change to_risc and builtin code according to last commit
Wherever space was loaded to get to the next_message we now load the Message factory. Otherwise much the same, only the attribute is next_object, not next_message The binary is growing with 1k objects per factory, so i had to fix (hack) arm to handle bigger constants close #14
This commit is contained in:
parent
d964e9ea9d
commit
f798173a09
@ -63,12 +63,12 @@ module Mom
|
|||||||
# set the method into the message
|
# set the method into the message
|
||||||
def build_message_data( builder )
|
def build_message_data( builder )
|
||||||
builder.build do
|
builder.build do
|
||||||
space? << Parfait.object_space
|
factory? << Parfait.object_space.get_factory_for(:Message)
|
||||||
next_message? << space[:next_message]
|
next_message? << factory[:next_object]
|
||||||
|
|
||||||
#FIXME in a multithreaded future this should be done using lock free compare and swap.
|
#FIXME in a multithreaded future this should be done using lock free compare and swap.
|
||||||
next_message_reg! << next_message[:next_message]
|
next_message_reg! << next_message[:next_message]
|
||||||
space[:next_message] << next_message_reg
|
factory[:next_object] << next_message_reg
|
||||||
|
|
||||||
message[:next_message] << next_message
|
message[:next_message] << next_message
|
||||||
next_message[:caller] << message
|
next_message[:caller] << message
|
||||||
|
@ -26,10 +26,10 @@ module Mom
|
|||||||
object! << message[:return_value]
|
object! << message[:return_value]
|
||||||
caller_reg! << message[:caller]
|
caller_reg! << message[:caller]
|
||||||
caller_reg[:return_value] << object
|
caller_reg[:return_value] << object
|
||||||
space! << Parfait.object_space
|
factory? << Parfait.object_space.get_factory_for(:Message)
|
||||||
next_message! << space[:next_message]
|
next_message! << factory[:next_object]
|
||||||
message[:next_message] << next_message
|
message[:next_message] << next_message
|
||||||
space[:next_message] << message
|
factory[:next_object] << message
|
||||||
end
|
end
|
||||||
compiler.reset_regs
|
compiler.reset_regs
|
||||||
builder.build do
|
builder.build do
|
||||||
|
@ -56,16 +56,17 @@ module Risc
|
|||||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||||
builder = compiler.builder(compiler.source)
|
builder = compiler.builder(compiler.source)
|
||||||
builder.build do
|
builder.build do
|
||||||
space! << Parfait.object_space
|
factory! << Parfait.object_space.get_factory_for(:Message)
|
||||||
message << space[:next_message]
|
message << factory[:next_object]
|
||||||
next_message! << message[:next_message]
|
next_message! << message[:next_message]
|
||||||
space[:next_message] << next_message
|
factory[:next_object] << 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 )
|
||||||
|
|
||||||
builder.build do
|
builder.build do
|
||||||
message << message[:next_message]
|
message << message[:next_message]
|
||||||
|
space? << Parfait.object_space
|
||||||
message[:receiver] << space
|
message[:receiver] << space
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_load_space
|
def test_load_space
|
||||||
space = @produced.next(1)
|
space = @produced.next(1)
|
||||||
assert_load( space , Parfait::Space , :r2 )
|
assert_load( space , Parfait::Factory , :r2 )
|
||||||
end
|
end
|
||||||
def test_load_first_message #from space (ie r2)
|
def test_load_first_message #from space (ie r2)
|
||||||
sl = @produced.next( 2 )
|
sl = @produced.next( 2 )
|
||||||
assert_slot_to_reg( sl , :r2 , 4 , :r3 )
|
assert_slot_to_reg( sl , :r2 , 2 , :r3 )
|
||||||
end
|
end
|
||||||
def test_get_next_next #reduce onto itself
|
def test_get_next_next #reduce onto itself
|
||||||
sl = @produced.next( 3 )
|
sl = @produced.next( 3 )
|
||||||
@ -36,7 +36,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_store_next_next_in_space
|
def test_store_next_next_in_space
|
||||||
sl = @produced.next( 4 )
|
sl = @produced.next( 4 )
|
||||||
assert_reg_to_slot( sl , :r4 , :r2 , 4 )
|
assert_reg_to_slot( sl , :r4 , :r2 , 2 )
|
||||||
end
|
end
|
||||||
def test_store_message_in_current
|
def test_store_message_in_current
|
||||||
sl = @produced.next( 5 )
|
sl = @produced.next( 5 )
|
||||||
|
@ -33,16 +33,16 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_load_space
|
def test_load_space
|
||||||
assert_load( instruction(4) , Parfait::Space )
|
assert_load( instruction(4) , Parfait::Factory )
|
||||||
end
|
end
|
||||||
def test_get_next
|
def test_get_next
|
||||||
assert_slot_to_reg( instruction( 5 ) , :r3 , 4 , :r4 )
|
assert_slot_to_reg( instruction( 5 ) , :r3 , 2 , :r4 )
|
||||||
end
|
end
|
||||||
def test_save_next
|
def test_save_next
|
||||||
assert_reg_to_slot( instruction( 6 ) , :r4 , :r0 , 1 )
|
assert_reg_to_slot( instruction( 6 ) , :r4 , :r0 , 1 )
|
||||||
end
|
end
|
||||||
def test_save_this
|
def test_save_this
|
||||||
assert_reg_to_slot( instruction( 7 ) , :r0 , :r3 , 4 )
|
assert_reg_to_slot( instruction( 7 ) , :r0 , :r3 , 2 )
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_save_addr
|
def test_save_addr
|
||||||
|
@ -45,7 +45,7 @@ module Risc
|
|||||||
ret = main_ticks(64)
|
ret = main_ticks(64)
|
||||||
assert_equal FunctionReturn , ret.class
|
assert_equal FunctionReturn , ret.class
|
||||||
assert_equal :r1 , ret.register.symbol
|
assert_equal :r1 , ret.register.symbol
|
||||||
assert_equal 50632 , @interpreter.get_register(ret.register)
|
assert_equal 175276 , @interpreter.get_register(ret.register)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ module Risc
|
|||||||
@instruction_events << was
|
@instruction_events << was
|
||||||
end
|
end
|
||||||
def length
|
def length
|
||||||
38
|
39
|
||||||
end
|
end
|
||||||
def test_state_change
|
def test_state_change
|
||||||
@interpreter.register_event :state_changed , self
|
@interpreter.register_event :state_changed , self
|
||||||
@ -40,13 +40,13 @@ module Risc
|
|||||||
def test_chain
|
def test_chain
|
||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||||
LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, # 10
|
||||||
RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
|
RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
|
||||||
RegToSlot, LoadConstant, RegToSlot, FunctionCall, LoadConstant,
|
LoadConstant, RegToSlot, LoadConstant, RegToSlot, FunctionCall, # 20
|
||||||
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot,
|
LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg,
|
||||||
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 30
|
||||||
SlotToReg, SlotToReg, Branch, FunctionReturn, Transfer,
|
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
|
||||||
SlotToReg, SlotToReg, Syscall, NilClass]
|
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ]
|
||||||
assert_equal Fixnum , get_return.class
|
assert_equal Fixnum , get_return.class
|
||||||
assert_equal 5 , get_return
|
assert_equal 5 , get_return
|
||||||
end
|
end
|
||||||
|
@ -12,9 +12,9 @@ module Risc
|
|||||||
def test_chain
|
def test_chain
|
||||||
#show_main_ticks # get output of what is
|
#show_main_ticks # get output of what is
|
||||||
check_main_chain [LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg,
|
check_main_chain [LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg,
|
||||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 10
|
||||||
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
|
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
|
||||||
Transfer, SlotToReg, SlotToReg, Syscall, NilClass]
|
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] # 20
|
||||||
assert_equal 5 , get_return
|
assert_equal 5 , get_return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_returns_slot
|
def test_returns_slot
|
||||||
r2 = RegisterValue.new(:r2 , :Message).set_builder( @builder )
|
r2 = RegisterValue.new(:r2 , :Message).set_builder( @builder )
|
||||||
@builder.build{ r2 << space![:next_message] }
|
@builder.build{ r2 << factory![:next_object] }
|
||||||
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).set_builder( @builder )
|
r2 = RegisterValue.new(:r2 , :Message).set_builder( @builder )
|
||||||
@builder.build{ r2 << space![:next_message] }
|
@builder.build{ r2 << factory![:next_object] }
|
||||||
assert_equal SlotToReg , built.class
|
assert_equal SlotToReg , built.class
|
||||||
assert_equal :r1 , built.array.symbol
|
assert_equal :r1 , built.array.symbol
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_pc1
|
def test_pc1
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 49992 , @interpreter.pc
|
assert_equal 174632 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick2
|
def test_tick2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@ -68,7 +68,7 @@ module Risc
|
|||||||
def test_pc2
|
def test_pc2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 49996 , @interpreter.pc
|
assert_equal 174636 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick_14_jump
|
def test_tick_14_jump
|
||||||
14.times {@interpreter.tick}
|
14.times {@interpreter.tick}
|
||||||
|
@ -25,7 +25,7 @@ module Risc
|
|||||||
assert_equal 0 , Position.get(@linker.cpu_init).at
|
assert_equal 0 , Position.get(@linker.cpu_init).at
|
||||||
end
|
end
|
||||||
def test_cpu_at
|
def test_cpu_at
|
||||||
assert_equal "0xd1fc" , Position.get(@linker.cpu_init.first).to_s
|
assert_equal "0x2b91c" , Position.get(@linker.cpu_init.first).to_s
|
||||||
end
|
end
|
||||||
def test_cpu_label
|
def test_cpu_label
|
||||||
assert_equal Position , Position.get(@linker.cpu_init.first).class
|
assert_equal Position , Position.get(@linker.cpu_init.first).class
|
||||||
|
@ -13,6 +13,7 @@ module Risc
|
|||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
@r0 = RegisterValue.new(:r0 , :Message)
|
@r0 = RegisterValue.new(:r0 , :Message)
|
||||||
@r1 = RegisterValue.new(:r1 , :Space)
|
@r1 = RegisterValue.new(:r1 , :Space)
|
||||||
|
@r2 = RegisterValue.new(:r1 , :Factory)
|
||||||
end
|
end
|
||||||
def test_class_name_type
|
def test_class_name_type
|
||||||
assert_equal :Message , @r0.class_name
|
assert_equal :Message , @r0.class_name
|
||||||
@ -77,11 +78,11 @@ module Risc
|
|||||||
assert_equal 1 , instr.index
|
assert_equal 1 , instr.index
|
||||||
end
|
end
|
||||||
def test_slot_to_reg
|
def test_slot_to_reg
|
||||||
instr = @r0 << @r1[:next_message]
|
instr = @r0 << @r2[:next_object]
|
||||||
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 4 , instr.index
|
assert_equal 2 , instr.index
|
||||||
end
|
end
|
||||||
def test_reg_to_byte
|
def test_reg_to_byte
|
||||||
instr = @r1[1] <= @r0
|
instr = @r1[1] <= @r0
|
||||||
@ -91,11 +92,11 @@ module Risc
|
|||||||
assert_equal 1 , instr.index
|
assert_equal 1 , instr.index
|
||||||
end
|
end
|
||||||
def test_reg_to_slot
|
def test_reg_to_slot
|
||||||
instr = @r1[:next_message] << @r0
|
instr = @r2[:next_object] << @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
|
||||||
assert_equal 4 , instr.index
|
assert_equal 2 , instr.index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ module Risc
|
|||||||
# how many instruction up until the main starts, ie
|
# how many instruction up until the main starts, ie
|
||||||
# ticks(main_at) will be the label for main
|
# ticks(main_at) will be the label for main
|
||||||
def main_at
|
def main_at
|
||||||
19
|
20
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_return
|
def get_return
|
||||||
|
Loading…
Reference in New Issue
Block a user