Class: YTLJit::VM::Node::TopTopNode

Inherits:
ClassTopNode show all
Includes:
MethodTopCodeGen
Defined in:
lib/ytljit/vm.rb

Constant Summary collapse

@@frame_struct_tab =
{}
@@local_object_area =
Runtime::Arena.new
@@global_object_area =
Runtime::Arena.new
@@unwind_proc =
CodeSpace.new
@@nothing_proc =
CodeSpace.new

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

Constants inherited from BaseNode

BaseNode::ESCAPE_LEVEL

Instance Attribute Summary collapse

Attributes inherited from ClassTopNode

#after_search_module, #before_search_module, #constant_tab, #klass_object, #klassclass, #klassclass_node, #method_tab

Attributes inherited from TopNode

#classtop, #code_space_from_signature, #current_signature, #end_nodes, #escape_info, #exception_table, #name, #send_nodes_with_block, #signature_cache, #yield_node

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MethodTopCodeGen

#gen_method_prologue

Methods inherited from ClassTopNode

#add_after_search_module, #add_before_search_module, #construct_frame_info, get_class_top_node, #get_constant_tab, #get_constant_value, #get_method_tab, #make_klassclass_node, #search_constant_with_super, #search_method_with_super

Methods included from SendNodeCodeGen

#gen_make_argv

Methods included from CommonCodeGen

#dump_context, #gen_alloca, #gen_call, #gen_save_thepr

Methods inherited from TopNode

#add_arg_to_args, #collect_candidate_type_common, #collect_info_top, #construct_frame_info, #disp_signature, #gen_comment, #modified_instance_var

Methods included from MultipleCodeSpaceUtil

#add_cs_for_signature, #find_cs_by_signature, #get_code_space

Methods included from NodeUtil

#search_class_top, #search_end, #search_frame_info, #search_top

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #add_element_node_backward_aux, #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, klassobj, name = :top) ⇒ TopTopNode

Returns a new instance of TopTopNode.



1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
# File 'lib/ytljit/vm.rb', line 1666

def initialize(parent, klassobj, name = :top)
  super
  
  @code_space_tab = []
  @asm_tab = {}
  @id.push 0

  @frame_struct_array = []
  @init_node = nil

  # Dummy for marshal
  @op_var_value_instaces = nil

  @modified_global_var = nil
end

Instance Attribute Details

#asm_tabObject (readonly)

Returns the value of attribute asm_tab.



1684
1685
1686
# File 'lib/ytljit/vm.rb', line 1684

def asm_tab
  @asm_tab
end

#code_space_tabObject (readonly)

Returns the value of attribute code_space_tab.



1683
1684
1685
# File 'lib/ytljit/vm.rb', line 1683

def code_space_tab
  @code_space_tab
end

#frame_struct_arrayObject (readonly)

Returns the value of attribute frame_struct_array.



1685
1686
1687
# File 'lib/ytljit/vm.rb', line 1685

def frame_struct_array
  @frame_struct_array
end

#init_nodeObject

Returns the value of attribute init_node.



1682
1683
1684
# File 'lib/ytljit/vm.rb', line 1682

def init_node
  @init_node
end

Class Method Details

.get_frame_struct_tabObject



1653
1654
1655
# File 'lib/ytljit/vm.rb', line 1653

def self.get_frame_struct_tab
  @@frame_struct_tab
end

.get_nothing_procObject



1662
1663
1664
# File 'lib/ytljit/vm.rb', line 1662

def self.get_nothing_proc
  @@nothing_proc
end

.get_unwind_procObject



1657
1658
1659
# File 'lib/ytljit/vm.rb', line 1657

def self.get_unwind_proc
  @@unwind_proc
end

Instance Method Details

#add_code_space(oldcs, newcs) ⇒ Object



1726
1727
1728
1729
1730
# File 'lib/ytljit/vm.rb', line 1726

def add_code_space(oldcs, newcs)
  if !@code_space_tab.include?(newcs) then
    @code_space_tab.push newcs
  end
end

#code_store_hookObject



1813
1814
1815
# File 'lib/ytljit/vm.rb', line 1813

def code_store_hook
  @op_var_value_instaces = OpVarValueMixin.instances
end

#collect_candidate_type(context, signode, sig) ⇒ Object



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

