diff options
author | Jose Narvaez <[email protected]> | 2021-03-06 23:46:56 +0000 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:31 -0400 |
commit | 4e2eb7695e9b45cb5d2ae757bdb5c2043d78be78 (patch) | |
tree | 71e02cd04b191b9ce66801b67736cf69d831bd0b /yjit_codegen.h | |
parent | 7f7e79d80221949f93c7ded7cbd8d26afd3dea1d (diff) |
Yet Another Ruby JIT!
Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
Diffstat (limited to 'yjit_codegen.h')
-rw-r--r-- | yjit_codegen.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/yjit_codegen.h b/yjit_codegen.h new file mode 100644 index 0000000000..f5be7c4de6 --- /dev/null +++ b/yjit_codegen.h @@ -0,0 +1,47 @@ +#ifndef YJIT_CODEGEN_H +#define YJIT_CODEGEN_H 1 + +#include "stddef.h" +#include "yjit_core.h" + +// Code blocks we generate code into +extern codeblock_t *cb; +extern codeblock_t *ocb; + +// Code generation state +typedef struct JITState +{ + // Block version being compiled + block_t* block; + + // Instruction sequence this is associated with + const rb_iseq_t *iseq; + + // Index of the current instruction being compiled + uint32_t insn_idx; + + // PC of the instruction being compiled + VALUE *pc; + + // Execution context when compilation started + // This allows us to peek at run-time values + rb_execution_context_t* ec; + +} jitstate_t; + +typedef enum codegen_status { + YJIT_END_BLOCK, + YJIT_KEEP_COMPILING, + YJIT_CANT_COMPILE +} codegen_status_t; + +// Code generation function signature +typedef codegen_status_t (*codegen_fn)(jitstate_t* jit, ctx_t* ctx); + +uint8_t* yjit_entry_prologue(); + +void yjit_gen_block(ctx_t* ctx, block_t* block, rb_execution_context_t* ec); + +void yjit_init_codegen(void); + +#endif // #ifndef YJIT_CODEGEN_H |