Fix MJIT's ISEQ_BODY macro usage at 5f10bd634fb

This commit is contained in:
Takashi Kokubun 2022-06-08 22:38:50 -07:00
parent 2931957d6f
commit 90b240d127
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
2 changed files with 11 additions and 1 deletions

View File

@ -370,7 +370,7 @@ mjit_compile_body(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
if (body->param.flags.has_opt) {
int i;
fprintf(f, "\n");
fprintf(f, " switch (reg_cfp->pc - reg_cfp->ISEQ_BODY(iseq)->iseq_encoded) {\n");
fprintf(f, " switch (reg_cfp->pc - ISEQ_BODY(reg_cfp->iseq)->iseq_encoded) {\n");
for (i = 0; i <= body->param.opt_num; i++) {
VALUE pc_offset = body->param.opt_table[i];
fprintf(f, " case %"PRIdVALUE":\n", pc_offset);

View File

@ -621,6 +621,16 @@ class TestMJIT < Test::Unit::TestCase
end;
end
def test_compile_opt_pc
assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 1)
begin;
def test(arg = 'hello')
print arg
end
test
end;
end
def test_mjit_output
out, err = eval_with_jit('5.times { puts "MJIT" }', verbose: 1, min_calls: 5)
assert_equal("MJIT\n" * 5, out)