fixing all the indexes
with the type word and layout but the list starting at 1, indexes still need 1 added and for arm x 4. Tried to get all that into one function, resolve_index
This commit is contained in:
parent
88f45cbf15
commit
9541712af8
@ -5,8 +5,7 @@ module Arm
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Register::GetSlot
|
||||
# times 4 because arm works in bytes, but vm in words
|
||||
# + 1 because of the type word
|
||||
load = ArmMachine.ldr( code.register , code.array , 4 * (code.index + 1) )
|
||||
load = ArmMachine.ldr( code.register , code.array , 4 * code.index )
|
||||
block.replace(code , load )
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Arm
|
||||
next unless code.is_a? Register::SetSlot
|
||||
# times 4 because arm works in bytes, but vm in words
|
||||
# + 1 because of the type word
|
||||
store = ArmMachine.str( code.register , code.array , 4 * (code.index + 1) )
|
||||
store = ArmMachine.str( code.register , code.array , 4 * code.index )
|
||||
block.replace(code , store )
|
||||
end
|
||||
end
|
||||
|
@ -56,21 +56,23 @@ module Register
|
||||
# TODO : fix this to use global (later per thread) variable
|
||||
def save_message(function)
|
||||
space_tmp = Register.tmp_reg
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for :syscall_message" unless ind
|
||||
ind = Register.resolve_index( :space , :syscall_message )
|
||||
function.info.add_code LoadConstant.new( Parfait::Space.object_space , space_tmp)
|
||||
function.info.add_code SetSlot.new( Register.message_reg , space_tmp , ind)
|
||||
end
|
||||
|
||||
def restore_message(function)
|
||||
# get the sys return out of the way
|
||||
return_tmp = Register.tmp_reg
|
||||
function.info.add_code RegisterTransfer.new( Register.message_reg , return_tmp )
|
||||
# load the space into the base register
|
||||
function.info.add_code RegisterTransfer.new( return_tmp , Register.message_reg )
|
||||
function.info.add_code LoadConstant.new(Parfait::Space.object_space ,Register.message_reg)
|
||||
# find the stored message
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for #{kind}.#{kind.class}" unless ind
|
||||
ind = Register.resolve_index( :space , :syscall_message )
|
||||
# and load it into the base RegisterMachine
|
||||
function.info.add_code Register.get_slot :message , ind , :message
|
||||
# save the return value into the message
|
||||
function.info.add_code Register.set_slot( return_tmp , :message , :return_value )
|
||||
# and "unroll" self and frame
|
||||
function.info.add_code Register.get_slot(:message , :receiver, :self )
|
||||
function.info.add_code Register.get_slot(:message , :frame , :frame)
|
||||
|
@ -42,9 +42,9 @@ module Register
|
||||
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 )
|
||||
kind_index = from.get_layout().index_of( kind ) + 1 # should be resolve_index to hide the +1
|
||||
raise "index not found for #{kind}.#{kind.class}" unless kind_index
|
||||
new_codes << GetSlot.new( Register.frame_reg , kind_index , frame_tmp) # 2 index of next_frame
|
||||
new_codes << GetSlot.new( Register.frame_reg , kind_index , frame_tmp)
|
||||
# save next frame into space
|
||||
new_codes << SetSlot.new( frame_tmp , space_tmp , space_index)
|
||||
block.replace(code , new_codes )
|
||||
|
@ -28,7 +28,7 @@ module Register
|
||||
return Register.resolve_index( :message , :name)
|
||||
when Virtual::NewArgSlot
|
||||
puts "from: #{from.index}"
|
||||
return Register.resolve_index( :message , :name) + 1 + from.index
|
||||
return Register.resolve_index( :message , :name) + from.index
|
||||
else
|
||||
raise "not implemented for #{from.class}"
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ module Register
|
||||
raise "Class name not given #{real_name}" unless clazz
|
||||
index = clazz.object_layout.index_of( instance_name )
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}" unless index.is_a?(Numeric)
|
||||
return index
|
||||
return index + 1 # one for the type word that is at index 0
|
||||
end
|
||||
|
||||
# if a symbol is given, it may be one of the four objects that the vm knows.
|
||||
|
@ -44,6 +44,7 @@ module Virtual
|
||||
rescue
|
||||
raise "No method found #{code.name} for #{clazz.name} in #{clazz.method_names}" unless method
|
||||
end
|
||||
#puts "CALL is #{method.name}"
|
||||
new_codes << MethodCall.new( method )
|
||||
else
|
||||
# must defer send to run-time
|
||||
|
Loading…
Reference in New Issue
Block a user