Skip to content

Commit

Permalink
Port setglobal to the new backend (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Aug 26, 2022
1 parent 01c4dd3 commit ea4b6e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 8 additions & 0 deletions bootstraptest/test_yjit_new_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ def function()
function()
}

# setglobal
assert_equal 'foo', %q{
def foo()
$foo = "foo"
end
foo()
$foo
}



Expand Down
22 changes: 11 additions & 11 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5298,30 +5298,30 @@ fn gen_getglobal(
KeepCompiling
}

/*
fn gen_setglobal(
jit: &mut JITState,
ctx: &mut Context,
cb: &mut CodeBlock,
asm: &mut Assembler,
_ocb: &mut OutlinedCb,
) -> CodegenStatus {
let gid = jit_get_arg(jit, 0);

// Save the PC and SP because we might make a Ruby call for
// Kernel#set_trace_var
jit_prepare_routine_call(jit, ctx, cb, REG0);
mov(cb, C_ARG_REGS[0], imm_opnd(gid.as_i64()));
let val = ctx.stack_pop(1);
mov(cb, C_ARG_REGS[1], val);
jit_prepare_routine_call(jit, ctx, asm);

call_ptr(cb, REG0, rb_gvar_set as *const u8);
asm.ccall(
rb_gvar_set as *const u8,
vec![
gid.into(),
ctx.stack_pop(1),
],
);

KeepCompiling
}

/*
fn gen_anytostring(
jit: &mut JITState,
ctx: &mut Context,
Expand Down Expand Up @@ -6028,8 +6028,8 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_leave => Some(gen_leave),

YARVINSN_getglobal => Some(gen_getglobal),
/*
YARVINSN_setglobal => Some(gen_setglobal),
/*
YARVINSN_anytostring => Some(gen_anytostring),
YARVINSN_objtostring => Some(gen_objtostring),
YARVINSN_intern => Some(gen_intern),
Expand Down

0 comments on commit ea4b6e5

Please sign in to comment.