diff options
| -rw-r--r-- | test/ruby/test_zjit.rb | 10 | ||||
| -rw-r--r-- | zjit/src/codegen.rs | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 692dfb486c..7c29fdeb19 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -99,6 +99,16 @@ class TestZJIT < Test::Unit::TestCase }, insns: [:intern] end + def test_duphash + assert_compiles '{a: 1}', %q{ + def test + {a: 1} + end + + test + }, insns: [:duphash] + end + def test_setglobal_with_trace_var_exception assert_compiles '"rescued"', %q{ def test diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index ba28af73b1..8b3f4f84be 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -398,13 +398,13 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio &Insn::IncrCounter(counter) => no_output!(gen_incr_counter(asm, counter)), Insn::ObjToString { val, cd, state, .. } => gen_objtostring(jit, asm, opnd!(val), *cd, &function.frame_state(*state)), &Insn::CheckInterrupts { state } => no_output!(gen_check_interrupts(jit, asm, &function.frame_state(state))), + &Insn::HashDup { val, state } => { gen_hash_dup(asm, opnd!(val), &function.frame_state(state)) }, &Insn::ArrayExtend { state, .. } | &Insn::ArrayMax { state, .. } | &Insn::ArrayPush { state, .. } | &Insn::DefinedIvar { state, .. } | &Insn::FixnumDiv { state, .. } | &Insn::FixnumMod { state, .. } - | &Insn::HashDup { state, .. } | &Insn::Send { state, .. } | &Insn::Throw { state, .. } | &Insn::ToArray { state, .. } @@ -684,6 +684,11 @@ fn gen_check_interrupts(jit: &mut JITState, asm: &mut Assembler, state: &FrameSt asm.jnz(side_exit(jit, state, SideExitReason::Interrupt)); } +fn gen_hash_dup(asm: &mut Assembler, val: Opnd, state: &FrameState) -> lir::Opnd { + gen_prepare_call_with_gc(asm, state); + asm_ccall!(asm, rb_hash_resurrect, val) +} + /// Compile an interpreter entry block to be inserted into an ISEQ fn gen_entry_prologue(asm: &mut Assembler, iseq: IseqPtr) { asm_comment!(asm, "ZJIT entry point: {}", iseq_get_location(iseq, 0)); |
