Class: YTLJit::VM::Node::GlobalVarSpecialRefNode

Inherits:
GlobalVarRefNode show all
Includes:
NodeUtil, TypeListWithoutSignature, SendNodeCodeGen, UnboxedArrayUtil
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 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 SendNodeCodeGen

#gen_make_argv

Methods included from CommonCodeGen

#dump_context, #gen_alloca, #gen_call, #gen_save_thepr

Methods included from UnboxedArrayUtil

#compile_array_unboxed, #gen_ref_element, #gen_set_element

Methods included from UnboxedObjectUtil

#compile_object_unboxed

Methods included from TypeListWithoutSignature

#add_type, #set_type_list, #type_list, #type_list_initvar

Methods included from NodeUtil

#search_class_top, #search_end, #search_frame_info, #search_top

Methods inherited from GlobalVarRefNode

#collect_info, instance

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #add_element_node_backward_aux, #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, name) ⇒ GlobalVarSpecialRefNode

Returns a new instance of GlobalVarSpecialRefNode.



3899
3900
3901
3902
3903
3904
# File 'lib/ytljit/vm.rb', line 3899

def initialize(parent, name)
  super(parent)
  @name = name
  @assign_nodes = nil
  @offset = nil
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



3906
3907
3908
3909
3910
3911
3912
# File 'lib/ytljit/vm.rb', line 3906

def collect_candidate_type(context)
  tt = RubyType::BaseType.from_object(eval(@name.to_s))
  sig = context.to_signature
  add_type(sig, tt)
  
  context
end

#compile(context) ⇒ Object



3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
# File 'lib/ytljit/vm.rb', line 3914

def compile(context)
  asm = context.assembler
  add = lambda { 
    a = address_of("rb_global_entry")
    $symbol_table[a] = "rb_global_entry"
    a
  }
  gentry = OpVarMemAddress.new(add)

  add = lambda { 
    a = address_of("rb_gvar_get")
    $symbol_table[a] = "rb_gvar_get"
    a
  }
  gget = OpVarMemAddress.new(add)
  wsize = AsmType::MACHINE_WORD.size
  symid = ((@name.__id__ << 1) / (5 * wsize))
  asm.with_retry do
    asm.mov(FUNC_ARG[0], symid)
  end
  context = gen_save_thepr(context)
  context = gen_call(context, gentry, 1)

  asm.with_retry do
    asm.mov(FUNC_ARG[0], RETR)
  end
  context = gen_save_thepr(context)
  context = gen_call(context, gget, 1)

  context.ret_reg = RETR
  context
end