Class: YTLJit::VM::Node::SendNewNode

Inherits:
SendNode show all
Includes:
UnboxedArrayUtil
Defined in:
lib/ytljit/vm_sendnode.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 inherited from SendNode

#arguments, #class_top, #current_exception_table, #frame_info, #func, #modified_instance_var, #modified_local_var, #next_node, #opt_flag, #result_cache, #seq_no, #yield_signature_cache

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 UnboxedArrayUtil

#compile_array_unboxed, #gen_ref_element, #gen_set_element

Methods included from UnboxedObjectUtil

#compile_object_unboxed

Methods inherited from SendNode

add_special_send_node, #check_signature_changed, #collect_candidate_type, #collect_candidate_type_block, #collect_info, #fill_result_cache, #get_constant_value, get_macro_tab, #get_send_method_node, get_user_defined_method_tab, #inherit_from_callee, macro_expand, make_send_node, node, #search_signature, #traverse_node

Methods included from SendUtil

#compile_c_fixarg, #compile_c_fixarg_raw, #compile_c_vararg, #compile_ytl, #gen_eval_self, #signature

Methods included from NodeUtil

#search_class_top, #search_end, #search_frame_info, #search_top

Methods included from SendNodeCodeGen

#gen_make_argv

Methods included from CommonCodeGen

#dump_context, #gen_alloca, #gen_call, #gen_save_thepr

Methods included from OptFlagOp

#is_args_blockarg, #is_args_splat, #is_fcall, #is_opt_send, #is_super, #is_tailcall, #is_tailrecursion, #is_vcall

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #add_element_node_backward_aux, #collect_candidate_type, #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, #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, func, arguments, op_flag, seqno) ⇒ SendNewNode

Returns a new instance of SendNewNode.



842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/ytljit/vm_sendnode.rb', line 842

def initialize(parent, func, arguments, op_flag, seqno)
  super
  allocfunc = MethodSelectNode.new(self, :allocate)
  alloc = SendNode.make_send_node(self, allocfunc, 
                                  arguments[0, 3], 0, seqno)
  allocfunc.set_reciever(alloc)
  initfunc = MethodSelectNode.new(self, :initialize)
  initarg = arguments.dup
  initarg[2] = alloc
  init = SendNode.make_send_node(self, initfunc, 
                                 initarg, op_flag, seqno)
  initfunc.set_reciever(init)
  alloc.parent = init
  @initmethod = init
  @allocmethod = alloc
end

Instance Method Details

#collect_candidate_type_regident(context, slf) ⇒ Object



874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/ytljit/vm_sendnode.rb', line 874

def collect_candidate_type_regident(context, slf)
  slfnode = @arguments[2]
  cursig = context.to_signature

  if slf.ruby_type.is_a?(Class) then
    set_escape_node(@parent.is_escape)
    @allocmethod.set_escape_node(@is_escape)
    @initmethod.type = nil
    context = @initmethod.collect_candidate_type(context)
    same_type(self, @allocmethod, cursig, cursig, context)
    context
  else
    super
  end
end

#compile(context) ⇒ Object



918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'lib/ytljit/vm_sendnode.rb', line 918

def compile(context)
  rtype = @arguments[2].decide_type_once(context.to_signature)
  if context.options[:insert_signature_comment] then
    lineno = debug_info[3]
    fname = debug_info[0]
    context.comment[fname] ||= {}
    context.comment[fname][lineno] ||= []
    ent = []
    ent.push 2
    ent.push is_escape
    ent.push rtype
    context.comment[fname][lineno].push ent
  end

  rrtype = rtype.ruby_type
  if rrtype.is_a?(Class) then
    ctype = decide_type_once(context.to_signature)
    crtype = ctype.ruby_type
    if !ctype.boxed and 
        crtype == Range then
      return compile_range(context)
      
    elsif crtype == Array and
        !ctype.boxed and 
        @is_escape != :global_export then
      return compile_array_unboxed(context)

    elsif @initmethod.func.calling_convention(context) then
      context = @initmethod.compile(context)

    else
      # initialize method not defined
      context = @allocmethod.compile(context)
    end
    context.ret_node = self
    @body.compile(context)
  else
    super
  end
end

#compile_range(context) ⇒ Object



890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'lib/ytljit/vm_sendnode.rb', line 890

def compile_range(context)
  context = gen_alloca(context, 3)
  asm = context.assembler
  breg = context.ret_reg
  
  off = 0
  sig = context.to_signature
  [3, 4, 5].each do |no|
    context = @arguments[no].compile(context)
    rtype = @arguments[no].decide_type_once(sig)
    context = rtype.gen_unboxing(context)
    dst = OpIndirect.new(breg, off)
    asm.with_retry do
      if context.ret_reg.is_a?(OpRegistor) then
        asm.mov(dst, context.ret_reg)
      else
        asm.mov(TMPR, context.ret_reg)
        asm.mov(dst, TMPR)
      end
    end
    off = off + AsmType::MACHINE_WORD.size
  end

  context.ret_reg = breg
  context.ret_node = self
  context
end

#debug_info=(val) ⇒ Object



859
860
861
862
863
# File 'lib/ytljit/vm_sendnode.rb', line 859

def debug_info=(val)
  @initmethod.debug_info = val
  @allocmethod.debug_info = val
  @debug_info = val
end

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

Yields:



865
866
867
868
869
870
871
872
# File 'lib/ytljit/vm_sendnode.rb', line 865

def traverse_childlen
  @arguments.each do |arg|
    yield arg
  end
  yield @func
  yield @initmethod
  yield @body
end