Skip to content

Commit

Permalink
RJIT: Fix the argument for defined
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Apr 4, 2023
1 parent 1950665 commit 98f0e2c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/ruby_vm/rjit/insn_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ def defined(jit, ctx, asm)
asm.cmovnz(:rax, :rcx)

# Push the return value onto the stack
out_type = if C::SPECIAL_CONST_P(C.to_ruby(pushval))
out_type = if C::SPECIAL_CONST_P(pushval)
Type::UnknownImm
else
Type::Unknown
Expand All @@ -1307,7 +1307,7 @@ def definedivar(jit, ctx, asm)
ivar_name = jit.operand(0)
# Value that will be pushed on the stack if the ivar is defined. In practice this is always the
# string "instance-variable". If the ivar is not defined, nil will be pushed instead.
pushval = jit.operand(2)
pushval = jit.operand(2, ruby: true)

# Get the receiver
recv = :rcx
Expand All @@ -1333,11 +1333,11 @@ def definedivar(jit, ctx, asm)
# }
asm.test(C_RET, 255)
asm.mov(:rax, Qnil)
asm.mov(:rcx, pushval)
asm.mov(:rcx, to_value(pushval))
asm.cmovnz(:rax, :rcx)

# Push the return value onto the stack
out_type = C::SPECIAL_CONST_P(C.to_ruby(pushval)) ? Type::UnknownImm : Type::Unknown
out_type = C::SPECIAL_CONST_P(pushval) ? Type::UnknownImm : Type::Unknown
stack_ret = ctx.stack_push(out_type)
asm.mov(stack_ret, :rax)

Expand All @@ -1358,7 +1358,7 @@ def definedivar(jit, ctx, asm)
asm.cmp(shape_opnd, shape_id)
jit_chain_guard(:jne, jit, ctx, asm, side_exit)

result = ivar_exists ? pushval : Qnil
result = ivar_exists ? C.to_value(pushval) : Qnil
putobject(jit, ctx, asm, val: result)

# Jump to next instruction. This allows guard chains to share the same successor.
Expand Down

0 comments on commit 98f0e2c

Please sign in to comment.