Class: YTLJit::VM::Node::LocalFrameInfoNode

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

Constant Summary

Constants inherited from BaseNode

BaseNode::ESCAPE_LEVEL

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, #add_element_node_backward, #collect_info, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #marge_element_node, #marge_type, #same_type, #set_escape_node, #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) ⇒ LocalFrameInfoNode

Returns a new instance of LocalFrameInfoNode.



1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
# File 'lib/ytljit/vm.rb', line 1665

def initialize(parent)
  super(parent)
  @frame_layout = []
  @argument_num = nil
  @system_num = nil
  @previous_frame = search_previous_frame(parent)
  @offset_cache = {}
  @local_area_size = nil
  @alloca_area_size = 0
end

Instance Attribute Details

#argument_numObject

Returns the value of attribute argument_num.



1698
1699
1700
# File 'lib/ytljit/vm.rb', line 1698

def argument_num
  @argument_num
end

#frame_layoutObject

Returns the value of attribute frame_layout.



1697
1698
1699
# File 'lib/ytljit/vm.rb', line 1697

def frame_layout
  @frame_layout
end

#previous_frameObject (readonly)

Returns the value of attribute previous_frame.



1700
1701
1702
# File 'lib/ytljit/vm.rb', line 1700

def previous_frame
  @previous_frame
end

#system_numObject

Returns the value of attribute system_num.



1699
1700
1701
# File 'lib/ytljit/vm.rb', line 1699

def system_num
  @system_num
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



1763
1764
1765
1766
1767
# File 'lib/ytljit/vm.rb', line 1763

def collect_candidate_type(context)
  traverse_childlen {|rec|
    context = rec.collect_candidate_type(context)
  }
end

#compile(context) ⇒ Object



1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
# File 'lib/ytljit/vm.rb', line 1769

def compile(context)
  context = super(context)
  siz = @local_area_size + @alloca_area_size
  if siz != 0 and !(@parent.is_a?(ExceptionTopNode)) then
    asm = context.assembler
    asm.with_retry do
      asm.sub(SPR, siz)
    end
    context.cpustack_pushn(siz)
    context = @body.compile(context)
    context.cpustack_popn(siz)
  else
    context = @body.compile(context)
  end

  context
end

#compute_local_area_sizeObject



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

def compute_local_area_size
  localnum = @frame_layout.size - @argument_num - @system_num
  @frame_layout[0, localnum].inject(0) {|sum, slot| 
    sum += slot.size
  }
end

#copy_frame_layoutObject



1693
1694
1695
# File 'lib/ytljit/vm.rb', line 1693

def copy_frame_layout
  @frame_layout.each { |ele| ele.dup }
end

#frame_sizeObject



1709
1710
1711
# File 'lib/ytljit/vm.rb', line 1709

def frame_size
  @frame_layout.inject(0) {|sum, slot| sum += slot.size}
end

#init_after_constructObject



1676
1677
1678
# File 'lib/ytljit/vm.rb', line 1676

def init_after_construct
  @local_area_size = compute_local_area_size
end

#offset_arg(n, basereg) ⇒ Object



1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
# File 'lib/ytljit/vm.rb', line 1741

def offset_arg(n, basereg)
  rc = nil
  if basereg == BPR then
    rc = @offset_cache[n]
    unless rc
      off = offset_by_byte(n)
      rc = @offset_cache[n] = OpIndirect.new(basereg, off)
    end
  else
    off = offset_by_byte(n)
    rc = OpIndirect.new(basereg, off)
  end

  rc
end

#offset_by_byte(off) ⇒ Object



1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
# File 'lib/ytljit/vm.rb', line 1730

def offset_by_byte(off)
  off = real_offset(off)

  obyte = 0
  off.times do |i|
    obyte += @frame_layout[i].size
  end
  
  obyte - @local_area_size
end

#real_offset(off) ⇒ Object



1720
1721
1722
1723
1724
1725
1726
1727
1728
# File 'lib/ytljit/vm.rb', line 1720

def real_offset(off)
  if off >=  @argument_num then
    off = off - @argument_num
  else
    off = off + (@frame_layout.size - @argument_num)
  end

  off
end

#search_previous_frame(mtop) ⇒ Object



1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
# File 'lib/ytljit/vm.rb', line 1680

def search_previous_frame(mtop)
  cnode = mtop.parent
  while !cnode.is_a?(TopNode)
    if cnode then
      cnode = cnode.parent
    else
      return nil
    end
  end

  return cnode.body
end

#static_alloca(size) ⇒ Object



1757
1758
1759
1760
1761
# File 'lib/ytljit/vm.rb', line 1757

def static_alloca(size)
#          base = -offset_by_byte(0)
  @alloca_area_size += size
  -(@local_area_size + @alloca_area_size)
end

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

Yields:



1702
1703
1704
1705
1706
1707
# File 'lib/ytljit/vm.rb', line 1702

def traverse_childlen
  @frame_layout.each do |vinf|
    yield vinf
  end
  yield @body
end