diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2021-03-30 10:59:53 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:32 -0400 |
commit | ac1aa84c1a866ee58c1f75874ceb226b297d676d (patch) | |
tree | c14d2b53b68d0662ff950ad0997d4bc709f897d0 | |
parent | cb46a17ca16935c61bdc82e44cad0c6450e8a4ad (diff) |
First sketch at temp type mapping
-rw-r--r-- | yjit_codegen.c | 2 | ||||
-rw-r--r-- | yjit_core.h | 69 |
2 files changed, 69 insertions, 2 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index 6ccc6afc99..56b82a5b17 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -580,7 +580,6 @@ guard_self_is_object(codeblock_t *cb, x86opnd_t self_opnd, uint8_t *side_exit, c // cmp(cb, self_opnd, imm_opnd(Qnil)); // jbe(cb, side_exit); - ctx->self_is_object = true; } } @@ -683,7 +682,6 @@ jit_chain_guard(enum jcc_kinds jcc, jitstate_t *jit, const ctx_t *ctx, uint8_t d } } - bool rb_iv_index_tbl_lookup(struct st_table *iv_index_tbl, ID id, struct rb_iv_index_tbl_entry **ent); // vm_insnhelper.c enum { diff --git a/yjit_core.h b/yjit_core.h index 1467395210..5a407bf37a 100644 --- a/yjit_core.h +++ b/yjit_core.h @@ -23,6 +23,75 @@ // Default versioning context (no type information) #define DEFAULT_CTX ( (ctx_t){ 0 } ) + +/** +Represent the type of a value (local/stack/self) in YJIT +*/ +typedef struct yjit_val_type +{ + // Value is definitely a heap object + uint8_t is_heap : 1; + + // Value is definitely an immediate + uint8_t is_imm : 1; + + // NOTE: we could switch this to an enum, + // but then we also need a value for "unknown type" + uint8_t is_fixnum : 1; + uint8_t is_bool : 1; // is this useful? + uint8_t is_array : 1; // for opt_aref + uint8_t is_hash : 1; // for opt_aref + uint8_t is_symbol : 1; + uint8_t is_string : 1; + +} val_type_t; +STATIC_ASSERT(val_type_size, sizeof(val_type_t) == 1); + +// Unknown type, could be anything, all zeroes +#define TYPE_UNKNOWN ( (val_type_t){ 0 } ) + +// Could be any heap object +#define TYPE_HEAP ( (val_type_t){ .is_heap = 1 } ) + +// Could be any immediate +#define TYPE_IMM ( (val_type_t){ .is_imm = 1 } ) + +// Immediate integer +#define TYPE_FIXNUM ( (val_type_t){ .is_imm = 1, .is_fixnum = 1 } ) + +typedef enum yjit_temp_loc +{ + TEMP_STACK = 0, + TEMP_SELF, + TEMP_LOCAL, // Local with index + //TEMP_CONST, // Small constant + +} temp_loc_t; + +typedef struct yjit_temp_mapping +{ + // Where/how is the local stored? + uint8_t kind: 2; + + // Index of the local variale, + // or small non-negative constant + uint8_t idx : 6; + +} temp_mapping_t; +STATIC_ASSERT(temp_mapping_size, sizeof(temp_mapping_t) == 1); + +// By default, temps are just temps on the stack +#define MAP_STACK ( (temp_mapping_t) { 0 } ) + +// Temp value is actually self +#define MAP_SELF ( (temp_mapping_t) { .kind = TEMP_SELF } ) + + + + + + + /** Code generation context Contains information we can use to optimize code |