to_risc for NotSameCheck
which is only used in call cache checking some fixing, needed to add a abel for the cache check jump
This commit is contained in:
parent
12c71fa394
commit
fa797f722d
@ -9,12 +9,18 @@ module Mom
|
|||||||
class NotSameCheck < Check
|
class NotSameCheck < Check
|
||||||
attr_reader :left , :right
|
attr_reader :left , :right
|
||||||
|
|
||||||
def initialize(left, right)
|
def initialize(left, right , label)
|
||||||
|
super(label)
|
||||||
@left , @right = left , right
|
@left , @right = left , right
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_risc(context)
|
# basically move both left and right values into register and issue a
|
||||||
Risc::Label.new(self,"NotSameCheck")
|
# risc comparison
|
||||||
|
def to_risc(compiler)
|
||||||
|
l_val = left.to_register(compiler, self)
|
||||||
|
r_val = right.to_register(compiler, self)
|
||||||
|
check = Risc::NotSame.new(self, l_val.register, r_val.register, false_jump.to_risc(compiler))
|
||||||
|
l_val << r_val << check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,6 +75,14 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# branch if two registers contain different values
|
||||||
|
class NotSame < Branch
|
||||||
|
attr_reader :left , :right
|
||||||
|
def initialize(source , left , right , label)
|
||||||
|
super(source , label)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Unconditional < Branch
|
class Unconditional < Branch
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -95,9 +95,11 @@ module Vool
|
|||||||
# if cached_type != current_type
|
# if cached_type != current_type
|
||||||
# cached_type = current_type
|
# cached_type = current_type
|
||||||
# cached_method = current_type.resolve_method(method.name)
|
# cached_method = current_type.resolve_method(method.name)
|
||||||
check = build_condition
|
ok = Mom::Label.new("cache_ok")
|
||||||
|
check = build_condition(ok)
|
||||||
check << build_type_cache_update
|
check << build_type_cache_update
|
||||||
check << build_method_cache_update(in_method)
|
check << build_method_cache_update(in_method)
|
||||||
|
check << ok
|
||||||
end
|
end
|
||||||
|
|
||||||
# this may look like a simple_call, but the difference is that we don't know
|
# this may look like a simple_call, but the difference is that we don't know
|
||||||
@ -107,10 +109,10 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def build_condition
|
def build_condition(ok_label)
|
||||||
cached_type = Mom::SlotDefinition.new(dynamic_call.cache_entry , [:cached_type])
|
cached_type = Mom::SlotDefinition.new(dynamic_call.cache_entry , [:cached_type])
|
||||||
current_type = Mom::SlotDefinition.new(:message , [:receiver , :type])
|
current_type = Mom::SlotDefinition.new(:message , [:receiver , :type])
|
||||||
Mom::NotSameCheck.new(cached_type , current_type)
|
Mom::NotSameCheck.new(cached_type , current_type, ok_label)
|
||||||
end
|
end
|
||||||
def build_type_cache_update
|
def build_type_cache_update
|
||||||
Mom::SlotLoad.new([dynamic_call.cache_entry, :cached_type] , [:message , :receiver , :type])
|
Mom::SlotLoad.new([dynamic_call.cache_entry, :cached_type] , [:message , :receiver , :type])
|
||||||
|
@ -26,7 +26,8 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
check_array [SlotLoad,NotSameCheck,SlotLoad,MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,MessageSetup,ArgumentTransfer,DynamicCall] , @ins
|
check_array [SlotLoad, NotSameCheck, SlotLoad, MessageSetup, ArgumentTransfer, SimpleCall ,
|
||||||
|
SlotLoad, Label, MessageSetup, ArgumentTransfer, DynamicCall] , @ins
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -12,19 +12,19 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condition
|
def test_condition
|
||||||
assert_equal TruthCheck , @ins.next(10).class
|
assert_equal TruthCheck , @ins.next(11).class
|
||||||
end
|
end
|
||||||
def test_condition_is_slot
|
def test_condition_is_slot
|
||||||
assert_equal SlotDefinition , @ins.next(10).condition.class , @ins
|
assert_equal SlotDefinition , @ins.next(11).condition.class , @ins
|
||||||
end
|
end
|
||||||
def test_hoisted_dynamic_call
|
def test_hoisted_dynamic_call
|
||||||
assert_equal DynamicCall , @ins.next(8).class
|
assert_equal DynamicCall , @ins.next(9).class
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [NotSameCheck, SlotLoad, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
|
check_array [NotSameCheck, SlotLoad, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
|
||||||
MessageSetup, ArgumentTransfer, DynamicCall, SlotLoad, TruthCheck, Label ,
|
Label, MessageSetup, ArgumentTransfer, DynamicCall, SlotLoad, TruthCheck ,
|
||||||
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label, MessageSetup ,
|
Label, MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
|
||||||
ArgumentTransfer, SimpleCall, Label] , @ins
|
MessageSetup, ArgumentTransfer, SimpleCall, Label] , @ins
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user