remove Risc.resolve_to_index

mostly by using better typed registers,
which cleans up the code where it was used
This commit is contained in:
Torsten Ruger
2018-07-16 19:00:04 +03:00
parent 29363e7f72
commit 4cc04787e9
8 changed files with 27 additions and 31 deletions

View File

@ -32,15 +32,14 @@ module Mom
# a target (not a label)
def to_risc(compiler)
compiler.add_constant( @cache_entry )
reg = compiler.use_reg( :Object )
entry = compiler.use_reg( :CacheEntry )
return_label = Risc.label(self, "continue_#{object_id}")
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label],self)
moves = save_return.to_risc(compiler)
moves << Risc.slot_to_reg(self, Risc.message_reg , :next_message , Risc.message_reg)
moves << Risc.load_constant( self , @cache_entry , reg )
method_index = Risc.resolve_to_index(:cache_entry , :cached_method)
moves << Risc::SlotToReg.new( self , reg ,method_index, reg)
moves << Risc::DynamicJump.new(self, reg )
moves << Risc.load_constant( self , @cache_entry , entry )
moves << Risc.slot_to_reg( self , entry ,:cached_method , entry)
moves << Risc::DynamicJump.new(self, entry )
moves << return_label
end
end

View File

@ -22,13 +22,12 @@ module Mom
def to_risc(compiler)
return_move = SlotLoad.new( [:message , :caller,:return_value] , [:message , :return_value],self)
moves = return_move.to_risc(compiler)
return_address = compiler.use_reg(:Object)
compiler.reset_regs
caller_index = Risc.resolve_to_index(:message , :caller)
return_index = Risc.resolve_to_index(:message , :return_address)
moves << Risc::SlotToReg.new(self, Risc.message_reg, return_index , return_address)
moves << Risc::SlotToReg.new( self , return_address , Parfait::Integer.integer_index , return_address)
moves << Risc::SlotToReg.new(self, Risc.message_reg , caller_index , Risc.message_reg)
return_address = compiler.use_reg(:ReturnAddress)
message = Risc.message_reg
moves << Risc.slot_to_reg(self,message, :return_address , return_address)
moves << Risc.slot_to_reg(self,return_address , Parfait::Integer.integer_index , return_address)
moves << Risc.slot_to_reg(self,message , :caller , message)
moves << Risc::FunctionReturn.new(self, return_address)
end

View File

@ -46,7 +46,13 @@ module Mom
end
end
def to_register(compiler, source)
type = known_object.respond_to?(:ct_type) ? known_object.ct_type : :Object
if known_object.respond_to?(:ct_type)
type = known_object.ct_type
elsif(known_object.respond_to?(:get_type))
type = known_object.get_type
else
type = :Object
end
right = compiler.use_reg( type )
case known_object
when Constant
@ -57,8 +63,7 @@ module Mom
const = Risc.load_constant(source, known_object , right)
if slots.length > 0
# desctructively replace the existing value to be loaded if more slots
index = Risc.resolve_to_index(known_object , slots[0] ,compiler)
const << Risc::SlotToReg.new( source , right ,index, right)
const << Risc.slot_to_reg( source , right ,slots[0], right)
end
when Symbol
return sym_to_risc(compiler , source)

View File

@ -46,10 +46,9 @@ module Mom
when Symbol
sym_to_risc(compiler , const)
when Parfait::CacheEntry
left = compiler.use_reg( :Object )
left = compiler.use_reg( :CacheEntry )
const << Risc.load_constant(original_source, @left.known_object , left)
left_index = Risc.resolve_to_index(:cache_entry , left_slots.first)
const << Risc.reg_to_slot(original_source, const.register , left, left_index)
const << Risc.reg_to_slot(original_source, const.register , left, left_slots.first)
else
raise "We have left #{@left.known_object}"
end