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
@@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

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_type, #same_type, #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.



1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
# File 'lib/ytljit/vm.rb', line 1452

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
end

Instance Attribute Details

#asm_tabObject (readonly)

Returns the value of attribute asm_tab.



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

def asm_tab
  @asm_tab
end

#code_space_tabObject (readonly)

Returns the value of attribute code_space_tab.



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

def code_space_tab
  @code_space_tab
end

#frame_struct_arrayObject (readonly)

Returns the value of attribute frame_struct_array.



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

def frame_struct_array
  @frame_struct_array
end

#init_nodeObject

Returns the value of attribute init_node.



1466
1467
1468
# File 'lib/ytljit/vm.rb', line 1466

def init_node
  @init_node
end

Class Method Details

.get_frame_struct_tabObject



1439
1440
1441
# File 'lib/ytljit/vm.rb', line 1439

def self.get_frame_struct_tab
  @@frame_struct_tab
end

.get_nothing_procObject



1448
1449
1450
# File 'lib/ytljit/vm.rb', line 1448

def self.get_nothing_proc
  @@nothing_proc
end

.get_unwind_procObject



1443
1444
1445
# File 'lib/ytljit/vm.rb', line 1443

def self.get_unwind_proc
  @@unwind_proc
end

Instance Method Details

#add_code_space(oldcs, newcs) ⇒ Object



1510
1511
1512
1513
1514
# File 'lib/ytljit/vm.rb', line 1510

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

#code_store_hookObject



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

def code_store_hook
  @op_var_value_instaces = OpVarValueMixin.instances
end

#collect_candidate_type(context, signode, sig) ⇒ Object



1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
# File 'lib/ytljit/vm.rb', line 1526

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



1516
1517
1518
1519
1520
1521
1522
1523
1524
# File 'lib/ytljit/vm.rb', line 1516

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
  super(context)
end

#compile(context) ⇒ Object



1564
1565
1566
1567
1568
1569
# File 'lib/ytljit/vm.rb', line 1564

def compile(context)
  if @init_node then
    context = @init_node.compile(context)
  end
  super(context)
end

#compile_init(context) ⇒ Object



1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
# File 'lib/ytljit/vm.rb', line 1552

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

#get_arena_addressObject



1541
1542
1543
1544
1545
# File 'lib/ytljit/vm.rb', line 1541

def get_arena_address
  ar = @@local_object_area
  # 2 means used and size
  ar.raw_address
end

#get_arena_end_addressObject



1547
1548
1549
1550
# File 'lib/ytljit/vm.rb', line 1547

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

#init_unwind_procObject



1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
# File 'lib/ytljit/vm.rb', line 1484

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



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

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:



1477
1478
1479
1480
1481
1482
# File 'lib/ytljit/vm.rb', line 1477

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

#update_after_restoreObject



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

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