RJIT: Convert opt_case_dispatch keys with #to_value

comptime_key is a Ruby object and the value is not valid in machine code.

This PR also implements `CMP r/m64, imm32 (Mod 01: [reg]+disp8)` that is
now needed for running mail.gem benchmark.
This commit is contained in:
Takashi Kokubun 2023-12-21 17:45:43 -08:00
Родитель 0c05551f58
Коммит 9a3c49ee5d
3 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -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