@@ -785,22 +785,21 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx)
785
785
}
786
786
787
787
static codegen_status_t
788
- gen_getlocal_wc1 ( jitstate_t * jit , ctx_t * ctx )
788
+ gen_getlocal_generic ( ctx_t * ctx , uint32_t local_idx , uint32_t level )
789
789
{
790
- //fprintf(stderr, "gen_getlocal_wc1\n");
791
-
792
790
// Load environment pointer EP from CFP
793
791
mov (cb , REG0 , member_opnd (REG_CFP , rb_control_frame_t , ep ));
794
792
795
- // Get the previous EP from the current EP
796
- // See GET_PREV_EP(ep) macro
797
- // VALUE* prev_ep = ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
798
- mov (cb , REG0 , mem_opnd (64 , REG0 , SIZEOF_VALUE * VM_ENV_DATA_INDEX_SPECVAL ));
799
- and (cb , REG0 , imm_opnd (~0x03 ));
793
+ while (level -- ) {
794
+ // Get the previous EP from the current EP
795
+ // See GET_PREV_EP(ep) macro
796
+ // VALUE* prev_ep = ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
797
+ mov (cb , REG0 , mem_opnd (64 , REG0 , SIZEOF_VALUE * VM_ENV_DATA_INDEX_SPECVAL ));
798
+ and (cb , REG0 , imm_opnd (~0x03 ));
799
+ }
800
800
801
801
// Load the local from the block
802
802
// val = *(vm_get_ep(GET_EP(), level) - idx);
803
- int32_t local_idx = (int32_t )jit_get_arg (jit , 0 );
804
803
const int32_t offs = - (SIZEOF_VALUE * local_idx );
805
804
mov (cb , REG0 , mem_opnd (64 , REG0 , offs ));
806
805
@@ -811,6 +810,21 @@ gen_getlocal_wc1(jitstate_t* jit, ctx_t* ctx)
811
810
return YJIT_KEEP_COMPILING ;
812
811
}
813
812
813
+ static codegen_status_t
814
+ gen_getlocal (jitstate_t * jit , ctx_t * ctx )
815
+ {
816
+ int32_t idx = (int32_t )jit_get_arg (jit , 0 );
817
+ int32_t level = (int32_t )jit_get_arg (jit , 1 );
818
+ return gen_getlocal_generic (ctx , idx , level );
819
+ }
820
+
821
+ static codegen_status_t
822
+ gen_getlocal_wc1 (jitstate_t * jit , ctx_t * ctx )
823
+ {
824
+ int32_t idx = (int32_t )jit_get_arg (jit , 0 );
825
+ return gen_getlocal_generic (ctx , idx , 1 );
826
+ }
827
+
814
828
static codegen_status_t
815
829
gen_setlocal_wc0 (jitstate_t * jit , ctx_t * ctx )
816
830
{
@@ -3057,6 +3071,7 @@ yjit_init_codegen(void)
3057
3071
yjit_reg_op (BIN (putobject_INT2FIX_0_ ), gen_putobject_int2fix );
3058
3072
yjit_reg_op (BIN (putobject_INT2FIX_1_ ), gen_putobject_int2fix );
3059
3073
yjit_reg_op (BIN (putself ), gen_putself );
3074
+ yjit_reg_op (BIN (getlocal ), gen_getlocal );
3060
3075
yjit_reg_op (BIN (getlocal_WC_0 ), gen_getlocal_wc0 );
3061
3076
yjit_reg_op (BIN (getlocal_WC_1 ), gen_getlocal_wc1 );
3062
3077
yjit_reg_op (BIN (setlocal_WC_0 ), gen_setlocal_wc0 );
0 commit comments