first go at translating DynamicCall to risc
This commit is contained in:
parent
d9ce295b89
commit
d98e55907e
@ -18,8 +18,18 @@ module Mom
|
|||||||
@cache_entry = Parfait::CacheEntry.new(type, method)
|
@cache_entry = Parfait::CacheEntry.new(type, method)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_risc(context)
|
# One could almost think that one can resolve this to a Risc::FunctionCall
|
||||||
Risc::Label.new(self,"DynamicCall")
|
# (which btw resolves to a simple jump), alas, the FunctionCall, like all other
|
||||||
|
# jumping, resolves the address at compile time.
|
||||||
|
#
|
||||||
|
# Instead we need a DynamicJump instruction that explicitly takes a register as
|
||||||
|
# a target (not a label)
|
||||||
|
def to_risc(compiler)
|
||||||
|
reg = compiler.use_reg( :int )
|
||||||
|
call = Risc.load_constant( self , @cache_entry , reg )
|
||||||
|
method_index = Risc.resolve_to_index(:cache_entry , :cached_method)
|
||||||
|
call << Risc::SlotToReg.new( self , reg ,method_index, reg)
|
||||||
|
call << Risc::DynamicJump.new(self, reg )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,6 +53,20 @@ module Risc
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# dynamic version of an Unconditional branch that jumps to the contents
|
||||||
|
# of a register instead of a hardcoded address
|
||||||
|
# As Branches jump to Labels, this is not derived from Branch
|
||||||
|
# PS: to conditionally jump to a dynamic adddress we do a normal branch
|
||||||
|
# over the dynamic one and then a dynamic one. Save us having all types of branches
|
||||||
|
# in two versions
|
||||||
|
class DynamicJump < Instruction
|
||||||
|
def initialize( source , register )
|
||||||
|
super(source)
|
||||||
|
@register = register
|
||||||
|
end
|
||||||
|
attr_reader :register
|
||||||
|
end
|
||||||
|
|
||||||
# branch if two registers contain same value
|
# branch if two registers contain same value
|
||||||
class IsSame < Branch
|
class IsSame < Branch
|
||||||
attr_reader :left , :right
|
attr_reader :left , :right
|
||||||
|
Loading…
Reference in New Issue
Block a user