Class: YTLJit::VM::Node::LocalAssignNode

Inherits:
LocalVarRefCommonNode 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

Constants inherited from BaseNode

BaseNode::ESCAPE_LEVEL

Instance Attribute Summary

Attributes included from HaveChildlenMixin

#body

Attributes inherited from LocalVarRefCommonNode

#current_frame_info, #depth, #frame_info, #offset

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 included from NodeUtil

#search_class_top, #search_end, #search_frame_info, #search_top

Methods included from LocalVarNodeCodeGen

#gen_pursue_parent_function

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, offset, depth, val) ⇒ LocalAssignNode

Returns a new instance of LocalAssignNode.



3596
3597
3598
3599
3600
3601
3602
# File 'lib/ytljit/vm.rb', line 3596

def initialize(parent, offset, depth, val)
  super(parent, offset, depth)
  val.parent = self
  @val = val
  @var_from = nil
  @var_type_info = nil
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
# File 'lib/ytljit/vm.rb', line 3636

def collect_candidate_type(context)
  context = @val.collect_candidate_type(context)
  cursig = context.to_signature
  varsig = context.to_signature(@var_from)
  @var_type_info.reverse.each do |topnode, node|
    if node != self then
      varsig2 = context.to_signature(topnode)
      same_type(self, node, cursig, varsig2, context)
    end
  end
  same_type(self, @val, varsig, cursig, context)
#          same_type(@val, self, cursig, varsig, context)

  @body.collect_candidate_type(context)
end

#collect_info(context) ⇒ Object



3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
# File 'lib/ytljit/vm.rb', line 3609

def collect_info(context)
  context = @val.collect_info(context)
  top = @frame_info
  @depth.times do |i|
    top = top.previous_frame
  end
  @var_from = top.parent

  nodepare = nil
  if @depth > 0 then 
    nodepare = context.modified_local_var.last[-@depth - 1]
  end
  if nodepare then
    nodepare = nodepare[@offset]
  end
  if nodepare then
    nodepare.push [@var_from, self]
  else
    nodepare = [[@var_from, self]]
  end
    
  context.modified_local_var.last[-@depth - 1][@offset] = nodepare
  @var_type_info = nodepare

  @body.collect_info(context)
end

#compile(context) ⇒ Object



3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
# File 'lib/ytljit/vm.rb', line 3652

def compile(context)
  context = super(context)
  context = @val.compile(context)

  cursig = context.to_signature
  varsig = context.to_signature(-@depth - 1)

  vartype = decide_type_once(varsig)
  valtype = @val.decide_type_once(cursig)

  asm = context.assembler
  # type conversion
  if vartype.ruby_type == Float and
      valtype.ruby_type == Fixnum then
    context = valtype.gen_unboxing(context)
    asm.with_retry do
      asm.mov(TMPR, context.ret_reg)
      asm.cvtsi2sd(XMM0, TMPR)
    end
    context.ret_reg = XMM0
    valtype = valtype.to_unbox
  end

  if vartype.boxed then
    context = valtype.gen_boxing(context)
  else
    context = valtype.gen_unboxing(context)
  end

  valr = context.ret_reg
  valn = context.ret_node
  context = gen_pursue_parent_function(context, @depth)
  base = context.ret_reg
  offarg = @current_frame_info.offset_arg(@offset, base)

  if valr.is_a?(OpRegistor) or 
      (valr.is_a?(OpImmidiate) and !valr.is_a?(OpImmidiate64)) then
    asm.with_retry do
      asm.mov(offarg, valr)
    end

  else
    asm.with_retry do
      asm.mov(TMPR, valr)
      asm.mov(offarg, TMPR)
    end
  end

  tmpctx = context
  @depth.times { tmpctx = tmpctx.prev_context}
  tmpctx.set_reg_content(offarg, @val)

  context.ret_reg = TMPR
  if base == TMPR2 then
    context.end_using_reg(base)
  end

  @body.compile(context)
end

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

Yields:

  • (@val)


3604
3605
3606
3607
# File 'lib/ytljit/vm.rb', line 3604

def traverse_childlen
  yield @val
  yield @body
end