This commit is contained in:
Takashi Kokubun 2022-12-28 14:43:04 -08:00
Родитель 9352f94a1b
Коммит 7a19aad8c3
3 изменённых файлов: 86 добавлений и 11 удалений

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

@ -153,7 +153,66 @@ module RubyVM::MJIT
asm.comment("Insn: #{insn.name}")
case insn.name
# nop
# getlocal
# setlocal
# getblockparam
# setblockparam
# getblockparamproxy
# getspecial
# setspecial
# getinstancevariable
# setinstancevariable
# getclassvariable
# setclassvariable
# opt_getconstant_path
# getconstant
# setconstant
# getglobal
# setglobal
when :putnil then @insn_compiler.putnil(jit, ctx, asm)
# putself
when :putobject then @insn_compiler.putobject(jit, ctx, asm)
# putspecialobject
# putstring
# concatstrings
# anytostring
# toregexp
# intern
# newarray
# newarraykwsplat
# duparray
# duphash
# expandarray
# concatarray
# splatarray
# newhash
# newrange
# pop
# dup
# dupn
# swap
# opt_reverse
# topn
# setn
# adjuststack
# defined
# checkmatch
# checkkeyword
# checktype
# defineclass
# definemethod
# definesmethod
# send
# opt_send_without_block
# objtostring
# opt_str_freeze
# opt_nil_p
# opt_str_uminus
# opt_newarray_max
# opt_newarray_min
# invokesuper
# invokeblock
when :leave then @insn_compiler.leave(jit, ctx, asm)
# throw
# jump

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

@ -4,7 +4,7 @@ module RubyVM::MJIT
# sp: rbx
# scratch regs: rax
class InsnCompiler
# 3/101
# 4/101
# nop
# getlocal
@ -34,7 +34,27 @@ module RubyVM::MJIT
end
# putself
# putobject
# @param jit [RubyVM::MJIT::JITState]
# @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::X86Assembler]
def putobject(jit, ctx, asm)
# Get operands
val = jit.operand(0)
# Push it to the stack
# TODO: GC offsets
if asm.imm32?(val)
asm.mov([SP, C.VALUE.size * ctx.stack_size], val)
else # 64-bit immediates can't be directly written to memory
asm.mov(:rax, val)
asm.mov([SP, C.VALUE.size * ctx.stack_size], :rax)
end
ctx.stack_size += 1
KeepCompiling
end
# putspecialobject
# putstring
# concatstrings

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

@ -245,6 +245,10 @@ module RubyVM::MJIT
end
end
def imm32?(imm)
(-0x8000_0000..0x7fff_ffff).include?(imm) # TODO: consider uimm
end
private
def insn(prefix: nil, opcode:, mod_rm: nil, disp: nil, imm: nil)
@ -347,16 +351,8 @@ module RubyVM::MJIT
(-0x80..0x7f).include?(imm)
end
def imm32?(imm)
raise "negative imm not supported: #{imm}" if imm.negative? # TODO: support this
# TODO: consider rejecting small values
imm <= 0x7fff_ffff # TODO: consider uimm
end
def imm64?(imm)
raise "negative imm not supported: #{imm}" if imm.negative? # TODO: support this
# TODO: consider rejecting small values
imm <= 0x7fff_ffff_ffff_ffff # TODO: consider uimm
(-0x8000_0000_0000_0000..0x7fff_ffff_ffff_ffff).include?(imm) # TODO: consider uimm
end
def r32?(reg)