remove virtual new_frame instruction
resolved to one register instruction, not worth the hassle
This commit is contained in:
parent
3b07f625a7
commit
3a622efe9a
@ -1,22 +0,0 @@
|
|||||||
module Register
|
|
||||||
# This implements the creation of a new frame object.
|
|
||||||
# Or to be more precise, it makes the frame available in a register, as the message (any message)
|
|
||||||
# carries a frame around which is reused.
|
|
||||||
|
|
||||||
# Just as a reminder: a message object is used to send and holds return address/message
|
|
||||||
# and arguments + self
|
|
||||||
# frames are used by a method and hold local and temporary variables
|
|
||||||
|
|
||||||
|
|
||||||
class FrameImplementation
|
|
||||||
def run block
|
|
||||||
block.codes.dup.each do |code|
|
|
||||||
next unless code.is_a?(Virtual::NewFrame)
|
|
||||||
# load the frame from message by index, simple get_slot
|
|
||||||
new_codes = [ Register.get_slot( code, :message , :frame , Register.resolve_to_register(:frame))]
|
|
||||||
block.replace(code , new_codes )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Virtual.machine.add_pass "Register::FrameImplementation"
|
|
||||||
end
|
|
@ -1,7 +1,6 @@
|
|||||||
require_relative "instruction"
|
require_relative "instruction"
|
||||||
require_relative "register_value"
|
require_relative "register_value"
|
||||||
require_relative "assembler"
|
require_relative "assembler"
|
||||||
require_relative "passes/frame_implementation"
|
|
||||||
require_relative "passes/return_implementation"
|
require_relative "passes/return_implementation"
|
||||||
require_relative "passes/call_implementation"
|
require_relative "passes/call_implementation"
|
||||||
|
|
||||||
|
@ -17,4 +17,3 @@ require_relative "instructions/halt"
|
|||||||
require_relative "instructions/method_call"
|
require_relative "instructions/method_call"
|
||||||
require_relative "instructions/method_enter"
|
require_relative "instructions/method_enter"
|
||||||
require_relative "instructions/method_return"
|
require_relative "instructions/method_return"
|
||||||
require_relative "instructions/new_frame"
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
module Virtual
|
|
||||||
|
|
||||||
class NewFrame < Instruction
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -9,7 +9,7 @@ module Virtual
|
|||||||
new_codes << Register.save_return(code, :message , :return_address)
|
new_codes << Register.save_return(code, :message , :return_address)
|
||||||
# and create a new frame if needed
|
# and create a new frame if needed
|
||||||
unless code.method.locals.empty?
|
unless code.method.locals.empty?
|
||||||
new_codes << Virtual::NewFrame.new
|
new_codes << Register.get_slot( code, :message , :frame , Register.resolve_to_register(:frame))
|
||||||
end
|
end
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user