Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port objtostring to the new backend #369

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bootstraptest/test_yjit_new_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,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 @@ -5328,15 +5328,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 @@ -5349,7 +5348,7 @@ fn gen_objtostring(
jit_guard_known_klass(
jit,
ctx,
cb,
asm,
ocb,
comptime_recv.class_of(),
recv,
Expand All @@ -5362,10 +5361,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 @@ -5399,7 +5397,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 @@ -6022,7 +6020,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