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
This commit is contained in:
parent
07a154be70
commit
1132309f6a
@ -60,7 +60,7 @@ module Mom
|
|||||||
def build_message_data( builder )
|
def build_message_data( builder )
|
||||||
builder.build do
|
builder.build do
|
||||||
space << Parfait.object_space
|
space << Parfait.object_space
|
||||||
next_message << space[:first_message]
|
next_message << space[:next_message]
|
||||||
message[:next_message] << next_message
|
message[:next_message] << next_message
|
||||||
next_message[:caller] << message
|
next_message[:caller] << message
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ module Mom
|
|||||||
#FIXME in a multithreaded future this should be done soon after getting
|
#FIXME in a multithreaded future this should be done soon after getting
|
||||||
# the first_message, using lock free compare and swap. Now saving regs
|
# the first_message, using lock free compare and swap. Now saving regs
|
||||||
next_message << next_message[:next_message]
|
next_message << next_message[:next_message]
|
||||||
space[:first_message] << next_message
|
space[:next_message] << next_message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,24 +34,27 @@ module Parfait
|
|||||||
def initialize( classes )
|
def initialize( classes )
|
||||||
@classes = classes
|
@classes = classes
|
||||||
@types = Dictionary.new
|
@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|
|
@classes.each do |name , cl|
|
||||||
add_type(cl.instance_type)
|
add_type(cl.instance_type)
|
||||||
end
|
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
|
@true_object = Parfait::TrueClass.new
|
||||||
@false_object = Parfait::FalseClass.new
|
@false_object = Parfait::FalseClass.new
|
||||||
@nil_object = Parfait::NilClass.new
|
@nil_object = Parfait::NilClass.new
|
||||||
end
|
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
|
attr_reader :true_object , :false_object , :nil_object
|
||||||
|
|
||||||
# hand out one of the preallocated ints for use as constant
|
# hand out one of the preallocated ints for use as constant
|
||||||
@ -68,7 +71,7 @@ module Parfait
|
|||||||
def get_address
|
def get_address
|
||||||
10.times do # 10 for whole pages
|
10.times do # 10 for whole pages
|
||||||
@next_address = ReturnAddress.new(0,@next_address)
|
@next_address = ReturnAddress.new(0,@next_address)
|
||||||
end unless @next_address
|
end unless @next_address.next_integer
|
||||||
addr = @next_address
|
addr = @next_address
|
||||||
@next_address = @next_address.next_integer
|
@next_address = @next_address.next_integer
|
||||||
addr
|
addr
|
||||||
|
@ -51,9 +51,9 @@ module Risc
|
|||||||
builder = compiler.compiler_builder(compiler.method)
|
builder = compiler.compiler_builder(compiler.method)
|
||||||
builder.build do
|
builder.build do
|
||||||
space << Parfait.object_space
|
space << Parfait.object_space
|
||||||
message << space[:first_message]
|
message << space[:next_message]
|
||||||
next_message << message[:next_message]
|
next_message << message[:next_message]
|
||||||
space[:first_message] << next_message
|
space[:next_message] << next_message
|
||||||
end
|
end
|
||||||
|
|
||||||
Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
|
Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
|
||||||
|
@ -141,9 +141,10 @@ module Parfait
|
|||||||
Object: {},
|
Object: {},
|
||||||
BinaryCode: {next: :BinaryCode} ,
|
BinaryCode: {next: :BinaryCode} ,
|
||||||
Space: {classes: :Dictionary , types: :Dictionary ,
|
Space: {classes: :Dictionary , types: :Dictionary ,
|
||||||
first_message: :Message , next_integer: :Integer ,
|
next_message: :Message , messages: :Message ,
|
||||||
true_object: :TrueClass, next_address: :ReturnAddress ,
|
next_integer: :Integer, integers: :Integer ,
|
||||||
false_object: :FalseClass , nil_object: :NilClass},
|
next_address: :ReturnAddress ,addresses: :ReturnAddress ,
|
||||||
|
true_object: :TrueClass, false_object: :FalseClass , nil_object: :NilClass},
|
||||||
NamedList: {},
|
NamedList: {},
|
||||||
Type: {names: :List , types: :List ,
|
Type: {names: :List , types: :List ,
|
||||||
object_class: :Class, methods: :TypedMethod } ,
|
object_class: :Class, methods: :TypedMethod } ,
|
||||||
|
@ -45,7 +45,7 @@ HERE
|
|||||||
# copy of register parfait tests, in order
|
# copy of register parfait tests, in order
|
||||||
def test_message_type
|
def test_message_type
|
||||||
@main = <<HERE
|
@main = <<HERE
|
||||||
Message m = self.first_message
|
Message m = self.next_message
|
||||||
m = m.next_message
|
m = m.next_message
|
||||||
Word w = m.get_class_name()
|
Word w = m.get_class_name()
|
||||||
w.putstring()
|
w.putstring()
|
||||||
|
@ -5,7 +5,7 @@ module Parfait
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@mess = @space.first_message
|
@mess = @space.next_message
|
||||||
@type = @mess.get_type
|
@type = @mess.get_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module Parfait
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@mess = @space.first_message
|
@mess = @space.next_message
|
||||||
end
|
end
|
||||||
def test_length
|
def test_length
|
||||||
assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect
|
assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect
|
||||||
|
@ -5,7 +5,7 @@ module Parfait
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@named_list = @space.first_message.frame
|
@named_list = @space.next_message.frame
|
||||||
@type = @named_list.get_type
|
@type = @named_list.get_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_space_length
|
def test_space_length
|
||||||
assert_equal 9 , @space.get_type.instance_length , @space.get_type.inspect
|
assert_equal 12 , @space.get_type.instance_length , @space.get_type.inspect
|
||||||
end
|
end
|
||||||
def test_singletons
|
def test_singletons
|
||||||
assert @space.true_object , "No truth"
|
assert @space.true_object , "No truth"
|
||||||
@ -98,7 +98,7 @@ module Parfait
|
|||||||
assert_equal Parfait::ReturnAddress , @space.next_address.next_integer.class
|
assert_equal Parfait::ReturnAddress , @space.next_address.next_integer.class
|
||||||
end
|
end
|
||||||
def test_address_count
|
def test_address_count
|
||||||
addr = @space.get_address
|
addr = @space.addresses
|
||||||
count = 0
|
count = 0
|
||||||
while(addr)
|
while(addr)
|
||||||
count += 1
|
count += 1
|
||||||
@ -108,7 +108,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_messages
|
def test_messages
|
||||||
mess = @space.first_message
|
mess = @space.messages
|
||||||
all = []
|
all = []
|
||||||
while mess
|
while mess
|
||||||
all << mess
|
all << mess
|
||||||
@ -120,7 +120,7 @@ module Parfait
|
|||||||
assert_equal 50 + 1 , all.length
|
assert_equal 50 + 1 , all.length
|
||||||
end
|
end
|
||||||
def test_message_vars
|
def test_message_vars
|
||||||
mess = @space.first_message
|
mess = @space.next_message
|
||||||
all = mess.get_instance_variables
|
all = mess.get_instance_variables
|
||||||
assert all
|
assert all
|
||||||
assert all.include?(:next_message)
|
assert all.include?(:next_message)
|
||||||
|
@ -5,7 +5,7 @@ module Parfait
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@mess = @space.first_message
|
@mess = @space.next_message
|
||||||
assert @mess
|
assert @mess
|
||||||
@type = @mess.get_type()
|
@type = @mess.get_type()
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ module Parfait
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@mess = @space.first_message
|
@mess = @space.next_message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_message_type
|
def test_message_type
|
||||||
|
@ -44,14 +44,14 @@ module Risc
|
|||||||
def test_returns_slot
|
def test_returns_slot
|
||||||
r2 = RegisterValue.new(:r2 , :Message)
|
r2 = RegisterValue.new(:r2 , :Message)
|
||||||
r2.builder = @builder
|
r2.builder = @builder
|
||||||
built = @builder.build{ r2 << space[:first_message] }
|
built = @builder.build{ r2 << space[:next_message] }
|
||||||
assert_equal SlotToReg , built.class
|
assert_equal SlotToReg , built.class
|
||||||
assert_equal :r1 , built.array.symbol
|
assert_equal :r1 , built.array.symbol
|
||||||
end
|
end
|
||||||
def test_returns_slot_reverse
|
def test_returns_slot_reverse
|
||||||
r2 = RegisterValue.new(:r2 , :Message)
|
r2 = RegisterValue.new(:r2 , :Message)
|
||||||
r2.builder = @builder
|
r2.builder = @builder
|
||||||
built = @builder.build{ r2 << space[:first_message] }
|
built = @builder.build{ r2 << space[:next_message] }
|
||||||
assert_equal SlotToReg , built.class
|
assert_equal SlotToReg , built.class
|
||||||
assert_equal :r1 , built.array.symbol
|
assert_equal :r1 , built.array.symbol
|
||||||
end
|
end
|
||||||
|
@ -36,20 +36,20 @@ module Risc
|
|||||||
assert_equal Transfer , builder.built.class
|
assert_equal Transfer , builder.built.class
|
||||||
end
|
end
|
||||||
def test_index_op
|
def test_index_op
|
||||||
message = @r0[:first_message]
|
message = @r0[:next_message]
|
||||||
assert_equal RValue , message.class
|
assert_equal RValue , message.class
|
||||||
assert_equal :first_message , message.index
|
assert_equal :next_message , message.index
|
||||||
assert_equal @r0 , message.register
|
assert_equal @r0 , message.register
|
||||||
end
|
end
|
||||||
def test_slot_to_reg
|
def test_slot_to_reg
|
||||||
instr = @r0 << @r1[:first_message]
|
instr = @r0 << @r1[:next_message]
|
||||||
assert_equal SlotToReg , instr.class
|
assert_equal SlotToReg , instr.class
|
||||||
assert_equal @r1 , instr.array
|
assert_equal @r1 , instr.array
|
||||||
assert_equal @r0 , instr.register
|
assert_equal @r0 , instr.register
|
||||||
assert_equal 3 , instr.index
|
assert_equal 3 , instr.index
|
||||||
end
|
end
|
||||||
def test_reg_to_slot
|
def test_reg_to_slot
|
||||||
instr = @r1[:first_message] << @r0
|
instr = @r1[:next_message] << @r0
|
||||||
assert_equal RegToSlot , instr.class
|
assert_equal RegToSlot , instr.class
|
||||||
assert_equal @r1 , instr.array
|
assert_equal @r1 , instr.array
|
||||||
assert_equal @r0 , instr.register
|
assert_equal @r0 , instr.register
|
||||||
|
Loading…
Reference in New Issue
Block a user