more ripples from removing index constants

This commit is contained in:
Torsten Ruger 2015-06-29 20:58:06 +03:00
parent 1e18db00c9
commit 553f30c874
5 changed files with 15 additions and 15 deletions

View File

@ -15,7 +15,7 @@ module Arm
def putstring int_code , codes
codes << ArmMachine.mov( :r1 , 20 ) # String length, obvious TODO
codes << ArmMachine.ldr( :r0 , Register::RegisterReference.message_reg, 4 * Virtual::SELF_INDEX)
codes << ArmMachine.ldr( :r0 , Register.message_reg, 4 * Register.resolve_index(:message , :receiver))
syscall(int_code , codes )
end

View File

@ -13,9 +13,9 @@ module Register
next unless code.is_a? Virtual::MethodCall
new_codes = []
# move the current new_message to message
new_codes << RegisterTransfer.new( RegisterReference.new_message_reg , RegisterReference.message_reg )
new_codes << RegisterTransfer.new( Register.new_message_reg , Register.message_reg )
# "roll out" self into its register
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::SELF_INDEX, RegisterReference.self_reg )
new_codes << Register.get_slot( :message , :receiver, :self )
# do the register call
new_codes << FunctionCall.new( code.method )
block.replace(code , new_codes )

View File

@ -30,21 +30,21 @@ module Register
next
end
# a place to store a reference to the space, we grab the next_frame from the space
space_tmp = RegisterReference.tmp_reg
space_tmp = Register.tmp_reg
# move the spave to it's register (mov instruction gets the address of the object)
new_codes = [ LoadConstant.new( Parfait::Space.object_space , space_tmp )]
# find index in the space where to grab frame/message
space_index = Parfait::Space.object_space.get_layout().index_of( kind )
space_index = Register.resolve_index( :space , kind )
raise "index not found for #{kind}.#{kind.class}" unless space_index
# load the frame/message from space by index
new_codes << GetSlot.new( space_tmp , space_index , RegisterReference.frame_reg )
new_codes << GetSlot.new( space_tmp , space_index , Register.resolve_to_register(:frame) )
# a temporary place to store the new frame
frame_tmp = space_tmp.next_reg_use
# get the next_frame
from = Parfait::Space.object_space.send( kind )
kind_index = from.get_layout().index_of( kind )
raise "index not found for #{kind}.#{kind.class}" unless kind_index
new_codes << GetSlot.new( RegisterReference.frame_reg , kind_index , frame_tmp) # 2 index of next_frame
new_codes << GetSlot.new( Register.frame_reg , kind_index , frame_tmp) # 2 index of next_frame
# save next frame into space
new_codes << SetSlot.new( frame_tmp , space_tmp , space_index)
block.replace(code , new_codes )

View File

@ -5,14 +5,14 @@ module Register
next unless code.is_a? Virtual::MethodReturn
new_codes = []
# move the current message to new_message
new_codes << RegisterTransfer.new( RegisterReference.message_reg , RegisterReference.new_message_reg )
new_codes << RegisterTransfer.new( Register.message_reg , Register.new_message_reg )
# and restore the message from saved value in new_message
new_codes << GetSlot.new( RegisterReference.new_message_reg , Virtual::CALLER_INDEX , RegisterReference.message_reg)
new_codes << Register.get_slot(:new_message , :caller , :message )
# "roll out" self and frame into their registers
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::SELF_INDEX , RegisterReference.self_reg )
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::FRAME_INDEX , RegisterReference.frame_reg )
new_codes << Register.get_slot( :message , :receiver , :self )
new_codes << Register.get_slot( :message , :frame , :frame )
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
new_codes << FunctionReturn.new( RegisterReference.message_reg , Virtual::RETURN_INDEX )
new_codes << FunctionReturn.new( Register.message_reg , Register.resolve_index(:message , :return_address) )
block.replace(code , new_codes )
end
end

View File

@ -5,9 +5,9 @@ module Virtual
block.codes.dup.each do |code|
next unless code.is_a? Virtual::MethodEnter
new_codes = []
# save return register and create a new frame
# lr is link register, ie where arm stores the return address when call is issued
new_codes << Register::SaveReturn.new( Register::RegisterReference.message_reg , Virtual::RETURN_INDEX )
# save return register to the message at instance return_address
new_codes << Register.save_return(:message , :return_address)
# and create a new frame if needed
unless code.method.locals.empty? and code.method.tmps.empty?
new_codes << Virtual::NewFrame.new
end