From e0dd4e0ad7a8c90ffb5c6d6c0a4b16fc9911ceed Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 21 Mar 2018 21:58:43 +0530 Subject: [PATCH] test dynamic call made cache labels unique --- lib/vool/statements/send_statement.rb | 2 +- test/mom/test_send_dynamic.rb | 43 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/mom/test_send_dynamic.rb diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/statements/send_statement.rb index 79e113c2..8940b2fc 100644 --- a/lib/vool/statements/send_statement.rb +++ b/lib/vool/statements/send_statement.rb @@ -95,7 +95,7 @@ module Vool # if cached_type != current_type # cached_type = current_type # cached_method = current_type.resolve_method(method.name) - ok = Mom::Label.new("cache_ok") + ok = Mom::Label.new("cache_ok_#{self.object_id}") check = build_condition(ok) check << build_type_cache_update check << build_method_cache_update(in_method) diff --git a/test/mom/test_send_dynamic.rb b/test/mom/test_send_dynamic.rb new file mode 100644 index 00000000..f5f58d3a --- /dev/null +++ b/test/mom/test_send_dynamic.rb @@ -0,0 +1,43 @@ +require_relative "helper" + +module Risc + class TestSendDynamic < MiniTest::Test + include Statements + + def setup + super + @input = "@a.mod4" + @expect = [LoadConstant, SlotToReg, SlotToReg, NotSame, SlotToReg, SlotToReg , + RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg , + SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot , + LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg , + RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant , + FunctionCall, Label, SlotToReg, RegToSlot, Label, LoadConstant , + SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot , + LoadConstant, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg , + SlotToReg, RegToSlot, LoadConstant, SlotToReg, DynamicJump] + end + + def test_send_instructions + assert_nil msg = check_nil , msg + end + def test_function_call + produced = produce_body + assert_equal DynamicJump , produced.next(52).class + end + def test_load_address + produced = produce_body + assert_equal Parfait::CacheEntry , produced.next(50).constant.class + end + def test_cache_check + produced = produce_body + assert_equal NotSame , produced.next(3).class + assert produced.next(34) , produced.next(3).label + end + def test_check_resolve + produced = produce_body + assert_equal FunctionCall , produced.next(30).class + assert_equal :resolve_method ,produced.next(30).method.name + end + end +end