Skip to content

Commit

Permalink
Port objtostring to the new backend (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Aug 26, 2022
1 parent d1fdafa commit c29ae5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bootstraptest/test_yjit_new_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,15 @@ def foo()
foo()
}

# toregexp
# toregexp, objtostring
assert_equal '/true/', %q{
def foo()
/#{true}/
end
foo().inspect
}

# concatstrings
# concatstrings, objtostring
assert_equal '9001', %q{
def foo()
"#{9001}"
Expand Down
16 changes: 7 additions & 9 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ fn gen_concatstrings(
// Save the PC and SP because we are allocating
jit_prepare_routine_call(jit, ctx, asm);

let values_ptr = ctx.sp_opnd(-((SIZEOF_VALUE as isize) * n.as_isize()));
let values_ptr = asm.lea(ctx.sp_opnd(-((SIZEOF_VALUE as isize) * n.as_isize())));

// call rb_str_concat_literals(long n, const VALUE *strings);
let return_value = asm.ccall(
Expand Down Expand Up @@ -5317,15 +5317,14 @@ fn gen_anytostring(
KeepCompiling
}

/*
fn gen_objtostring(
jit: &mut JITState,
ctx: &mut Context,
cb: &mut CodeBlock,
asm: &mut Assembler,
ocb: &mut OutlinedCb,
) -> CodegenStatus {
if !jit_at_current_insn(jit) {
defer_compilation(jit, ctx, cb, ocb);
defer_compilation(jit, ctx, asm, ocb);
return EndBlock;
}

Expand All @@ -5338,7 +5337,7 @@ fn gen_objtostring(
jit_guard_known_klass(
jit,
ctx,
cb,
asm,
ocb,
comptime_recv.class_of(),
recv,
Expand All @@ -5351,10 +5350,9 @@ fn gen_objtostring(
KeepCompiling
} else {
let cd = jit_get_arg(jit, 0).as_ptr();
gen_send_general(jit, ctx, cb, ocb, cd, None)
gen_send_general(jit, ctx, asm, ocb, cd, None)
}
}
*/

fn gen_intern(
jit: &mut JITState,
Expand Down Expand Up @@ -5388,7 +5386,7 @@ fn gen_toregexp(
// raise an exception.
jit_prepare_routine_call(jit, ctx, asm);

let values_ptr = ctx.sp_opnd(-((SIZEOF_VALUE as isize) * (cnt as isize)));
let values_ptr = asm.lea(ctx.sp_opnd(-((SIZEOF_VALUE as isize) * (cnt as isize))));
ctx.stack_pop(cnt);

let ary = asm.ccall(
Expand Down Expand Up @@ -6011,7 +6009,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_getglobal => Some(gen_getglobal),
YARVINSN_setglobal => Some(gen_setglobal),
YARVINSN_anytostring => Some(gen_anytostring),
//YARVINSN_objtostring => Some(gen_objtostring),
YARVINSN_objtostring => Some(gen_objtostring),
YARVINSN_intern => Some(gen_intern),
YARVINSN_toregexp => Some(gen_toregexp),
YARVINSN_getspecial => Some(gen_getspecial),
Expand Down

0 comments on commit c29ae5b

Please sign in to comment.