aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-08-01 10:34:15 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:47:05 -0700
commita674b8d8a13c9dbffb92dbcab7ff297a8b99591b (patch)
tree4fd6c3044b824387851d0d2e37828f0f54ae0df5
parent1446e22aeba09c55227c56b9c2f6cb90facc9512 (diff)
downloadruby-a674b8d8a13c9dbffb92dbcab7ff297a8b99591b.tar.gz
Port class variable instructions (https://github.com/Shopify/ruby/pull/346)
-rw-r--r--yjit/src/codegen.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 940ffed3df..73d76759a6 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -5525,26 +5525,29 @@ fn gen_getspecial(
KeepCompiling
}
}
+*/
fn gen_getclassvariable(
jit: &mut JITState,
ctx: &mut Context,
- cb: &mut CodeBlock,
+ asm: &mut Assembler,
_ocb: &mut OutlinedCb,
) -> CodegenStatus {
// rb_vm_getclassvariable can raise exceptions.
- jit_prepare_routine_call(jit, ctx, cb, REG0);
-
- let cfp_iseq_opnd = mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_ISEQ);
- mov(cb, C_ARG_REGS[0], cfp_iseq_opnd);
- mov(cb, C_ARG_REGS[1], REG_CFP);
- mov(cb, C_ARG_REGS[2], uimm_opnd(jit_get_arg(jit, 0).as_u64()));
- mov(cb, C_ARG_REGS[3], uimm_opnd(jit_get_arg(jit, 1).as_u64()));
+ jit_prepare_routine_call(jit, ctx, asm);
- call_ptr(cb, REG0, rb_vm_getclassvariable as *const u8);
+ let val_opnd = asm.ccall(
+ rb_vm_getclassvariable as *const u8,
+ vec![
+ Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ),
+ CFP,
+ Opnd::UImm(jit_get_arg(jit, 0).as_u64()),
+ Opnd::UImm(jit_get_arg(jit, 1).as_u64()),
+ ],
+ );
- let stack_top = ctx.stack_push(Type::Unknown);
- mov(cb, stack_top, RAX);
+ let top = ctx.stack_push(Type::Unknown);
+ asm.mov(top, val_opnd);
KeepCompiling
}
@@ -5552,24 +5555,27 @@ fn gen_getclassvariable(
fn gen_setclassvariable(
jit: &mut JITState,
ctx: &mut Context,
- cb: &mut CodeBlock,
+ asm: &mut Assembler,
_ocb: &mut OutlinedCb,
) -> CodegenStatus {
// rb_vm_setclassvariable can raise exceptions.
- jit_prepare_routine_call(jit, ctx, cb, REG0);
-
- let cfp_iseq_opnd = mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_ISEQ);
- mov(cb, C_ARG_REGS[0], cfp_iseq_opnd);
- mov(cb, C_ARG_REGS[1], REG_CFP);
- mov(cb, C_ARG_REGS[2], uimm_opnd(jit_get_arg(jit, 0).as_u64()));
- mov(cb, C_ARG_REGS[3], ctx.stack_pop(1));
- mov(cb, C_ARG_REGS[4], uimm_opnd(jit_get_arg(jit, 1).as_u64()));
+ jit_prepare_routine_call(jit, ctx, asm);
- call_ptr(cb, REG0, rb_vm_setclassvariable as *const u8);
+ asm.ccall(
+ rb_vm_setclassvariable as *const u8,
+ vec![
+ Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ),
+ CFP,
+ Opnd::UImm(jit_get_arg(jit, 0).as_u64()),
+ ctx.stack_pop(1),
+ Opnd::UImm(jit_get_arg(jit, 1).as_u64()),
+ ],
+ );
KeepCompiling
}
+/*
fn gen_opt_getinlinecache(
jit: &mut JITState,
ctx: &mut Context,
@@ -6035,9 +6041,9 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_intern => Some(gen_intern),
YARVINSN_toregexp => Some(gen_toregexp),
YARVINSN_getspecial => Some(gen_getspecial),
+ */
YARVINSN_getclassvariable => Some(gen_getclassvariable),
YARVINSN_setclassvariable => Some(gen_setclassvariable),
- */
// Unimplemented opcode, YJIT won't generate code for this yet
_ => None,