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

Returns a new instance of ThrowNode.



2504
2505
2506
2507
2508
# File 'lib/ytljit/vm.rb', line 2504

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

Instance Method Details

#collect_candidate_type(context) ⇒ Object



2518
2519
2520
# File 'lib/ytljit/vm.rb', line 2518

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

#collect_info(context) ⇒ Object



2514
2515
2516
# File 'lib/ytljit/vm.rb', line 2514

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

#compile(context) ⇒ Object



2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
# File 'lib/ytljit/vm.rb', line 2538

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)
    if context.ret_reg != TMPR then
      asm.with_retry do
        asm.mov(TMPR, 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
    context = @exception_object.compile(context)
    if context.ret_reg != TMPR then
      asm.with_retry do
        asm.mov(TMPR, context.ret_reg)                
      end
    end
    context.set_reg_content(RETR, context.ret_node)
    tnode = search_frame_info
    finfo = tnode
    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



2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
# File 'lib/ytljit/vm.rb', line 2525

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.push(TMPR)
    asm.mov(TMPR, handoff)
    asm.call(ensureoff)
    asm.pop(TMPR)
  end
  gen_method_epilogue(context)
end

#gen_unwind(context) ⇒ Object



2522
2523
# File 'lib/ytljit/vm.rb', line 2522

def gen_unwind(context)
end

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

Yields:

  • (@exception_object)


2510
2511
2512
# File 'lib/ytljit/vm.rb', line 2510

def traverse_childlen
  yield @exception_object
end