ruby-changes:68891
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:15:05 +0900 (JST)
Subject: [ruby-changes:68891] ac1aa84c1a (master): First sketch at temp type mapping
https://git.ruby-lang.org/ruby.git/commit/?id=ac1aa84c1a From ac1aa84c1a866ee58c1f75874ceb226b297d676d Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Tue, 30 Mar 2021 10:59:53 -0400 Subject: First sketch at temp type mapping --- yjit_codegen.c | 2 -- 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 https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L580 // 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 https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L682 } } - 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 @@ https://github.com/ruby/ruby/blob/trunk/yjit_core.h#L23 // 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/