Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Finally block adjustments.

  • Loading branch information...
commit c6f37aa676997f5a2263ea72b8e9be147dae34a4 1 parent 598e77b
Peter Zotov authored
23 lib/furnace-avm2/transform/cfg_build.rb
@@ -21,11 +21,17 @@ def transform(code, body)
21 21
22 22 exc_block.target_labels << exc.target_offset
23 23
24   - exc_block.cti.children <<
25   - AST::Node.new(:catch,
26   - [ (exc.exception.to_astlet if exc.exception),
27   - exc.variable.to_astlet,
28   - exc.target_offset ])
  24 + if exc.variable
  25 + exc_block.cti.children <<
  26 + AST::Node.new(:catch,
  27 + [ (exc.exception.to_astlet if exc.exception),
  28 + exc.variable.to_astlet,
  29 + exc.target_offset ])
  30 + else
  31 + exc_block.cti.children <<
  32 + AST::Node.new(:finally,
  33 + [ exc.target_offset ])
  34 + end
29 35 end
30 36
31 37 # Handle nested exception handling blocks.
@@ -84,8 +90,11 @@ def transform(code, body)
84 90 next_offset = next_opcode.offset if next_opcode
85 91
86 92 case opcode
87   - when ABC::FunctionReturnOpcode, ABC::AS3Throw
88   - cutoff(nil, [nil])
  93 + when ABC::FunctionReturnOpcode
  94 + cutoff(nil, [ nil ])
  95 +
  96 + when ABC::AS3Throw
  97 + cutoff(opcode, [ ])
89 98
90 99 when ABC::AS3Jump
91 100 @jumps.add(opcode.target_offset)
10 lib/furnace-avm2/transform/cfg_reduce.rb
@@ -425,6 +425,12 @@ def extended_block(block, stopgap=nil, loop_stack=[], nesting=0, upper_exc=nil,
425 425 end
426 426
427 427 block = out_root
  428 + elsif block.cti.type == :throw
  429 + log nesting, "ends with throw"
  430 +
  431 + append_instructions(block, current_nodes, true)
  432 +
  433 + block = nil
428 434 else
429 435 log nesting, "is a conditional"
430 436
@@ -664,9 +670,9 @@ def check_nonlocal_loop(loop_stack, block)
664 670 end
665 671 end
666 672
667   - def append_instructions(block, nodes)
  673 + def append_instructions(block, nodes, cti=false)
668 674 block.insns.each do |insn|
669   - next if insn.equal? block.cti
  675 + next if insn.equal?(block.cti) && !cti
670 676 nodes << insn
671 677 end
672 678 end
4 lib/furnace-avm2/transform/liveness_analysis.rb
@@ -22,7 +22,9 @@ def transform(cfg)
22 22 block = worklist.first
23 23 worklist.delete block
24 24
25   - if loops.include? block
  25 + if block.cti && block.cti.type == :throw
  26 + dead_ends.add block
  27 + elsif loops.include? block
26 28 back_edged, sources = block.sources.partition do |source|
27 29 dom[source].include? block
28 30 end

0 comments on commit c6f37aa

Please sign in to comment.
Something went wrong with that request. Please try again.