fix releasing in allocator

fell into hash new trap, which reuses the object you give it. not good for mutable objects like the array.
also previous logic was broken in terms of machine vs ssa names
This commit is contained in:
2020-03-19 14:10:39 +02:00
parent 3f131a4018
commit f13e6dcf57
3 changed files with 42 additions and 11 deletions

View File

@ -37,6 +37,10 @@ module Risc
assert_equal Symbol, @allocator.use_reg(:r1, :some).class
assert @allocator.used_regs.include?(:r1)
end
def test_reverse_check
assert_equal Symbol, @allocator.use_reg(:r1, :some).class
assert_equal :r1 , @allocator.reverse_used(:some)
end
def test_add_fail
assert_raises{ @allocator.use_reg(1)}
end

View File

@ -13,7 +13,7 @@ module Risc
end
def test_allocate_runs
assert_nil @allocator.allocate_regs
assert_equal 10 , @allocator.used_regs.length
assert_equal 0 , @allocator.used_regs.length
end
def test_live_length
live = @allocator.walk_and_mark(@compiler.risc_instructions)