8000 Merge pull request #116 from Shopify/opt-mult · github/ruby@cfe5d2c · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfe5d2c

Browse files
authored
Merge pull request #116 from Shopify/opt-mult
Implement opt_{mult,div}
2 parents 6ed39d5 + 991e4d5 commit cfe5d2c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

bootstraptest/test_yjit.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ def mod(a, b)
2626
mod(7, 5)
2727
}
2828

29+
# Test for opt_mult
30+
assert_equal '12', %q{
31+
def mult(a, b)
32+
a * b
33+
end
34+
35+
mult(6, 2)
36+
mult(6, 2)
37+
}
38+
39+
# Test for opt_div
40+
assert_equal '3', %q{
41+
def div(a, b)
42+
a / b
43+
end
44+
45+
div(6, 2)
46+
div(6, 2)
47+
}
48+
2949
# BOP redefined methods work when JIT compiled
3050
assert_equal 'false', %q{
3151
def less_than x

yjit_codegen.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ gen_opt_aset(jitstate_t *jit, ctx_t *ctx)
17921792
x86opnd_t arg1 = ctx_stack_pop(ctx, 1);
17931793
x86opnd_t arg0 = ctx_stack_pop(ctx, 1);
17941794

1795-
// Call rb_vm_opt_mod(VALUE recv, VALUE obj)
1795+
// Call rb_vm_opt_aset(VALUE recv, VALUE obj)
17961796
yjit_save_regs(cb);
17971797
mov(cb, C_ARG_REGS[0], arg0);
17981798
mov(cb, C_ARG_REGS[1], arg1);
@@ -1931,6 +1931,20 @@ gen_opt_plus(jitstate_t* jit, ctx_t* ctx)
19311931
return YJIT_KEEP_COMPILING;
19321932
}
19331933

1934+
static codegen_status_t
1935+
gen_opt_mult(jitstate_t* jit, ctx_t* ctx)
1936+
{
1937+
// Delegate to send, call the method on the recv
1938+
return gen_opt_send_without_block(jit, ctx);
1939+
}
1940+
1941+
static codegen_status_t
1942+
gen_opt_div(jitstate_t* jit, ctx_t* ctx)
1943+
{
1944+
// Delegate to send, call the method on the recv
1945+
return gen_opt_send_without_block(jit, ctx);
1946+
}
1947+
19341948
VALUE rb_vm_opt_mod(VALUE recv, VALUE obj);
19351949

19361950
static codegen_status_t
@@ -3460,6 +3474,8 @@ yjit_init_codegen(void)
34603474
yjit_reg_op(BIN(opt_or), gen_opt_or);
34613475
yjit_reg_op(BIN(opt_minus), gen_opt_minus);
34623476
yjit_reg_op(BIN(opt_plus), gen_opt_plus);
3477+
yjit_reg_op(BIN(opt_mult), gen_opt_mult);
3478+
yjit_reg_op(BIN(opt_div), gen_opt_div);
34633479
yjit_reg_op(BIN(opt_mod), gen_opt_mod);
34643480
yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt);
34653481
yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p);

0 commit comments

Comments
 (0)
0