1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-15 07:47:40 +00:00

Add ffi jit example.

This commit is contained in:
Calvin Rose
2022-12-03 17:52:23 -06:00
parent c731f01067
commit aa60c1f36a
4 changed files with 46 additions and 8 deletions

View File

@@ -0,0 +1,12 @@
###
### Relies on NASM being installed to assemble code.
### Only works on x86-64 Linux.
###
### Before running, compile hello.nasm to hello.bin with
### $ nasm hello.nasm -o hello.bin
(def bin (slurp "hello.bin"))
(def f (ffi/jitfn bin))
(def signature (ffi/signature :default :void))
(ffi/call f signature)
(print "called a jitted function with FFI!")