From 553f30c8741080b30580a6fff1f796856ffa0c38 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 29 Jun 2015 20:58:06 +0300 Subject: [PATCH] more ripples from removing index constants --- lib/arm/passes/syscall_implementation.rb | 2 +- lib/register/passes/call_implementation.rb | 4 ++-- lib/register/passes/frame_implementation.rb | 8 ++++---- lib/register/passes/return_implementation.rb | 10 +++++----- lib/virtual/passes/enter_implementation.rb | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/arm/passes/syscall_implementation.rb b/lib/arm/passes/syscall_implementation.rb index 260a143a..28883523 100644 --- a/lib/arm/passes/syscall_implementation.rb +++ b/lib/arm/passes/syscall_implementation.rb @@ -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 diff --git a/lib/register/passes/call_implementation.rb b/lib/register/passes/call_implementation.rb index a265bd4f..1ad73646 100644 --- a/lib/register/passes/call_implementation.rb +++ b/lib/register/passes/call_implementation.rb @@ -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 ) diff --git a/lib/register/passes/frame_implementation.rb b/lib/register/passes/frame_implementation.rb index 35501199..604ad553 100644 --- a/lib/register/passes/frame_implementation.rb +++ b/lib/register/passes/frame_implementation.rb @@ -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 ) diff --git a/lib/register/passes/return_implementation.rb b/lib/register/passes/return_implementation.rb index eaf1ac24..2fba2cd4 100644 --- a/lib/register/passes/return_implementation.rb +++ b/lib/register/passes/return_implementation.rb @@ -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 diff --git a/lib/virtual/passes/enter_implementation.rb b/lib/virtual/passes/enter_implementation.rb index 2420d9ae..d5529675 100644 --- a/lib/virtual/passes/enter_implementation.rb +++ b/lib/virtual/passes/enter_implementation.rb @@ -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