rubyx/lib/virtual/passes/enter_implementation.rb
Torsten Ruger 3a622efe9a remove virtual new_frame instruction
resolved to one register instruction, not worth the hassle
2015-10-16 17:58:42 +03:00

20 lines
653 B
Ruby

module Virtual
class EnterImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a? Virtual::MethodEnter
new_codes = []
# save return register to the message at instance return_address
new_codes << Register.save_return(code, :message , :return_address)
# and create a new frame if needed
unless code.method.locals.empty?
new_codes << Register.get_slot( code, :message , :frame , Register.resolve_to_register(:frame))
end
block.replace(code , new_codes )
end
end
end
Virtual.machine.add_pass "Virtual::EnterImplementation"
end