last instruciton, dynamic_call

next macros
This commit is contained in:
Torsten 2020-03-03 16:44:21 +02:00
parent 7f5ebab800
commit 2af953e1d2
2 changed files with 18 additions and 19 deletions

View File

@ -20,7 +20,7 @@ module SlotMachine
def to_s
str = "DynamicCall "
str += cache_entry.cached_method&.name if cache_entry
str += cache_entry.cached_method&.name if cache_entry and cache_entry.cached_method
str
end
@ -31,17 +31,15 @@ module SlotMachine
# Instead we need a DynamicJump instruction that explicitly takes a register as
# a target (not a label)
def to_risc(compiler)
entry = @cache_entry
compiler.add_constant( entry )
entry = compiler.load_object(@cache_entry)[:cached_method].to_reg
compiler.add_constant( @cache_entry)
return_label = Risc.label(self, "continue_#{object_id}")
compiler.build("DynamicCall") do
return_address! << return_label
next_message! << message[:next_message]
next_message[:return_address] << return_address
return_address = compiler.load_object(return_label)
compiler.build(to_s) do
message[:next_message][:return_address] << return_address
message << message[:next_message]
cache_entry! << entry
cache_entry << cache_entry[:cached_method]
add_code Risc::DynamicJump.new("DynamicCall", cache_entry )
add_code Risc::DynamicJump.new("DynamicCall", entry )
add_code return_label
end
end

View File

@ -9,26 +9,27 @@ module SlotMachine
assert_equal 9 , all.length , all_str
end
def test_1_load
assert_load risc(1) , Risc::Label , :r1
assert_label risc(1).constant , "continue_"
assert_load risc(1) , Parfait::CacheEntry , "id_"
end
def test_2_slot
assert_slot_to_reg risc(2) ,:r0 , 1 , :r2
assert_slot_to_reg risc(2) , "id_" , 2 , "id_.cached_method"
end
def test_3_reg
assert_reg_to_slot risc(3) , :r1 , :r2 , 4
def test_3_load
assert_load risc(3) , Risc::Label , "id_"
assert_label risc(3).constant , "continue_"
end
def test_4_slot
assert_slot_to_reg risc(4) ,:r0 , 1 , :r0
assert_slot_to_reg risc(4) , :message , 1 , "message.next_message"
end
def test_5_load
assert_load risc(5) , Parfait::CacheEntry , :r3
def test_5_reg
assert_reg_to_slot risc(5) , "id_" , "message.next_message" , 4
end
def test_6_slot
assert_slot_to_reg risc(6) ,:r3 , 2 , :r3
assert_slot_to_reg risc(6) , :message , 1 , :message
end
def test_7_jump
assert_equal Risc::DynamicJump , risc(7).class
assert_register :jump , "id_.cached_method" , risc(7).register
end
def test_8_label
assert_label risc(8) , "continue_"