mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Implement putobject
This commit is contained in:
parent
9352f94a1b
commit
7a19aad8c3
3 changed files with 86 additions and 11 deletions
|
@ -153,7 +153,66 @@ module RubyVM::MJIT
|
||||||
asm.comment("Insn: #{insn.name}")
|
asm.comment("Insn: #{insn.name}")
|
||||||
|
|
||||||
case 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)
|
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)
|
when :leave then @insn_compiler.leave(jit, ctx, asm)
|
||||||
# throw
|
# throw
|
||||||
# jump
|
# jump
|
||||||
|
|
|
@ -4,7 +4,7 @@ module RubyVM::MJIT
|
||||||
# sp: rbx
|
# sp: rbx
|
||||||
# scratch regs: rax
|
# scratch regs: rax
|
||||||
class InsnCompiler
|
class InsnCompiler
|
||||||
# 3/101
|
# 4/101
|
||||||
|
|
||||||
# nop
|
# nop
|
||||||
# getlocal
|
# getlocal
|
||||||
|
@ -34,7 +34,27 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
# putself
|
# 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
|
# putspecialobject
|
||||||
# putstring
|
# putstring
|
||||||
# concatstrings
|
# concatstrings
|
||||||
|
|
|
@ -245,6 +245,10 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def imm32?(imm)
|
||||||
|
(-0x8000_0000..0x7fff_ffff).include?(imm) # TODO: consider uimm
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def insn(prefix: nil, opcode:, mod_rm: nil, disp: nil, imm: nil)
|
def insn(prefix: nil, opcode:, mod_rm: nil, disp: nil, imm: nil)
|
||||||
|
@ -347,16 +351,8 @@ module RubyVM::MJIT
|
||||||
(-0x80..0x7f).include?(imm)
|
(-0x80..0x7f).include?(imm)
|
||||||
end
|
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)
|
def imm64?(imm)
|
||||||
raise "negative imm not supported: #{imm}" if imm.negative? # TODO: support this
|
(-0x8000_0000_0000_0000..0x7fff_ffff_ffff_ffff).include?(imm) # TODO: consider uimm
|
||||||
# TODO: consider rejecting small values
|
|
||||||
imm <= 0x7fff_ffff_ffff_ffff # TODO: consider uimm
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def r32?(reg)
|
def r32?(reg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue