/* * jit.h — x86_64 JIT compiler for lumbda * * Compiles Scheme procedures to native machine code. * Uses mmap(PROT_READ|PROT_WRITE|PROT_EXEC) for executable memory. * * Code outlasts authors. */ #ifndef JIT_H #define JIT_H #include "lumbda.h" /* A JIT-compiled function takes NaN-boxed Value args and returns a Value. * System V AMD64 ABI: args in rdi, rsi, rdx, rcx, r8, r9 */ typedef Value (*JitFunc)(Value, Value, Value, Value, Value, Value); /* Opaque handle to a JIT code block */ typedef struct JitBlock { void *code; /* mmap'd executable memory */ size_t size; /* allocated size */ JitFunc func; /* entry point (same as code) */ const char *name; /* procedure name for debugging */ } JitBlock; /* Try to JIT-compile a Proc. Returns NULL if the proc uses features * we can't JIT (call/cc, macros, complex forms). */ JitBlock *jit_compile(Proc *proc); /* Free a JIT code block */ void jit_free(JitBlock *block); /* Global flag — enable JIT compilation */ extern bool g_jit_enabled; #endif /* JIT_H */