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, #add_element_node_backward_aux, #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, #search_valid_signature, #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



1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
# File 'lib/ytljit/vm.rb', line 1862

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

  @argc = nil
  @opt_label = []
  @opt_label_node = []
  @post_len = nil
  @post_start = nil
  @rest_index = nil
  @block_index = nil
  @simple = true
end

Instance Attribute Details

#argcObject

Returns the value of attribute argc.



1908
1909
1910
# File 'lib/ytljit/vm.rb', line 1908

def argc
  @argc
end

#argument_numObject

Returns the value of attribute argument_num.



1904
1905
1906
# File 'lib/ytljit/vm.rb', line 1904

def argument_num
  @argument_num
end

#block_indexObject

Returns the value of attribute block_index.



1914
1915
1916
# File 'lib/ytljit/vm.rb', line 1914

def block_index
  @block_index
end

#frame_layoutObject

Returns the value of attribute frame_layout.



1903
1904
1905
# File 'lib/ytljit/vm.rb', line 1903

def frame_layout
  @frame_layout
end

#opt_labelObject

Returns the value of attribute opt_label.



1909
1910
1911
# File 'lib/ytljit/vm.rb', line 1909

def opt_label
  @opt_label
end

#opt_label_nodeObject

Returns the value of attribute opt_label_node.



1910
1911
1912
# File 'lib/ytljit/vm.rb', line 1910

def opt_label_node
  @opt_label_node
end

#post_lenObject

Returns the value of attribute post_len.



1911
1912
1913
# File 'lib/ytljit/vm.rb', line 1911

def post_len
  @post_len
end

#post_startObject

Returns the value of attribute post_start.



1912
1913
1914
# File 'lib/ytljit/vm.rb', line 1912

def post_start
  @post_start
end

#previous_frameObject (readonly)

Returns the value of attribute previous_frame.



1906
1907
1908
# File 'lib/ytljit/vm.rb', line 1906

def previous_frame
  @previous_frame
end

#rest_indexObject

Returns the value of attribute rest_index.



1913
1914
1915
# File 'lib/ytljit/vm.rb', line 1913

def rest_index
  @rest_index
end

#simpleObject

Returns the value of attribute simple.



1915
1916
1917
# File 'lib/ytljit/vm.rb', line 1915

def simple
  @simple
end

#system_numObject

Returns the value of attribute system_num.



1905
1906
1907
# File 'lib/ytljit/vm.rb', line 1905

def system_num
  @system_num
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



1978
1979
1980
1981
1982
# File 'lib/ytljit/vm.rb', line 1978

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

#compile(context) ⇒ Object



1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
# File 'lib/ytljit/vm.rb', line 1984

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



1928
1929
1930
1931
1932
1933
# File 'lib/ytljit/vm.rb', line 1928

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



1899
1900
1901
# File 'lib/ytljit/vm.rb', line 1899

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

#frame_sizeObject



1924
1925
1926
# File 'lib/ytljit/vm.rb', line 1924

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

#init_after_constructObject



1882
1883
1884
# File 'lib/ytljit/vm.rb', line 1882

def init_after_construct
  @local_area_size = compute_local_area_size
end

#offset_arg(n, basereg) ⇒ Object



1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
# File 'lib/ytljit/vm.rb', line 1956

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



1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
# File 'lib/ytljit/vm.rb', line 1945

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



1935
1936
1937
1938
1939
1940
1941
1942
1943
# File 'lib/ytljit/vm.rb', line 1935

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



1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
# File 'lib/ytljit/vm.rb', line 1886

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



1972
1973
1974
1975
1976
# File 'lib/ytljit/vm.rb', line 1972

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:



1917
1918
1919
1920
1921
1922
# File 'lib/ytljit/vm.rb', line 1917

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