From 99b59d920cfdae389231b646a99071696a6c65c2 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 28 Jun 2015 10:52:02 +0300 Subject: [PATCH] constant fixes --- lib/arm/passes/save_implementation.rb | 2 +- lib/register/passes/frame_implementation.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/arm/passes/save_implementation.rb b/lib/arm/passes/save_implementation.rb index 5416436e..f9799343 100644 --- a/lib/arm/passes/save_implementation.rb +++ b/lib/arm/passes/save_implementation.rb @@ -10,7 +10,7 @@ module Arm def run block block.codes.dup.each do |code| next unless code.is_a? Register::SaveReturn - store = ArmMachine.str( :lr , code.register , code.index ) + store = ArmMachine.str( :lr , code.register , 4 * code.index ) block.replace(code , store ) end end diff --git a/lib/register/passes/frame_implementation.rb b/lib/register/passes/frame_implementation.rb index 9fcfd06f..58c42f58 100644 --- a/lib/register/passes/frame_implementation.rb +++ b/lib/register/passes/frame_implementation.rb @@ -31,19 +31,17 @@ module Register end # a place to store a reference to the space, we grab the next_frame from the space space_tmp = RegisterReference.tmp_reg - # a temporary place to store the new frame - frame_tmp = space_tmp.next_reg_use # 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 ind = Parfait::Space.object_space.get_layout().index_of( kind ) raise "index not found for #{kind}.#{kind.class}" unless ind # load the frame/message from space by index - new_codes << GetSlot.new( space_tmp , 5 , frame_tmp ) - # save the frame in real frame register - new_codes << RegisterTransfer.new( frame_tmp , RegisterReference.frame_reg ) + new_codes << GetSlot.new( space_tmp , ind , RegisterReference.frame_reg ) + # a temporary place to store the new frame + frame_tmp = space_tmp.next_reg_use # get the next_frame - new_codes << GetSlot.new( frame_tmp , 2 , frame_tmp) # 2 index of next_frame + new_codes << GetSlot.new( RegisterReference.frame_reg , 2 , frame_tmp) # 2 index of next_frame # save next frame into space new_codes << SetSlot.new( frame_tmp , space_tmp , ind) block.replace(code , new_codes )