Class: YTLJit::VM::Node::ThrowNode

Inherits:
BaseNode show all
Includes:
HaveChildlenMixin, MethodEndCodeGen, NodeUtil
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 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 MethodEndCodeGen

#gen_method_epilogue

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #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, state, exceptobj) ⇒ ThrowNode

Returns a new instance of ThrowNode.



2265
2266
2267
2268
2269
# File 'lib/ytljit/vm.rb', line 2265

def initialize(parent, state, exceptobj)
  super(parent)
  @state = state
  @exception_object = exceptobj
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



2279
2280
2281
# File 'lib/ytljit/vm.rb', line 2279

def collect_candidate_type(context)
  @exception_object.collect_candidate_type(context)
end

#collect_info(context) ⇒ Object



2275
2276
2277
# File 'lib/ytljit/vm.rb', line 2275

def collect_info(context)
  @exception_object.collect_info(context)
end

#compile(context) ⇒ Object



2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
# File 'lib/ytljit/vm.rb', line 2297

def compile(context)
  asm = context.assembler
  if @state == 0 then
    context = @exception_object.compile(context)
    
  elsif @state == 2 then # break
    context = @exception_object.compile(context)
    asm.with_retry do
      if context.ret_reg != RETR then
        asm.mov(RETR, context.ret_reg)                
      end
    end
    context.set_reg_content(RETR, context.ret_node)
    # two epilogue means block and method which is called with block
    context = gen_method_epilogue(context)
    # instead of gen_method_epilogue because may need to ensure proc.
    context = compile_unwind(context)
    asm.with_retry do
      asm.ret
    end

  elsif @state == 1 then # return
    if context.ret_reg != RETR then
      asm.mov(RETR, context.ret_reg)                
    end
    context.set_reg_content(RETR, context.ret_node)
    tnode = search_frame_info
    finfo = tnode
    depth = 0
    while finfo.parent.is_a?(BlockTopNode)
      finfo = finfo.previous_frame
      # two epilogue means block and method which is called with block
      context = gen_method_epilogue(context)
      context = compile_unwind(context)
    end
    context = compile_unwind(context)
    asm.with_retry do
      asm.ret
    end
  end
  context
end

#compile_unwind(context) ⇒ Object



2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
# File 'lib/ytljit/vm.rb', line 2286

def compile_unwind(context)
  asm = context.assembler
  handoff = OpIndirect.new(BPR, AsmType::MACHINE_WORD.size * 2)
  ensureoff = OpIndirect.new(TMPR, 0)
  asm.with_retry do
    asm.mov(TMPR, handoff)
    asm.call(ensureoff)
  end
  gen_method_epilogue(context)
end

#gen_unwind(context) ⇒ Object



2283
2284
# File 'lib/ytljit/vm.rb', line 2283

def gen_unwind(context)
end

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

Yields:

  • (@exception_object)


2271
2272
2273
# File 'lib/ytljit/vm.rb', line 2271

def traverse_childlen
  yield @exception_object
end