use the return jump to jump to the return sequence

thus every method only has one exit
should make multi return messages smaller
especially when we have escape analisis
(maybe will help with inlining too)
This commit is contained in:
Torsten Ruger
2018-08-02 17:36:39 +03:00
parent 4d4b691a4b
commit 5346077a72
3 changed files with 27 additions and 12 deletions

View File

@ -13,14 +13,28 @@ module Risc
def initialize( callable )
@callable = callable
@regs = []
@risc_instructions = Risc.label(source_name, source_name)
@risc_instructions << Risc.label( source_name, "unreachable")
init_instructions
@current = @risc_instructions
@constants = []
@block_compilers = []
end
attr_reader :risc_instructions , :constants , :block_compilers , :callable
def init_instructions
@risc_instructions = Risc.label(source_name, source_name)
@risc_instructions.append Risc.label( source_name, "return_label")
@risc_instructions.append Mom::ReturnSequence.new.to_risc(self)
@risc_instructions.append Risc.label( source_name, "unreachable")
reset_regs
end
def return_label
@risc_instructions.each do |ins|
next unless ins.is_a?(Label)
return ins if ins.name == "return_label"
end
end
# convert the given mom instruction to_risc and then add it (see add_code)
# continue down the instruction chain unti depleted
# (adding moves the insertion point so the whole mom chain is added as a risc chain)