8000 Implement opt_aset as interpreter handler call · github/ruby@0c3842d · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c3842d

Browse files
maximecbXrXr
authored andcommitted
Implement opt_aset as interpreter handler call
1 parent c9feb72 commit 0c3842d

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

vm_insnhelper.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5193,6 +5193,12 @@ vm_opt_aset(VALUE recv, VALUE obj, VALUE set)
51935193
}
51945194
}
51955195

5196+
VALUE
5197+
rb_vm_opt_aset(VALUE recv, VALUE obj, VALUE set)
5198+
{
5199+
return vm_opt_aset(recv, obj, set);
5200+
}
5201+
51965202
static VALUE
51975203
vm_opt_aref_with(VALUE recv, VALUE key)
51985204
{

yjit_codegen.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,42 @@ gen_opt_aref(jitstate_t *jit, ctx_t *ctx)
14021402
}
14031403
}
14041404

1405+
VALUE rb_vm_opt_aset(VALUE recv, VALUE obj, VALUE set);
1406+
1407+
static codegen_status_t
1408+
gen_opt_aset(jitstate_t *jit, ctx_t *ctx)
1409+
{
1410+
// Save the PC and SP because the callee may allocate
1411+
// Note that this modifies REG_SP, which is why we do it first
1412+
jit_save_pc(jit, REG0);
1413+
jit_save_sp(jit, ctx);
1414+
1415+
uint8_t* side_exit = yjit_side_exit(jit, ctx);
1416+
1417+
// Get the operands from the stack
1418+
x86opnd_t arg2 = ctx_stack_pop(ctx, 1);
1419+
x86opnd_t arg1 = ctx_stack_pop(ctx, 1);
1420+
x86opnd_t arg0 = ctx_stack_pop(ctx, 1);
1421+
1422+
// Call rb_vm_opt_mod(VALUE recv, VALUE obj)
1423+
yjit_save_regs(cb);
1424+
mov(cb, C_ARG_REGS[0], arg0);
1425+
mov(cb, C_ARG_REGS[1], arg1);
1426+
mov(cb, C_ARG_REGS[2], arg2);
1427+
call_ptr(cb, REG0, (void *)rb_vm_opt_aset);
1428+
yjit_load_regs(cb);
1429+
1430+
// If val == Qundef, bail to do a method call
1431+
cmp(cb, RAX, imm_opnd(Qundef));
1432+
je_ptr(cb, side_exit);
1433+
1434+
// Push the return value onto the stack
1435+
x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_UNKNOWN);
1436+
mov(cb, stack_ret, RAX);
1437+
1438+
return YJIT_KEEP_COMPILING;
1439+
}
1440+
14051441
static codegen_status_t
14061442
gen_opt_and(jitstate_t* jit, ctx_t* ctx)
14071443
{
@@ -2533,6 +2569,7 @@ yjit_init_codegen(void)
25332569
yjit_reg_op(BIN(opt_gt), gen_opt_gt);
25342570
yjit_reg_op(BIN(opt_eq), gen_opt_eq);
25352571
yjit_reg_op(BIN(opt_aref), gen_opt_aref);
2572+
yjit_reg_op(BIN(opt_aset), gen_opt_aset);
25362573
yjit_reg_op(BIN(opt_and), gen_opt_and);
25372574
yjit_reg_op(BIN(opt_or), gen_opt_or);
25382575
yjit_reg_op(BIN(opt_minus), gen_opt_minus);

0 commit comments

Comments
 (0)
0