Class: YTLJit::VM::Node::LocalLabel

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

Constant Summary

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, #element_node_list, #id, #parent, #ti_observee, #ti_observer, #type

Instance Method Summary collapse

Methods inherited from BaseNode

#add_element_node, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #merge_type, #same_type, #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, name) ⇒ LocalLabel

Returns a new instance of LocalLabel.



1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/ytljit/vm.rb', line 1460

def initialize(parent, name)
  super(parent)
  @name = name
  @come_from = {}
  @come_from_val = []
  @code_space = CodeSpace.new
  @value_node = PhiNode.new(self)
  @modified_local_var_list = []
end

Instance Attribute Details

#come_fromObject (readonly)

Returns the value of attribute come_from.



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

def come_from
  @come_from
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#value_nodeObject (readonly)

Returns the value of attribute value_node.



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

def value_node
  @value_node
end

Instance Method Details

#collect_candidate_type(context, sender = nil) ⇒ Object



1550
1551
1552
1553
1554
1555
1556
# File 'lib/ytljit/vm.rb', line 1550

def collect_candidate_type(context, sender = nil)
  if @come_from.keys[0] == sender then
    @body.collect_candidate_type(context)
  else
    context
  end
end

#collect_info(context) ⇒ Object



1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
# File 'lib/ytljit/vm.rb', line 1495

def collect_info(context)
  if @modified_local_var_list.size == 0 then
    # first visit
    delnode = []
    fornode = []
    @come_from.keys.each do |ele|
      if lonly_node(ele) then
        delnode.push ele
      end
    end
    delnode.each do |ele|
      @come_from.delete(ele)
    end
  end
    
  modlocvar = context.modified_local_var.last.map {|ele| ele.dup}
  @modified_local_var_list.push modlocvar
  if @modified_local_var_list.size == 1 then
    @body.collect_info(context)
  elsif @modified_local_var_list.size == @come_from.size then
    context.merge_local_var(@modified_local_var_list)
    @body.collect_info(context)
  else
    context
  end
end

#compile(context) ⇒ Object



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

def compile(context)
  context = super(context)
  @come_from_val.push context.ret_reg
  
  if @come_from_val.size == 1 then
    @body.compile(context)
  else
    context
  end
end

#compile_block_value(context, comefrom) ⇒ Object



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

def compile_block_value(context, comefrom)
  valnode = @come_from[comefrom]
  if valnode then
    context = valnode.compile(context)
    asm = context.assembler
    if !context.ret_reg.is_a?(OpRegXMM) then
      if RETR != context.ret_reg then
        asm.with_retry do
          asm.mov(RETR, context.ret_reg)
        end
        context.set_reg_content(RETR, context.ret_node)
        context.ret_reg = RETR
      end
    end
  end

  context
end

#lonly_node(node) ⇒ Object



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

def lonly_node(node)
  while !node.is_a?(TopNode) 
    if node.is_a?(LocalLabel) then
      if node.come_from.size == 0 then
        return true
      else
        return false
      end
    end

    node = node.parent
  end

  return false
end

#traverse_block_value(comefrom, &block) ⇒ Object



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

def traverse_block_value(comefrom, &block)
  valnode = @come_from[comefrom]
  if valnode then
    yield valnode
  else
    nil
  end
end

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

Yields:



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

def traverse_childlen
  yield @value_node
  yield @body
end