register assignment fix (was not taking subsequent calls into account)

This commit is contained in:
Torsten Ruger 2014-06-12 21:27:30 +03:00
parent 200da192b4
commit 6d6c7ddb68
2 changed files with 12 additions and 3 deletions

View File

@ -87,7 +87,8 @@ module Vm
# a call_site uses pushes and pops these to make them available for code after a call
def locals_at l_block
used =[]
assigned = []
# call assigns the return register, but as it is in l_block, it is not asked.
assigned = [ RegisterUse.new(Vm::RegisterMachine.instance.return_register) ]
l_block.reachable.each do |b|
b.uses.each {|u|
(used << u) unless assigned.include?(u)

View File

@ -183,10 +183,18 @@ module Vm
end
end
def uses
[]
if opcode == :call
@first.args.collect {|arg| arg.used_register }
else
[]
end
end
def assigns
[]
if opcode == :call
[RegisterUse.new(RegisterMachine.instance.return_register)]
else
[]
end
end
end
end