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

#end_nodes, #exception_table, #name, #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, #construct_frame_info, #disp_signature, #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, #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, klassobj, name = :top) ⇒ TopTopNode

Returns a new instance of TopTopNode.



1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/ytljit/vm.rb', line 1477

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.



1495
1496
1497
# File 'lib/ytljit/vm.rb', line 1495

def asm_tab
  @asm_tab
end

#code_space_tabObject (readonly)

Returns the value of attribute code_space_tab.



1494
1495
1496
# File 'lib/ytljit/vm.rb', line 1494

def code_space_tab
  @code_space_tab
end

#frame_struct_arrayObject (readonly)

Returns the value of attribute frame_struct_array.



1496
1497
1498
# File 'lib/ytljit/vm.rb', line 1496

def frame_struct_array
  @frame_struct_array
end

#init_nodeObject

Returns the value of attribute init_node.



1493
1494
1495
# File 'lib/ytljit/vm.rb', line 1493

def init_node
  @init_node
end

Class Method Details

.get_frame_struct_tabObject



1464
1465
1466
# File 'lib/ytljit/vm.rb', line 1464

def self.get_frame_struct_tab
  @@frame_struct_tab
end

.get_nothing_procObject



1473
1474
1475
# File 'lib/ytljit/vm.rb', line 1473

def self.get_nothing_proc
  @@nothing_proc
end

.get_unwind_procObject



1468
1469
1470
# File 'lib/ytljit/vm.rb', line 1468

def self.get_unwind_proc
  @@unwind_proc
end

Instance Method Details

#add_code_space(oldcs, newcs) ⇒ Object



1537
1538
1539
1540
1541
# File 'lib/ytljit/vm.rb', line 1537

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

#code_store_hookObject



1616
1617
1618
# File 'lib/ytljit/vm.rb', line 1616

def code_store_hook
  @op_var_value_instaces = OpVarValueMixin.instances
end

#collect_candidate_type(context, signode, sig) ⇒ Object



1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
# File 'lib/ytljit/vm.rb', line 1555

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



1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
# File 'lib/ytljit/vm.rb', line 1543

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



1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
# File 'lib/ytljit/vm.rb', line 1602

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



1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
# File 'lib/ytljit/vm.rb', line 1590

def compile_init(context)
  addr = lambda {
    get_local_arena_end_address
  }
  aa = OpVarImmidiateAddress.new(addr) 
  asm = context.assembler
  asm.with_retry do
    asm.mov(THEPR, aa)
  end
  context
end

#get_global_arena_addressObject



1570
1571
1572
1573
# File 'lib/ytljit/vm.rb', line 1570

def get_global_arena_address
  ar = @@global_object_area
  ar.raw_address
end

#get_global_arena_end_addressObject



1575
1576
1577
1578
# File 'lib/ytljit/vm.rb', line 1575

def get_global_arena_end_address
  ar = @@global_object_area
  ar.body_address + ar.size
end

#get_local_arena_addressObject



1580
1581
1582
1583
# File 'lib/ytljit/vm.rb', line 1580

def get_local_arena_address
  ar = @@local_object_area
  ar.raw_address
end

#get_local_arena_end_addressObject



1585
1586
1587
1588
# File 'lib/ytljit/vm.rb', line 1585

def get_local_arena_end_address
  ar = @@local_object_area
  (ar.body_address + ar.size) & (~0xf)
end

#init_unwind_procObject



1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
# File 'lib/ytljit/vm.rb', line 1511

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



1498
1499
1500
1501
1502
# File 'lib/ytljit/vm.rb', line 1498

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:



1504
1505
1506
1507
1508
1509
# File 'lib/ytljit/vm.rb', line 1504

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

#update_after_restoreObject



1620
1621
1622
1623
1624
1625
1626
# File 'lib/ytljit/vm.rb', line 1620

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