From ec1e8c8f3a912a62f5c1c9ca0d01a84a9e449add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Fri, 23 Aug 2019 10:20:39 +0300 Subject: [PATCH] Fix risc layer from cc changes --- lib/risc/parfait_boot.rb | 9 ++- .../interpreter/assign/test_assign_local.rb | 16 ++--- .../interpreter/blocks/test_assign_outer.rb | 48 +++++++-------- .../interpreter/blocks/test_block_return.rb | 12 ++-- test/risc/interpreter/calling/test_minus.rb | 2 +- test/risc/interpreter/test_dynamic_call.rb | 61 +++++++++---------- .../interpreter/while/test_while_simple.rb | 27 ++++---- test/risc/test_collector.rb | 4 +- test/risc/test_interpreter.rb | 4 +- test/risc/test_linker.rb | 2 +- 10 files changed, 92 insertions(+), 93 deletions(-) diff --git a/lib/risc/parfait_boot.rb b/lib/risc/parfait_boot.rb index 32d600f4..e538062f 100644 --- a/lib/risc/parfait_boot.rb +++ b/lib/risc/parfait_boot.rb @@ -162,8 +162,13 @@ module Parfait return_address: :Integer, return_value: :Object, caller: :Message , method: :TypedMethod , arguments_given: :Integer , - arg1: :Integer , arg2: :Integer, arg3: :Integer, - arg4: :Integer, arg5: :Integer, arg6: :Integer}, + arg1: :Object , arg2: :Object, arg3: :Object, + arg4: :Object, arg5: :Object, arg6: :Object, + locals_used: :Integer, + local1: :Object , local2: :Object, local3: :Object, local4: :Object, + local5: :Object, local6: :Object ,local7: :Object, local8: :Object , + local9: :Object ,local10: :Object, local11: :Object , local12: :Object, + local13: :Object, local14: :Object, local15: :Object}, MetaClass: {instance_methods: :List, instance_type: :Type, clazz: :Class }, NamedList: {}, NilClass: {}, diff --git a/test/risc/interpreter/assign/test_assign_local.rb b/test/risc/interpreter/assign/test_assign_local.rb index 17ed1e52..b2792e28 100644 --- a/test/risc/interpreter/assign/test_assign_local.rb +++ b/test/risc/interpreter/assign/test_assign_local.rb @@ -11,11 +11,11 @@ module Risc def test_chain #show_main_ticks # get output of what is - check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, - RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, # 10 - LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, - SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 20 - SlotToReg, Syscall, NilClass, ] + check_main_chain [LoadConstant, RegToSlot, SlotToReg, RegToSlot, Branch, + SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, # 10 + RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, + FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 20 + NilClass, ] assert_equal 15 , get_return end @@ -31,17 +31,17 @@ module Risc assert_equal 15 , @interpreter.get_register(load_ins.register).value end def test_return - ret = main_ticks(18) + ret = main_ticks(16) assert_equal FunctionReturn , ret.class link = @interpreter.get_register( ret.register ) assert_equal ::Integer , link.class end def test_transfer - transfer = main_ticks(19) + transfer = main_ticks(17) assert_equal Transfer , transfer.class end def test_sys - sys = main_ticks(22) + sys = main_ticks(20) assert_equal Syscall , sys.class end end diff --git a/test/risc/interpreter/blocks/test_assign_outer.rb b/test/risc/interpreter/blocks/test_assign_outer.rb index bea30601..3631910f 100644 --- a/test/risc/interpreter/blocks/test_assign_outer.rb +++ b/test/risc/interpreter/blocks/test_assign_outer.rb @@ -11,30 +11,29 @@ module Risc def test_chain #show_main_ticks # get output of what is - check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, - SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, # 10 - RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, - SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, # 20 - SlotToReg, FunctionCall, LoadConstant, SlotToReg, OperatorInstruction, - IsZero, SlotToReg, LoadConstant, SlotToReg, SlotToReg, # 30 - RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, - SlotToReg, RegToSlot, SlotToReg, LoadConstant, RegToSlot, # 40 - SlotToReg, SlotToReg, DynamicJump, LoadConstant, SlotToReg, - SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, # 50 - Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, - SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 60 - SlotToReg, FunctionReturn, SlotToReg, RegToSlot, Branch, - SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, # 70 - Branch, RegToSlot, RegToSlot, SlotToReg, SlotToReg, - SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, # 80 - Branch, SlotToReg, SlotToReg, RegToSlot, Branch, - LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, # 90 - SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, - SlotToReg, Syscall, NilClass, ] + check_main_chain [LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, + SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, # 10 + SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, + RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, # 20 + FunctionCall, LoadConstant, SlotToReg, OperatorInstruction, IsZero, + SlotToReg, LoadConstant, SlotToReg, SlotToReg, RegToSlot, # 30 + RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, + RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, # 40 + SlotToReg, DynamicJump, LoadConstant, SlotToReg, SlotToReg, + RegToSlot, LoadConstant, RegToSlot, Branch, SlotToReg, # 50 + SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, + RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, # 60 + SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, + RegToSlot, LoadConstant, SlotToReg, Branch, RegToSlot, # 70 + RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, + SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, # 80 + RegToSlot, LoadConstant, SlotToReg, Branch, RegToSlot, + RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, # 90 + Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] assert_equal 10 , get_return end - def base ; 43 ; end + def base ; 42 ; end def test_block_jump load_ins = main_ticks(base) assert_equal DynamicJump , load_ins.class @@ -51,14 +50,11 @@ module Risc def test_block_slot2 assert_slot_to_reg main_ticks(base+3) ,:r2 , 6 , :r2 end - def test_block_slot3 - assert_slot_to_reg main_ticks(base+4) ,:r2 , 3 , :r2 - end def test_block_reg - assert_reg_to_slot main_ticks(base+5) ,:r1 , :r2 , 1 + assert_reg_to_slot main_ticks(base+4) ,:r1 , :r2 , 16 end def test_ret_load - load_ins = main_ticks(base+6) + load_ins = main_ticks(base+5) assert_load load_ins , Parfait::Integer , :r1 assert_equal 15 , @interpreter.get_register(load_ins.register).value end diff --git a/test/risc/interpreter/blocks/test_block_return.rb b/test/risc/interpreter/blocks/test_block_return.rb index a7ab9fbb..ea63e79c 100644 --- a/test/risc/interpreter/blocks/test_block_return.rb +++ b/test/risc/interpreter/blocks/test_block_return.rb @@ -11,7 +11,7 @@ module Risc def test_chain #show_main_ticks # get output of what is - check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, + check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, # 20 @@ -25,11 +25,11 @@ module Risc RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, # 60 LoadConstant, SlotToReg, Branch, RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, # 70 - SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, - Branch, SlotToReg, SlotToReg, RegToSlot, Branch, # 80 - LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, - SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 90 - SlotToReg, Syscall, NilClass, ] + RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, + SlotToReg, RegToSlot, LoadConstant, SlotToReg, Branch, # 80 + RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, + FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 90 + NilClass, ] assert_equal 15 , get_return end diff --git a/test/risc/interpreter/calling/test_minus.rb b/test/risc/interpreter/calling/test_minus.rb index cca7df8d..9896f45f 100644 --- a/test/risc/interpreter/calling/test_minus.rb +++ b/test/risc/interpreter/calling/test_minus.rb @@ -39,7 +39,7 @@ module Risc ret = main_ticks(60) assert_equal FunctionReturn , ret.class assert_equal :r1 , ret.register.symbol - assert_equal 22816 , @interpreter.get_register(ret.register) + assert_equal 26160 , @interpreter.get_register(ret.register) end end end diff --git a/test/risc/interpreter/test_dynamic_call.rb b/test/risc/interpreter/test_dynamic_call.rb index 9ffcc2f2..ad924d75 100644 --- a/test/risc/interpreter/test_dynamic_call.rb +++ b/test/risc/interpreter/test_dynamic_call.rb @@ -11,33 +11,32 @@ module Risc def test_chain #show_main_ticks # get output of what is - check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, - SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero, # 10 - SlotToReg, SlotToReg, SlotToReg, LoadConstant, RegToSlot, - LoadConstant, LoadConstant, SlotToReg, SlotToReg, LoadConstant, # 20 - OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, IsZero, - SlotToReg, Branch, LoadConstant, OperatorInstruction, IsZero, # 30 - SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch, - LoadConstant, OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, # 40 - IsZero, SlotToReg, Branch, LoadConstant, OperatorInstruction, - IsZero, SlotToReg, OperatorInstruction, IsZero, SlotToReg, # 50 - Branch, LoadConstant, OperatorInstruction, IsZero, SlotToReg, - OperatorInstruction, IsZero, SlotToReg, Branch, LoadConstant, # 60 - OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, IsZero, - RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, # 70 - SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, - SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 80 - SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, - DynamicJump, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, # 90 - IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg, - LoadData, OperatorInstruction, Branch, RegToSlot, RegToSlot, # 100 - SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, - RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, # 110 - FunctionReturn, SlotToReg, RegToSlot, Branch, Branch, - SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, # 120 - RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, - FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 130 - NilClass, ] + check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, SlotToReg, + SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, # 10 + LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, + SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, # 20 + OperatorInstruction, IsZero, SlotToReg, Branch, LoadConstant, + OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, IsZero, # 30 + SlotToReg, Branch, LoadConstant, OperatorInstruction, IsZero, + SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch, # 40 + LoadConstant, OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, + IsZero, SlotToReg, Branch, LoadConstant, OperatorInstruction, # 50 + IsZero, SlotToReg, OperatorInstruction, IsZero, SlotToReg, + Branch, LoadConstant, OperatorInstruction, IsZero, SlotToReg, # 60 + OperatorInstruction, IsZero, RegToSlot, LoadConstant, SlotToReg, + LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, # 70 + RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, + LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, # 80 + SlotToReg, DynamicJump, LoadConstant, SlotToReg, LoadConstant, + OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, SlotToReg, # 90 + SlotToReg, LoadData, OperatorInstruction, Branch, RegToSlot, + RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 100 + SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, + SlotToReg, FunctionReturn, SlotToReg, RegToSlot, Branch, # 110 + SlotToReg, SlotToReg, RegToSlot, Branch, LoadConstant, + SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 120 + SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, + Syscall, NilClass, ] assert_equal ::Integer , get_return.class assert_equal 1 , get_return @@ -49,23 +48,23 @@ module Risc assert_equal :main , call_ins.method.name end def test_load_entry - call_ins = main_ticks(4) + call_ins = main_ticks(3) assert_equal LoadConstant , call_ins.class assert_equal Parfait::CacheEntry , call_ins.constant.class end def test_dyn - cal = main_ticks(86) + cal = main_ticks(82) assert_equal DynamicJump , cal.class end def test_return - ret = main_ticks(126) + ret = main_ticks(122) assert_equal FunctionReturn , ret.class link = @interpreter.get_register( ret.register ) assert_equal ::Integer , link.class end def test_sys - sys = main_ticks(130) + sys = main_ticks(126) assert_equal Syscall , sys.class end end diff --git a/test/risc/interpreter/while/test_while_simple.rb b/test/risc/interpreter/while/test_while_simple.rb index e0a2f95a..8f95f794 100644 --- a/test/risc/interpreter/while/test_while_simple.rb +++ b/test/risc/interpreter/while/test_while_simple.rb @@ -11,15 +11,13 @@ module Risc def test_while #show_main_ticks # get output of what is in main - check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, - LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, # 10 - IsZero, LoadConstant, SlotToReg, RegToSlot, Branch, - SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, # 20 - SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg, - SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, # 30 - RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch, - FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 40 - NilClass, ] + check_main_chain [LoadConstant, RegToSlot, SlotToReg, LoadConstant, OperatorInstruction, + IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, # 10 + RegToSlot, Branch, SlotToReg, LoadConstant, OperatorInstruction, + IsZero, SlotToReg, RegToSlot, Branch, SlotToReg, # 20 + SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, + RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, # 30 + Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] assert_kind_of Parfait::NilClass , get_return end def test_load_false_const @@ -28,7 +26,7 @@ module Risc assert_kind_of Parfait::TrueClass , load.constant end def base - 6 + 4 end def test_load_false load = main_ticks(base) @@ -45,6 +43,11 @@ module Risc assert_equal IsZero , check.class assert check.label.name.start_with?("merge_label") , check.label.name end + def test_load_false + load = main_ticks(base+3) + assert_equal LoadConstant , load.class + assert_equal Parfait::NilClass , load.constant.class + end def test_compare2 op = main_ticks(base + 4) assert_equal OperatorInstruction , op.class @@ -55,9 +58,5 @@ module Risc assert_equal IsZero , check.class assert check.label.name.start_with?("merge_label") , check.label.name end - def test_exit - done = main_ticks(40) - assert_equal Syscall , done.class - end end end diff --git a/test/risc/test_collector.rb b/test/risc/test_collector.rb index 02b47adc..24e1c960 100644 --- a/test/risc/test_collector.rb +++ b/test/risc/test_collector.rb @@ -11,7 +11,7 @@ module Risc def test_simple_collect objects = Collector.collect_space(@linker) - assert_equal 602 , objects.length , objects.length.to_s + assert_equal 620 , objects.length , objects.length.to_s end def test_collect_all_types @@ -55,7 +55,7 @@ module Risc def test_simple_collect objects = Collector.collect_space(@linker) - assert_equal 2402, objects.length , objects.length.to_s + assert_equal 2420, objects.length , objects.length.to_s end def test_integer_positions diff --git a/test/risc/test_interpreter.rb b/test/risc/test_interpreter.rb index ad504757..7a9c0cf1 100644 --- a/test/risc/test_interpreter.rb +++ b/test/risc/test_interpreter.rb @@ -55,7 +55,7 @@ module Risc end def test_pc1 @interpreter.tick - assert_equal 22616 , @interpreter.pc + assert_equal 25960 , @interpreter.pc end def test_tick2 @interpreter.tick @@ -69,7 +69,7 @@ module Risc def test_pc2 @interpreter.tick @interpreter.tick - assert_equal 22620 , @interpreter.pc + assert_equal 25964 , @interpreter.pc end def ttest_tick_14_jump 30.times { @interpreter.tick ;puts @interpreter.instruction.class} diff --git a/test/risc/test_linker.rb b/test/risc/test_linker.rb index b6acf1f6..5a74e15d 100644 --- a/test/risc/test_linker.rb +++ b/test/risc/test_linker.rb @@ -25,7 +25,7 @@ module Risc assert_equal 0 , Position.get(@linker.cpu_init).at end def test_cpu_at - assert_equal "0x576c" , Position.get(@linker.cpu_init.first).to_s + assert_equal "0x5edc" , Position.get(@linker.cpu_init.first).to_s end def test_cpu_label assert_equal Position , Position.get(@linker.cpu_init.first).class