From 69781fb5059b02c448f49142fb2acd71105a1f1a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 2 Jul 2015 13:48:32 +0300 Subject: [PATCH] remoe sys call message and rely on linux to restore all registers save message in r8 --- lib/parfait/space.rb | 1 - lib/register/builtin/kernel.rb | 21 +++++++-------------- lib/virtual/boot.rb | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index 0d000a26..8cef3e77 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -25,7 +25,6 @@ module Parfait super() Parfait::Space.set_object_space self @classes = Parfait::Dictionary.new_object - @syscall_message = nil # a hack sto store the message during syscall end attr_reader :classes , :first_message diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index 266ca991..a64362db 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -43,28 +43,21 @@ module Register function.info.add_code Syscall.new( name ) restore_message(function) end + # save the current message, as the syscall destroys all context # - # currently HACKED into the space as a temporary varaible. As the space is a globally - # unique object we can retrieve it from there - # TODO : fix this to use global (later per thread) variable + # This relies on linux to save and restore all registers + # def save_message(function) - space_tmp = Register.tmp_reg - 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) + function.info.add_code RegisterTransfer.new( Register.message_reg , :r8 ) end def restore_message(function) - # get the sys return out of the way return_tmp = Register.tmp_reg + # get the sys return out of the way function.info.add_code RegisterTransfer.new( Register.message_reg , return_tmp ) - # load the space into the base register - function.info.add_code LoadConstant.new(Parfait::Space.object_space ,Register.message_reg) - # find the stored message - ind = Register.resolve_index( :space , :syscall_message ) - # and load it into the base RegisterMachine - function.info.add_code Register.get_slot :message , ind , :message + # load the stored message into the base RegisterMachine + function.info.add_code RegisterTransfer.new( :r8 , Register.message_reg ) # save the return value into the message function.info.add_code Register.set_slot( return_tmp , :message , :return_value ) # and "unroll" self and frame diff --git a/lib/virtual/boot.rb b/lib/virtual/boot.rb index 4a04a894..2c7c775b 100644 --- a/lib/virtual/boot.rb +++ b/lib/virtual/boot.rb @@ -30,7 +30,7 @@ module Virtual :caller , :name ], :MetaClass => [], :BinaryCode => [], - :Space => [:classes , :first_message , :syscall_message], + :Space => [:classes , :first_message ], :Frame => [:next_frame ], :Layout => [:object_class] , :Class => [:object_layout ],