def collect_candidate_type(context, signode, sig)
  context.convergent = true
  context.visited_top_node = {}
  if @init_node then
    context = @init_node.collect_candidate_type(context, signode, sig)
  end

  # This is for return boxed object to CRuby system
  if @end_nodes[0] then
    @end_nodes[0].add_type(sig, RubyType::BaseType.from_object(nil))
  end

  super(context, signode, sig)
end

#collect_info(context) ⇒ Object



1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
# File 'lib/ytljit/vm.rb', line 1732

def collect_info(context)
  if @init_node then
    context = @init_node.collect_info(context)
  else
    init_unwind_proc
    add_code_space(nil, @@unwind_proc)
  end
  context = super(context)
  @modified_global_var = context.modified_global_var
  context
end

#compile(context) ⇒ Object



1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
# File 'lib/ytljit/vm.rb', line 1799

def compile(context)
  if @init_node then
    context = @init_node.compile(context)
  end
  @modified_global_var.each_with_index do |dmy, i|
    @@global_object_area[i + 1] = 4
=begin
    p @@global_object_area
    p dmy[0]
=end
  end
  super(context)
end

#compile_init(context) ⇒ Object



1791
1792
1793
1794
1795
1796
1797
# File 'lib/ytljit/vm.rb', line 1791

def compile_init(context)
  asm = context.assembler
  asm.with_retry do
    asm.mov(THEPR, get_local_arena_end_address)
  end
  context
end

#get_global_arena_addressObject



1759
1760
1761
1762
1763
1764
1765
# File 'lib/ytljit/vm.rb', line 1759

def get_global_arena_address
  ar = @@global_object_area
  addr = lambda {
    ar.raw_address
  }
  OpVarImmidiateAddress.new(addr)           
end

#get_global_arena_end_addressObject



1767
1768
1769
1770
1771
1772
1773
# File 'lib/ytljit/vm.rb', line 1767

def get_global_arena_end_address
  ar = @@global_object_area
  addr = lambda {
    ar.body_address + ar.size
  }
  OpVarImmidiateAddress.new(addr)           
end

#get_local_arena_addressObject



1775
1776
1777
1778
1779
1780
1781
# File 'lib/ytljit/vm.rb', line 1775

def get_local_arena_address
  ar = @@local_object_area
  addr = lambda {
    ar.raw_address
  }
  OpVarImmidiateAddress.new(addr)           
end

#get_local_arena_end_addressObject



1783
1784
1785
1786
1787
1788
1789
# File 'lib/ytljit/vm.rb', line 1783

def get_local_arena_end_address
  ar = @@local_object_area
  addr = lambda {
    (ar.body_address + ar.size) & (~0xf)
  }
  OpVarImmidiateAddress.new(addr)           
end

#init_unwind_procObject



1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
# File 'lib/ytljit/vm.rb', line 1700

def init_unwind_proc
  asm = Assembler.new(@@unwind_proc)
  # Make linkage of frame pointer
  asm.with_retry do
    asm.mov(SPR, BPR)
    asm.pop(BPR)
    # must be asm.pop(THEPR)? Maybe not because release caller
    asm.pop(TMPR)   # Dummy pop THEPR
    asm.pop(TMPR2)   # exception handler
    asm.mov(SPR, BPR)
    asm.pop(BPR) # Return address store by call inst.
    asm.pop(TMPR) # return address
    asm.add(TMPR2, TMPR3)  # TMPR3 store offset of exception handler
    asm.mov(TMPR2, INDIRECT_TMPR2)
    asm.and(TMPR2, TMPR2)
    asm.jz(@@unwind_proc.var_base_address)
    asm.jmp(TMPR2)
  end

  asm = Assembler.new(@@nothing_proc)
  # Make linkage of frame pointer
  asm.with_retry do
    asm.ret
  end
end

#make_frame_struct_tabObject



1687
1688
1689
1690
1691
# File 'lib/ytljit/vm.rb', line 1687

def make_frame_struct_tab
  @frame_struct_array.each do |vkey, val|
    @@frame_struct_tab[vkey.value] = val
  end
end

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

Yields:



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

def traverse_childlen
  if @init_node then
    yield @init_node
  end
  yield @body
end

#update_after_restoreObject



1817
1818
1819
1820
1821
1822
1823
# File 'lib/ytljit/vm.rb', line 1817

def update_after_restore
  @op_var_value_instaces.each do |ins|
    ins.refer.each do |stfn|
      stfn.call
    end
  end
end