Skip to content

Commit

Permalink
Port gen_opt_str_freeze to new backend IR (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
fresh-eggs authored and k0kubun committed Aug 26, 2022
1 parent 7c5e1e8 commit c80aaf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions bootstraptest/test_yjit_new_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,14 @@ def foo
Foo.new.foo
}

# opt_str_freeze
assert_equal 'netscape', %q{
def foo()
"netscape".freeze
end
foo()
}

# BOP redefinition works on Integer#<
assert_equal 'false', %q{
def less_than x
Expand Down
10 changes: 5 additions & 5 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3054,27 +3054,27 @@ fn gen_opt_succ(
gen_opt_send_without_block(jit, ctx, asm, ocb)
}

/*

fn gen_opt_str_freeze(
jit: &mut JITState,
ctx: &mut Context,
cb: &mut CodeBlock,
asm: &mut Assembler,
ocb: &mut OutlinedCb,
) -> CodegenStatus {
if !assume_bop_not_redefined(jit, ocb, STRING_REDEFINED_OP_FLAG, BOP_FREEZE) {
return CantCompile;
}

let str = jit_get_arg(jit, 0);
jit_mov_gc_ptr(jit, cb, REG0, str);

// Push the return value onto the stack
let stack_ret = ctx.stack_push(Type::CString);
mov(cb, stack_ret, REG0);
asm.mov(stack_ret, str.into());

KeepCompiling
}

/*
fn gen_opt_str_uminus(
jit: &mut JITState,
ctx: &mut Context,
Expand Down Expand Up @@ -5964,7 +5964,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_opt_gt => Some(gen_opt_gt),
YARVINSN_opt_ge => Some(gen_opt_ge),
YARVINSN_opt_mod => Some(gen_opt_mod),
//YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze),
YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze),
//YARVINSN_opt_str_uminus => Some(gen_opt_str_uminus),
YARVINSN_splatarray => Some(gen_splatarray),
YARVINSN_newrange => Some(gen_newrange),
Expand Down

0 comments on commit c80aaf3

Please sign in to comment.