Skip to content

Commit 39f8dc7

Browse files
kddnewtonXrXr
authored andcommitted
Implement opt_div
1 parent cfada4d commit 39f8dc7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

bootstraptest/test_yjit.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ def mult(a, b)
3636
mult(6, 2)
3737
}
3838

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+
3949
# BOP redefined methods work when JIT compiled
4050
assert_equal 'false', %q{
4151
def less_than x

yjit_codegen.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,13 @@ gen_opt_mult(jitstate_t* jit, ctx_t* ctx)
19401940
return gen_opt_send_without_block(jit, ctx);
19411941
}
19421942

1943+
static codegen_status_t
1944+
gen_opt_div(jitstate_t* jit, ctx_t* ctx)
1945+
{
1946+
// Delegate to send, call the method on the recv
1947+
return gen_opt_send_without_block(jit, ctx);
1948+
}
1949+
19431950
VALUE rb_vm_opt_mod(VALUE recv, VALUE obj);
19441951

19451952
static codegen_status_t
@@ -3470,6 +3477,7 @@ yjit_init_codegen(void)
34703477
yjit_reg_op(BIN(opt_minus), gen_opt_minus);
34713478
yjit_reg_op(BIN(opt_plus), gen_opt_plus);
34723479
yjit_reg_op(BIN(opt_mult), gen_opt_mult);
3480+
yjit_reg_op(BIN(opt_div), gen_opt_div);
34733481
yjit_reg_op(BIN(opt_mod), gen_opt_mod);
34743482
yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt);
34753483
yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p);

0 commit comments

Comments
 (0)