Class: YTLJit::VM::Node::BranchCommonNode

Inherits:
BaseNode show all
Includes:
HaveChildlenMixin, IfNodeCodeGen
Defined in:
lib/ytljit/vm.rb

Direct Known Subclasses

BranchIfNode, BranchUnlessNode

Constant Summary

Constants included from AbsArch

AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3

Constants included from SSE

SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7

Instance Attribute Summary

Attributes included from HaveChildlenMixin

#body

Attributes inherited from BaseNode

#code_space, #debug_info, #element_node_list, #id, #is_escape, #parent, #ti_observee, #ti_observer, #type

Instance Method Summary collapse

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #collect_info, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #marge_type, #same_type, #set_escape_node_backward, #ti_add_observer, #ti_changed, #ti_del_link, #ti_reset, #ti_update

Methods included from TypeListWithSignature

#add_type, #set_type_list, #type_list, #type_list_initvar

Methods included from Inspect

#inspect_by_graph

Constructor Details

#initialize(parent, cond, jmpto) ⇒ BranchCommonNode

Returns a new instance of BranchCommonNode.



2102
2103
2104
2105
2106
# File 'lib/ytljit/vm.rb', line 2102

def initialize(parent, cond, jmpto)
  super(parent)
  @cond = cond
  @jmp_to_node = jmpto
end

Instance Method Details

#branch(as, address) ⇒ Object



2115
2116
2117
2118
2119
# File 'lib/ytljit/vm.rb', line 2115

def branch(as, address)
  # as.jn(address)
  # as.je(address)
  raise "Don't use this node direct"
end

#collect_candidate_type(context) ⇒ Object



2121
2122
2123
2124
2125
# File 'lib/ytljit/vm.rb', line 2121

def collect_candidate_type(context)
  context = @cond.collect_candidate_type(context)
  context = @jmp_to_node.collect_candidate_type(context, self)
  @body.collect_candidate_type(context)
end

#compile(context) ⇒ Object



2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
# File 'lib/ytljit/vm.rb', line 2127

def compile(context)
  sig = context.to_signature
  context = super(context)
  context = @jmp_to_node.compile_block_value(context, self)
  jmptocs = @jmp_to_node.get_code_space(sig)

  curas = context.assembler
  context = @cond.compile(context)
  curas.with_retry do
    if context.ret_reg != TMPR then
      curas.mov(TMPR, context.ret_reg)
    end
    
    # In 64bit mode. It will be sign extended to 64 bit
    curas.and(TMPR, OpImmidiate32.new(~4))
  end

  curas.with_retry do
    branch(curas, jmptocs.var_base_address)
  end

  context = @body.compile(context)
  oldcs = context.set_code_space(jmptocs)
  context = @jmp_to_node.compile(context)
#          context.set_code_space(oldcs)

  context
end

#traverse_childlen {|@cond| ... } ⇒ Object

Yields:

  • (@cond)


2108
2109
2110
2111
2112
2113
# File 'lib/ytljit/vm.rb', line 2108

def traverse_childlen(&block)
  @jmp_to_node.traverse_block_value(self, &block)
  yield @cond
  yield @jmp_to_node
  yield @body
end