8000 Commit WIP setlocal_WC_1 implementation · github/ruby@b551bbb · GitHub
[go: up one dir, main page]

Skip to content

Commit b551bbb

Browse files
committed
Commit WIP setlocal_WC_1 implementation
1 parent 2fb842f commit b551bbb

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

ujit_codegen.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx)
339339

340340
// Compute the offset from BP to the local
341341
int32_t local_idx = (int32_t)jit_get_arg(jit, 0);
342-
const int32_t offs = -sizeof(VALUE) * local_idx;
342+
const int32_t offs = -(SIZEOF_VALUE * local_idx);
343343

344344
// Load the local from the block
345345
mov(cb, REG0, mem_opnd(64, REG0, offs));
@@ -351,6 +351,33 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx)
351351
return true;
352352
}
353353

354+
static bool
355+
gen_getlocal_wc1(jitstate_t* jit, ctx_t* ctx)
356+
{
357+
//fprintf(stderr, "gen_getlocal_wc1\n");
358+
359+
// Load environment pointer EP from CFP
360+
mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, ep));
361+
362+
// Get the previous EP from the current EP
363+
// See GET_PREV_EP(ep) macro
364+
// VALUE* prev_ep = ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
365+
mov(cb, REG0, mem_opnd(64, REG0, SIZEOF_VALUE * VM_ENV_DATA_INDEX_SPECVAL));
366+
and(cb, REG0, imm_opnd(~0x03));
367+
368+
// Load the local from the block
369+
// val = *(vm_get_ep(GET_EP(), level) - idx);
370+
int32_t local_idx = (int32_t)jit_get_arg(jit, 0);
371+
const int32_t offs = -(SIZEOF_VALUE * local_idx);
372+
mov(cb, REG0, mem_opnd(64, REG0, offs));
373+
374+
// Write the local at SP
375+
x86opnd_t stack_top = ctx_stack_push(ctx, T_NONE);
376+
mov(cb, stack_top, REG0);
377+
378+
return true;
379+
}
380+
354381
static bool
355382
gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx)
356383
{
@@ -1186,9 +1213,9 @@ gen_opt_swb_iseq(jitstate_t* jit, ctx_t* ctx, struct rb_call_data * cd, const rb
11861213

11871214
// Setup the new frame
11881215
// *cfp = (const struct rb_control_frame_struct) {
1189-
// .pc = 0,
1216+
// .pc = pc,
11901217
// .sp = sp,
1191-
// .iseq = 0,
1218+
// .iseq = iseq,
11921219
// .self = recv,
11931220
// .ep = sp - 1,
11941221
// .block_code = 0,
@@ -1348,6 +1375,7 @@ ujit_init_codegen(void)
13481375
ujit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix, false);
13491376
ujit_reg_op(BIN(putself), gen_putself, false);
13501377
ujit_reg_op(BIN(getlocal_WC_0), gen_getlocal_wc0, false);
1378+
//ujit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1, false);
13511379
ujit_reg_op(BIN(setlocal_WC_0), gen_setlocal_wc0, false);
13521380
ujit_reg_op(BIN(getinstancevariable), gen_getinstancevariable, false);
13531381
ujit_reg_op(BIN(setinstancevariable), gen_setinstancevariable, false);

0 commit comments

Comments
 (0)
0