Class: YTLJit::VM::Node::LocalLabel

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

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 collapse

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, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #merge_type, #same_type, #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, name) ⇒ LocalLabel

Returns a new instance of LocalLabel.



1623
1624
1625
1626
1627
1628
1629
1630
1631
# File 'lib/ytljit/vm.rb', line 1623

def initialize(parent, name)
  super(parent)
  @name = name
  @come_from = {}
  @come_from_val = []
  @code_space = CodeSpace.new
  @value_node = PhiNode.new(self)
  @modified_local_var_list = []
end

Instance Attribute Details

#come_fromObject (readonly)

Returns the value of attribute come_from.



1634
1635
1636
# File 'lib/ytljit/vm.rb', line 1634

def come_from
  @come_from
end

#nameObject (readonly)

Returns the value of attribute name.



1633
1634
1635
# File 'lib/ytljit/vm.rb', line 1633

def name
  @name
end

#value_nodeObject (readonly)

Returns the value of attribute value_node.



1635
1636
1637
# File 'lib/ytljit/vm.rb', line 1635

def value_node
  @value_node
end

Instance Method Details

#collect_candidate_type(context, sender = nil) ⇒ Object



1714
1715
1716
1717
1718
1719
1720
# File 'lib/ytljit/vm.rb', line 1714

def collect_candidate_type(context, sender = nil)
  if @come_from.keys[0] == sender then
    @body.collect_candidate_type(context)
  else
    context
  end
end

#collect_info(context) ⇒ Object



1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
# File 'lib/ytljit/vm.rb', line 1658

def collect_info(context)
  if @modified_local_var_list.size == 0 then
    # first visit
    delnode = []
    fornode = []
    @come_from.keys.each do |ele|
      if lonly_node(ele) then
        delnode.push ele
      end
    end
    delnode.each do |ele|
      @come_from.delete(ele)
    end
  end
    
  modlocvar = context.modified_local_var.last.map {|ele| ele.dup}
  @modified_local_var_list.push modlocvar
  if @modified_local_var_list.size == 1 then
    @body.collect_info(context)
  elsif @modified_local_var_list.size == @come_from.size then
    context.merge_local_var(@modified_local_var_list)
    @body.collect_info(context)
  else
    context
  end
end

#compile(context) ⇒ Object



1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
# File 'lib/ytljit/vm.rb', line 1722

def compile(context)
  context = super(context)
  @come_from_val.push context.ret_reg
  
  if @come_from_val.size == 1 then
    @body.compile(context)
  else
    context
  end
end

#compile_block_value(context, comefrom) ⇒ Object



1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
# File 'lib/ytljit/vm.rb', line 1685

def compile_block_value(context, comefrom)
  valnode = @come_from[comefrom]
  if valnode then
    context = valnode.compile(context)
    asm = context.assembler
    if !context.ret_reg.is_a?(OpRegXMM) then
      if RETR != context.ret_reg then
        asm.with_retry do
          asm.mov(RETR, context.ret_reg)
        end
        context.set_reg_content(RETR, context.ret_node)
        context.ret_reg = RETR
      end
    end
  end

  context.set_reg_content(context.ret_reg, self)
  context
end

#lonly_node(node) ⇒ Object



1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
# File 'lib/ytljit/vm.rb', line 1642

def lonly_node(node)
  while !node.is_a?(TopNode) 
    if node.is_a?(LocalLabel) then
      if node.come_from.size == 0 then
        return true
      else
        return false
      end
    end

    node = node.parent
  end

  return false
end

#traverse_block_value(comefrom, &block) ⇒ Object



1705
1706
1707
1708
1709
1710
1711
1712
# File 'lib/ytljit/vm.rb', line 1705

def traverse_block_value(comefrom, &block)
  valnode = @come_from[comefrom]
  if valnode then
    yield valnode
  else
    nil
  end
end

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

Yields:



1637
1638
1639
1640
# File 'lib/ytljit/vm.rb', line 1637

def traverse_childlen
  yield @value_node
  yield @body
end