Class: YTLJit::VM::Node::SetResultNode

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

Overview

Set result of method/block

Constant Summary

Constants inherited from BaseNode

BaseNode::ESCAPE_LEVEL

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, #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 inherited from BaseNode

#add_element_node, #add_element_node_backward, #collect_info, #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, valnode) ⇒ SetResultNode

Returns a new instance of SetResultNode.



1931
1932
1933
1934
1935
# File 'lib/ytljit/vm.rb', line 1931

def initialize(parent, valnode)
  super(parent)
  @value_node = valnode
  @class_top_node = search_class_top
end

Instance Attribute Details

#value_nodeObject (readonly)

Returns the value of attribute value_node.



1937
1938
1939
# File 'lib/ytljit/vm.rb', line 1937

def value_node
  @value_node
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
# File 'lib/ytljit/vm.rb', line 1944

def collect_candidate_type(context)
  cursig = context.to_signature
  context = @value_node.collect_candidate_type(context)
  same_type(self, @value_node, cursig, cursig, context)
  same_type(@value_node, self, cursig, cursig, context)

#          @type = nil
  rtype = decide_type_once(cursig)
  rrtype = rtype.ruby_type
  if !rtype.boxed and rrtype != Fixnum and rrtype != Float then
    set_escape_node_backward(:local_export)
  else
    set_escape_node_backward(:not_export)
  end
  @body.collect_candidate_type(context)
end

#compile(context) ⇒ Object



1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
# File 'lib/ytljit/vm.rb', line 1961

def compile(context)
  context = super(context)
  context = @value_node.compile(context)
  if context.ret_reg != RETR then
    if context.ret_reg.is_a?(OpRegXMM) then
=begin
         decide_type_once(context.to_signature)
         context = @type.gen_boxing(context)
         if context.ret_reg != RETR then
           curas = context.assembler
           curas.with_retry do
            curas.mov(RETR, context.ret_reg)
          end
           
           context.set_reg_content(RETR, context.ret_node)
         end
=end
      context.set_reg_content(context.ret_reg, context.ret_node)
    else
      curas = context.assembler
      curas.with_retry do
        curas.mov(RETR, context.ret_reg)
      end
      context.set_reg_content(RETR, context.ret_node)
      context.ret_reg = RETR
    end
  else
    context.set_reg_content(RETR, context.ret_node)
    context.ret_reg = RETR
  end

  @body.compile(context)
end

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

Yields:



1939
1940
1941
1942
# File 'lib/ytljit/vm.rb', line 1939

def traverse_childlen
  yield @value_node
  yield @body
end