diff --git a/lib/ruby_vm/rjit/assembler.rb b/lib/ruby_vm/rjit/assembler.rb index 64f663ec0e..645072d11b 100644 --- a/lib/ruby_vm/rjit/assembler.rb +++ b/lib/ruby_vm/rjit/assembler.rb @@ -328,6 +328,17 @@ module RubyVM::RJIT disp: left_disp, imm: imm8(right_imm), ) + # CMP r/m64, imm32 (Mod 01: [reg]+disp8) + in [QwordPtr[R64 => left_reg, IMM8 => left_disp], IMM32 => right_imm] + # REX.W + 81 /7 id + # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32 + insn( + prefix: REX_W, + opcode: 0x81, + mod_rm: ModRM[mod: Mod01, reg: 7, rm: left_reg], + disp: left_disp, + imm: imm32(right_imm), + ) # CMP r/m64, imm8 (Mod 10: [reg]+disp32) in [QwordPtr[R64 => left_reg, IMM32 => left_disp], IMM8 => right_imm] # REX.W + 83 /7 ib diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb index 74a982e898..cb92723d9c 100644 --- a/lib/ruby_vm/rjit/insn_compiler.rb +++ b/lib/ruby_vm/rjit/insn_compiler.rb @@ -2099,7 +2099,7 @@ module RubyVM::RJIT end # Check if the key is the same value - asm.cmp(key_opnd, comptime_key) + asm.cmp(key_opnd, to_value(comptime_key)) side_exit = side_exit(jit, starting_context) jit_chain_guard(:jne, jit, starting_context, asm, side_exit) diff --git a/test/ruby/rjit/test_assembler.rb b/test/ruby/rjit/test_assembler.rb index a9ed6ce39e..fbf780d6c3 100644 --- a/test/ruby/rjit/test_assembler.rb +++ b/test/ruby/rjit/test_assembler.rb @@ -122,6 +122,7 @@ module RubyVM::RJIT asm.cmp(BytePtr[:rax, 8], 8) # CMP r/m8, imm8 (Mod 01: [reg]+disp8) asm.cmp(DwordPtr[:rax, 8], 0x100) # CMP r/m32, imm32 (Mod 01: [reg]+disp8) asm.cmp([:rax, 8], 8) # CMP r/m64, imm8 (Mod 01: [reg]+disp8) + asm.cmp([:rbx, 8], 0x100) # CMP r/m64, imm32 (Mod 01: [reg]+disp8) asm.cmp([:rax, 0x100], 8) # CMP r/m64, imm8 (Mod 10: [reg]+disp32) asm.cmp(:rax, 8) # CMP r/m64, imm8 (Mod 11: reg) asm.cmp(:rax, 0x100) # CMP r/m64, imm32 (Mod 11: reg) @@ -132,12 +133,13 @@ module RubyVM::RJIT 0x0: cmp byte ptr [rax + 8], 8 0x4: cmp dword ptr [rax + 8], 0x100 0xb: cmp qword ptr [rax + 8], 8 - 0x10: cmp qword ptr [rax + 0x100], 8 - 0x18: cmp rax, 8 - 0x1c: cmp rax, 0x100 - 0x23: cmp qword ptr [rax + 8], rbx - 0x27: cmp qword ptr [rax - 0x100], rbx - 0x2e: cmp rax, rbx + 0x10: cmp qword ptr [rbx + 8], 0x100 + 0x18: cmp qword ptr [rax + 0x100], 8 + 0x20: cmp rax, 8 + 0x24: cmp rax, 0x100 + 0x2b: cmp qword ptr [rax + 8], rbx + 0x2f: cmp qword ptr [rax - 0x100], rbx + 0x36: cmp rax, rbx EOS end