From 1132309f6af5ea2d353187150c26e959c72d97c1 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 2 Jul 2018 15:49:51 +0300 Subject: [PATCH] unify space collection attribute naming currently space is still acting as a sort of memory manager. For proper linking, all objects must be reachable from space, hence the plural versions like messages and addresses (even they are instances, it is the list that is important) To dish out instance to use, the head must be kept, ie next_XXX for intergers, return addresses and messages --- lib/mom/instruction/message_setup.rb | 4 ++-- lib/parfait/space.rb | 25 ++++++++++++++----------- lib/risc/builtin/object.rb | 4 ++-- lib/risc/parfait_boot.rb | 7 ++++--- stash/parfait/test_type.rb | 2 +- test/parfait/test_attributes.rb | 2 +- test/parfait/test_message.rb | 2 +- test/parfait/test_named_list.rb | 2 +- test/parfait/test_space.rb | 8 ++++---- test/parfait/type/test_basic.rb | 2 +- test/parfait/type/test_message.rb | 2 +- test/risc/test_builder.rb | 4 ++-- test/risc/test_risc_value.rb | 8 ++++---- 13 files changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/mom/instruction/message_setup.rb b/lib/mom/instruction/message_setup.rb index ba9c36f6..5214ae64 100644 --- a/lib/mom/instruction/message_setup.rb +++ b/lib/mom/instruction/message_setup.rb @@ -60,7 +60,7 @@ module Mom def build_message_data( builder ) builder.build do space << Parfait.object_space - next_message << space[:first_message] + next_message << space[:next_message] message[:next_message] << next_message next_message[:caller] << message @@ -79,7 +79,7 @@ module Mom #FIXME in a multithreaded future this should be done soon after getting # the first_message, using lock free compare and swap. Now saving regs next_message << next_message[:next_message] - space[:first_message] << next_message + space[:next_message] << next_message end end end diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index a62235f9..80d2096c 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -34,24 +34,27 @@ module Parfait def initialize( classes ) @classes = classes @types = Dictionary.new - message = Message.new(nil) - 101.times { @next_integer = Integer.new(0,@next_integer) } - 10.times { @next_address = ReturnAddress.new(0,@next_address) } - - 50.times do - @first_message = Message.new message - message.set_caller @first_message - message = @first_message - end @classes.each do |name , cl| add_type(cl.instance_type) end + 101.times { @integers = Integer.new(0,@integers) } + 10.times { @addresses = ReturnAddress.new(0,@addresses) } + message = Message.new(nil) + 50.times do + @messages = Message.new message + message.set_caller @messages + message = @messages + end + @next_message = @messages + @next_integer = @integers + @next_address = @addresses @true_object = Parfait::TrueClass.new @false_object = Parfait::FalseClass.new @nil_object = Parfait::NilClass.new end - attr_reader :classes , :types , :first_message , :next_integer , :next_address + attr_reader :classes , :types , :next_message , :next_integer , :next_address + attr_reader :messages, :integers , :addresses attr_reader :true_object , :false_object , :nil_object # hand out one of the preallocated ints for use as constant @@ -68,7 +71,7 @@ module Parfait def get_address 10.times do # 10 for whole pages @next_address = ReturnAddress.new(0,@next_address) - end unless @next_address + end unless @next_address.next_integer addr = @next_address @next_address = @next_address.next_integer addr diff --git a/lib/risc/builtin/object.rb b/lib/risc/builtin/object.rb index c2672455..e10f5679 100644 --- a/lib/risc/builtin/object.rb +++ b/lib/risc/builtin/object.rb @@ -51,9 +51,9 @@ module Risc builder = compiler.compiler_builder(compiler.method) builder.build do space << Parfait.object_space - message << space[:first_message] + message << space[:next_message] next_message << message[:next_message] - space[:first_message] << next_message + space[:next_message] << next_message end Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder ) diff --git a/lib/risc/parfait_boot.rb b/lib/risc/parfait_boot.rb index a5586471..2140deba 100644 --- a/lib/risc/parfait_boot.rb +++ b/lib/risc/parfait_boot.rb @@ -141,9 +141,10 @@ module Parfait Object: {}, BinaryCode: {next: :BinaryCode} , Space: {classes: :Dictionary , types: :Dictionary , - first_message: :Message , next_integer: :Integer , - true_object: :TrueClass, next_address: :ReturnAddress , - false_object: :FalseClass , nil_object: :NilClass}, + next_message: :Message , messages: :Message , + next_integer: :Integer, integers: :Integer , + next_address: :ReturnAddress ,addresses: :ReturnAddress , + true_object: :TrueClass, false_object: :FalseClass , nil_object: :NilClass}, NamedList: {}, Type: {names: :List , types: :List , object_class: :Class, methods: :TypedMethod } , diff --git a/stash/parfait/test_type.rb b/stash/parfait/test_type.rb index 499a8c52..b068f8c6 100644 --- a/stash/parfait/test_type.rb +++ b/stash/parfait/test_type.rb @@ -45,7 +45,7 @@ HERE # copy of register parfait tests, in order def test_message_type @main = <