2021-03-07 02:46:56 +03:00
|
|
|
#ifndef YJIT_CODEGEN_H
|
|
|
|
#define YJIT_CODEGEN_H 1
|
2020-12-09 00:54:41 +03:00
|
|
|
|
|
|
|
#include "stddef.h"
|
2021-03-07 02:46:56 +03:00
|
|
|
#include "yjit_core.h"
|
2020-12-09 00:54:41 +03:00
|
|
|
|
2020-12-17 05:45:51 +03:00
|
|
|
// Code blocks we generate code into
|
2021-01-22 23:06:51 +03:00
|
|
|
extern codeblock_t *cb;
|
|
|
|
extern codeblock_t *ocb;
|
2021-08-26 00:00:45 +03:00
|
|
|
extern uint32_t yjit_codepage_frozen_bytes;
|
2020-12-17 05:45:51 +03:00
|
|
|
|
2020-12-18 23:02:43 +03:00
|
|
|
// Code generation state
|
|
|
|
typedef struct JITState
|
|
|
|
{
|
2021-01-13 01:03:54 +03:00
|
|
|
// Block version being compiled
|
2021-01-14 21:33:19 +03:00
|
|
|
block_t* block;
|
2021-01-13 01:03:54 +03:00
|
|
|
|
2020-12-18 23:02:43 +03:00
|
|
|
// Instruction sequence this is associated with
|
|
|
|
const rb_iseq_t *iseq;
|
|
|
|
|
|
|
|
// Index of the current instruction being compiled
|
|
|
|
uint32_t insn_idx;
|
|
|
|
|
2021-05-04 19:35:51 +03:00
|
|
|
// Opcode for the instruction being compiled
|
|
|
|
int opcode;
|
|
|
|
|
2021-03-02 04:43:58 +03:00
|
|
|
// PC of the instruction being compiled
|
2020-12-18 23:02:43 +03:00
|
|
|
VALUE *pc;
|
|
|
|
|
2021-03-02 04:43:58 +03:00
|
|
|
// Execution context when compilation started
|
|
|
|
// This allows us to peek at run-time values
|
|
|
|
rb_execution_context_t* ec;
|
2020-12-17 01:07:18 +03:00
|
|
|
|
2021-08-26 00:00:45 +03:00
|
|
|
// Whether we need to record the code address at
|
|
|
|
// the end of this bytecode instruction for tracing suppoert
|
|
|
|
bool record_boundary_patch_point;
|
|
|
|
|
2021-03-02 04:43:58 +03:00
|
|
|
} jitstate_t;
|
2021-01-08 01:09:25 +03:00
|
|
|
|
2021-03-02 04:43:58 +03:00
|
|
|
typedef enum codegen_status {
|
2021-03-07 02:46:56 +03:00
|
|
|
YJIT_END_BLOCK,
|
|
|
|
YJIT_KEEP_COMPILING,
|
|
|
|
YJIT_CANT_COMPILE
|
2021-03-02 04:43:58 +03:00
|
|
|
} codegen_status_t;
|
2021-01-08 01:09:25 +03:00
|
|
|
|
2021-03-02 04:43:58 +03:00
|
|
|
// Code generation function signature
|
|
|
|
typedef codegen_status_t (*codegen_fn)(jitstate_t* jit, ctx_t* ctx);
|
2021-01-08 01:09:25 +03:00
|
|
|
|
2021-07-15 21:09:08 +03:00
|
|
|
uint8_t* yjit_entry_prologue(const rb_iseq_t* iseq);
|
2020-12-18 21:49:53 +03:00
|
|
|
|
2021-04-24 07:16:48 +03:00
|
|
|
void yjit_gen_block(block_t* block, rb_execution_context_t* ec);
|
2020-12-09 00:54:41 +03:00
|
|
|
|
2021-03-07 02:46:56 +03:00
|
|
|
void yjit_init_codegen(void);
|
2020-12-09 00:54:41 +03:00
|
|
|
|
2021-03-07 02:46:56 +03:00
|
|
|
#endif // #ifndef YJIT_CODEGEN_H
|