|
|
@ -185,11 +185,7 @@ public class TransformExceptionHandlers { |
|
|
|
* @param ret the ReturnBlock. |
|
|
|
* @param ret the ReturnBlock. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void removeReturnLocal(ReturnBlock ret) { |
|
|
|
private void removeReturnLocal(ReturnBlock ret) { |
|
|
|
if (ret.outer == null |
|
|
|
StructuredBlock pred = getPredecessor(ret); |
|
|
|
|| !(ret.outer instanceof SequentialBlock)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StructuredBlock pred = ret.outer.getSubBlocks()[0]; |
|
|
|
|
|
|
|
if (!(pred instanceof InstructionBlock)) |
|
|
|
if (!(pred instanceof InstructionBlock)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
Expression instr = ((InstructionBlock) pred).getInstruction(); |
|
|
|
Expression instr = ((InstructionBlock) pred).getInstruction(); |
|
|
@ -208,15 +204,13 @@ public class TransformExceptionHandlers { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Remove the JSR's jumping to the specified subRoutine. It |
|
|
|
* Remove the wrongly placed JSRs jumping to the specified |
|
|
|
* is checked if the next block is a leaving instruction, and |
|
|
|
* subRoutine. The right JSRs are already removed, but we have to |
|
|
|
* otherwise the JsrBlock is not removed (to give the user a |
|
|
|
* replace the wrong ones with a warning. |
|
|
|
* hint that something went wrong). This will also remove the |
|
|
|
|
|
|
|
* local javac generates for returns. |
|
|
|
|
|
|
|
* @param tryFlow the FlowBLock of the try block. |
|
|
|
* @param tryFlow the FlowBLock of the try block. |
|
|
|
* @param subRoutine the FlowBlock of the sub routine. |
|
|
|
* @param subRoutine the FlowBlock of the sub routine. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void removeJSR(FlowBlock tryFlow, StructuredBlock catchBlock, |
|
|
|
private void removeBadJSR(FlowBlock tryFlow, StructuredBlock catchBlock, |
|
|
|
FlowBlock subRoutine) { |
|
|
|
FlowBlock subRoutine) { |
|
|
|
Jump nextJump; |
|
|
|
Jump nextJump; |
|
|
|
for (Jump jumps = tryFlow.getJumps(subRoutine); |
|
|
|
for (Jump jumps = tryFlow.getJumps(subRoutine); |
|
|
@ -230,105 +224,130 @@ public class TransformExceptionHandlers { |
|
|
|
/* This is the mandatory jsr in the catch block */ |
|
|
|
/* This is the mandatory jsr in the catch block */ |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (prev.outer.getNextFlowBlock() != null) { |
|
|
|
/* We have a JSR to the subroutine, which is badly placed. |
|
|
|
/* The jsr is directly before a jump, okay. */ |
|
|
|
* We complain here. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
DescriptionBlock msg |
|
|
|
|
|
|
|
= new DescriptionBlock("ERROR: JSR FINALLY BLOCK!"); |
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
prev.removeJump(); |
|
|
|
prev.removeJump(); |
|
|
|
prev.outer.removeBlock(); |
|
|
|
msg.replace(prev.outer); |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
} |
|
|
|
/* We have a jump to the subroutine, that is wrong. |
|
|
|
if (prev.outer.outer instanceof SequentialBlock |
|
|
|
* We complain here. |
|
|
|
&& prev.outer.outer.getSubBlocks()[0] == prev.outer) { |
|
|
|
*/ |
|
|
|
SequentialBlock seq = (SequentialBlock) prev.outer.outer; |
|
|
|
DescriptionBlock msg |
|
|
|
if (seq.subBlocks[1] instanceof JsrBlock |
|
|
|
= new DescriptionBlock("ERROR: GOTO FINALLY BLOCK!"); |
|
|
|
|| (seq.subBlocks[1] instanceof SequentialBlock |
|
|
|
|
|
|
|
&& seq.subBlocks[1].getSubBlocks()[0] |
|
|
|
|
|
|
|
instanceof JsrBlock)) { |
|
|
|
|
|
|
|
/* The jsr is followed by a jsr, okay. */ |
|
|
|
|
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
prev.removeJump(); |
|
|
|
prev.removeJump(); |
|
|
|
prev.outer.removeBlock(); |
|
|
|
prev.appendBlock(msg); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (seq.subBlocks[1] instanceof ReturnBlock |
|
|
|
|
|
|
|
&& !(seq.subBlocks[1] instanceof ThrowBlock)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The jsr is followed by a return, okay. */ |
|
|
|
private static StructuredBlock getPredecessor(StructuredBlock stmt) |
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
{ |
|
|
|
prev.removeJump(); |
|
|
|
if (stmt.outer instanceof SequentialBlock) { |
|
|
|
ReturnBlock ret = (ReturnBlock) seq.subBlocks[1]; |
|
|
|
SequentialBlock seq = (SequentialBlock) stmt.outer; |
|
|
|
prev.outer.removeBlock(); |
|
|
|
if (seq.subBlocks[1] == stmt) |
|
|
|
|
|
|
|
return seq.subBlocks[0]; |
|
|
|
|
|
|
|
else if (seq.outer instanceof SequentialBlock) |
|
|
|
|
|
|
|
return seq.outer.getSubBlocks()[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
removeReturnLocal(ret); |
|
|
|
/** |
|
|
|
continue; |
|
|
|
* Gets the slot of the monitorexit instruction instr in the |
|
|
|
|
|
|
|
* stmt, or -1 if stmt isn't a InstructionBlock with a |
|
|
|
|
|
|
|
* monitorexit instruction. |
|
|
|
|
|
|
|
* @param stmt the stmt, may be null. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static int getMonitorExitSlot(StructuredBlock stmt) { |
|
|
|
|
|
|
|
if (stmt instanceof InstructionBlock) { |
|
|
|
|
|
|
|
Expression instr = ((InstructionBlock) stmt).getInstruction(); |
|
|
|
|
|
|
|
if (instr instanceof MonitorExitOperator) { |
|
|
|
|
|
|
|
MonitorExitOperator monExit = (MonitorExitOperator)instr; |
|
|
|
|
|
|
|
if (monExit.getFreeOperandCount() == 0 |
|
|
|
|
|
|
|
&& (monExit.getSubExpressions()[0] |
|
|
|
|
|
|
|
instanceof LocalLoadOperator)) |
|
|
|
|
|
|
|
return ((LocalLoadOperator) monExit.getSubExpressions()[0]) |
|
|
|
|
|
|
|
.getLocalInfo().getSlot(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isMonitorExitSubRoutine(FlowBlock subRoutine, |
|
|
|
|
|
|
|
LocalInfo local) { |
|
|
|
|
|
|
|
if (transformSubRoutine(subRoutine.block) |
|
|
|
|
|
|
|
&& getMonitorExitSlot(subRoutine.block) == local.getSlot()) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
/* Now we have a jump to the subroutine, that is wrong. |
|
|
|
|
|
|
|
* We complain here. |
|
|
|
private static StructuredBlock skipFinExitChain(StructuredBlock block) |
|
|
|
*/ |
|
|
|
{ |
|
|
|
DescriptionBlock msg |
|
|
|
StructuredBlock pred, result; |
|
|
|
= new DescriptionBlock("ERROR: GOTO FINALLY BLOCK!"); |
|
|
|
if (block instanceof ReturnBlock) |
|
|
|
tryFlow.removeSuccessor(jumps); |
|
|
|
pred = getPredecessor(block); |
|
|
|
prev.removeJump(); |
|
|
|
else |
|
|
|
prev.appendBlock(msg); |
|
|
|
pred = block; |
|
|
|
|
|
|
|
result = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (pred instanceof JsrBlock |
|
|
|
|
|
|
|
|| getMonitorExitSlot(pred) >= 0) { |
|
|
|
|
|
|
|
result = pred; |
|
|
|
|
|
|
|
pred = getPredecessor(pred); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void checkAndRemoveJSR(FlowBlock tryFlow, |
|
|
|
|
|
|
|
|
|
|
|
private void checkAndRemoveJSR(FlowBlock tryFlow, |
|
|
|
StructuredBlock catchBlock, |
|
|
|
StructuredBlock catchBlock, |
|
|
|
FlowBlock subRoutine, |
|
|
|
FlowBlock subRoutine, |
|
|
|
int startOutExit, int endOutExit) { |
|
|
|
int startOutExit, int endOutExit) { |
|
|
|
boolean foundSub = false; |
|
|
|
|
|
|
|
Iterator iter = tryFlow.getSuccessors().iterator(); |
|
|
|
Iterator iter = tryFlow.getSuccessors().iterator(); |
|
|
|
dest_loop: |
|
|
|
dest_loop: |
|
|
|
while (iter.hasNext()) { |
|
|
|
while (iter.hasNext()) { |
|
|
|
FlowBlock dest = (FlowBlock) iter.next(); |
|
|
|
FlowBlock dest = (FlowBlock) iter.next(); |
|
|
|
if (dest == subRoutine) { |
|
|
|
if (dest == subRoutine) |
|
|
|
foundSub = true; |
|
|
|
|
|
|
|
continue dest_loop; |
|
|
|
continue dest_loop; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isFirstJump = true; |
|
|
|
boolean isFirstJump = true; |
|
|
|
for (Jump jumps = tryFlow.getJumps(dest); |
|
|
|
for (Jump jumps = tryFlow.getJumps(dest); |
|
|
|
jumps != null; jumps = jumps.next, isFirstJump = false) { |
|
|
|
jumps != null; jumps = jumps.next, isFirstJump = false) { |
|
|
|
|
|
|
|
|
|
|
|
StructuredBlock prev = jumps.prev; |
|
|
|
StructuredBlock prev = jumps.prev; |
|
|
|
if (prev instanceof JsrBlock) { |
|
|
|
|
|
|
|
/* The jump is directly preceeded by a jsr. |
|
|
|
|
|
|
|
* Everything okay. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prev instanceof EmptyBlock |
|
|
|
if (prev instanceof EmptyBlock |
|
|
|
&& prev.outer instanceof JsrBlock) { |
|
|
|
&& prev.outer instanceof JsrBlock) { |
|
|
|
/* If jump is a jsr check the outer |
|
|
|
/* This jump is really a jsr, since it doesn't |
|
|
|
* block instead. |
|
|
|
* leave the block forever, we can ignore it. |
|
|
|
*/ |
|
|
|
|
|
|
|
prev = prev.outer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ((prev instanceof ReturnBlock |
|
|
|
|
|
|
|
|| prev instanceof JsrBlock) |
|
|
|
|
|
|
|
&& prev.outer instanceof SequentialBlock) { |
|
|
|
|
|
|
|
SequentialBlock seq = (SequentialBlock) prev.outer; |
|
|
|
|
|
|
|
if (seq.subBlocks[1] == prev |
|
|
|
|
|
|
|
&& (seq.subBlocks[0] instanceof JsrBlock)) { |
|
|
|
|
|
|
|
/* The jump is preceeded by another jsr, okay. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (seq.subBlocks[0] == prev |
|
|
|
|
|
|
|
&& seq.outer instanceof SequentialBlock |
|
|
|
StructuredBlock pred = skipFinExitChain(prev); |
|
|
|
&& (seq.outer.getSubBlocks()[0] instanceof JsrBlock)) { |
|
|
|
if (pred instanceof JsrBlock) { |
|
|
|
/* Again the jump is preceeded by another jsr, okay. |
|
|
|
StructuredBlock jsrInner = ((JsrBlock) pred).innerBlock; |
|
|
|
|
|
|
|
if (jsrInner instanceof EmptyBlock |
|
|
|
|
|
|
|
&& jsrInner.jump != null |
|
|
|
|
|
|
|
&& jsrInner.jump.destination == subRoutine) { |
|
|
|
|
|
|
|
/* The jump is preceeded by the right jsr. Remove |
|
|
|
|
|
|
|
* the jsr. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
tryFlow.removeSuccessor(jsrInner.jump); |
|
|
|
|
|
|
|
jsrInner.removeJump(); |
|
|
|
|
|
|
|
pred.removeBlock(); |
|
|
|
|
|
|
|
if (prev instanceof ReturnBlock) |
|
|
|
|
|
|
|
removeReturnLocal((ReturnBlock) prev); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isFirstJump) { |
|
|
|
if (pred == null && isFirstJump) { |
|
|
|
/* Now we have a jump that is not preceded by the |
|
|
|
/* Now we have a jump that is not preceded by any |
|
|
|
* jsr. There's a last chance: the jump jumps |
|
|
|
* jsr. There's a last chance: the jump jumps |
|
|
|
* directly to a correct jsr instruction, which |
|
|
|
* directly to a correct jsr instruction, which |
|
|
|
* lies outside the try/catch block. |
|
|
|
* lies outside the try/catch block. |
|
|
@ -359,42 +378,18 @@ public class TransformExceptionHandlers { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
DescriptionBlock msg |
|
|
|
DescriptionBlock msg |
|
|
|
= new DescriptionBlock("ERROR: NO JSR TO FINALLY"); |
|
|
|
= new DescriptionBlock("ERROR: NO JSR TO FINALLY"); |
|
|
|
|
|
|
|
if (pred != null) |
|
|
|
|
|
|
|
pred.prependBlock(msg); |
|
|
|
|
|
|
|
else { |
|
|
|
prev.appendBlock(msg); |
|
|
|
prev.appendBlock(msg); |
|
|
|
msg.moveJump(jumps); |
|
|
|
msg.moveJump(prev.jump); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (foundSub) |
|
|
|
|
|
|
|
removeJSR(tryFlow, catchBlock, subRoutine); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static boolean isMonitorExit(Expression instr, LocalInfo local) { |
|
|
|
|
|
|
|
if (instr instanceof MonitorExitOperator) { |
|
|
|
|
|
|
|
MonitorExitOperator monExit = (MonitorExitOperator)instr; |
|
|
|
|
|
|
|
if (monExit.getFreeOperandCount() == 0 |
|
|
|
|
|
|
|
&& monExit.getSubExpressions()[0] instanceof LocalLoadOperator |
|
|
|
|
|
|
|
&& (((LocalLoadOperator) monExit.getSubExpressions()[0]) |
|
|
|
|
|
|
|
.getLocalInfo().getSlot() == local.getSlot())) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
removeBadJSR(tryFlow, catchBlock, subRoutine); |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean isMonitorExitSubRoutine(FlowBlock subRoutine, LocalInfo local) { |
|
|
|
private void checkAndRemoveMonitorExit(FlowBlock tryFlow, |
|
|
|
if (transformSubRoutine(subRoutine.block)) { |
|
|
|
|
|
|
|
if (subRoutine.block instanceof InstructionBlock) { |
|
|
|
|
|
|
|
Expression instr = |
|
|
|
|
|
|
|
((InstructionBlock)subRoutine.block) |
|
|
|
|
|
|
|
.getInstruction(); |
|
|
|
|
|
|
|
if (isMonitorExit(instr, local)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkAndRemoveMonitorExit(FlowBlock tryFlow, |
|
|
|
|
|
|
|
StructuredBlock catchBlock, |
|
|
|
StructuredBlock catchBlock, |
|
|
|
LocalInfo local, |
|
|
|
LocalInfo local, |
|
|
|
int start, int end) { |
|
|
|
int start, int end) { |
|
|
@ -408,85 +403,51 @@ public class TransformExceptionHandlers { |
|
|
|
jumps != null; jumps = jumps.next, isFirstJump = false) { |
|
|
|
jumps != null; jumps = jumps.next, isFirstJump = false) { |
|
|
|
|
|
|
|
|
|
|
|
StructuredBlock prev = jumps.prev; |
|
|
|
StructuredBlock prev = jumps.prev; |
|
|
|
|
|
|
|
|
|
|
|
if (prev instanceof JsrBlock) { |
|
|
|
|
|
|
|
/* The jump is directly preceeded by a jsr. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (prev instanceof EmptyBlock |
|
|
|
if (prev instanceof EmptyBlock |
|
|
|
&& prev.outer instanceof JsrBlock) { |
|
|
|
&& prev.outer instanceof JsrBlock) { |
|
|
|
/* If jump is a jsr check the outer |
|
|
|
/* This jump is really a jsr, since it doesn't |
|
|
|
* block instead. |
|
|
|
* leave the block forever, we can ignore it. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
prev = prev.outer; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
StructuredBlock pred = skipFinExitChain(prev); |
|
|
|
|
|
|
|
if (pred instanceof JsrBlock) { |
|
|
|
|
|
|
|
StructuredBlock jsrInner = ((JsrBlock) pred).innerBlock; |
|
|
|
|
|
|
|
if (jsrInner instanceof EmptyBlock |
|
|
|
|
|
|
|
&& jsrInner.jump != null) { |
|
|
|
|
|
|
|
FlowBlock dest = jsrInner.jump.destination; |
|
|
|
|
|
|
|
|
|
|
|
/* If the block is a jsr or a return block, check if |
|
|
|
if (subRoutine == null |
|
|
|
* it is preceeded by another jsr. |
|
|
|
&& dest.getBlockNr() >= start |
|
|
|
*/ |
|
|
|
&& dest.getNextBlockNr() <= end) { |
|
|
|
if ((prev instanceof JsrBlock |
|
|
|
dest.analyze(start, end); |
|
|
|
|| prev instanceof ReturnBlock) |
|
|
|
if (isMonitorExitSubRoutine(dest, local)) |
|
|
|
&& prev.outer instanceof SequentialBlock) { |
|
|
|
subRoutine = dest; |
|
|
|
SequentialBlock seq = (SequentialBlock) prev.outer; |
|
|
|
} |
|
|
|
StructuredBlock pred = null; |
|
|
|
|
|
|
|
if (seq.subBlocks[1] == prev) |
|
|
|
|
|
|
|
pred = seq.subBlocks[0]; |
|
|
|
|
|
|
|
else if (seq.outer instanceof SequentialBlock) |
|
|
|
|
|
|
|
pred = seq.outer.getSubBlocks()[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pred != null) { |
|
|
|
if (dest == subRoutine) { |
|
|
|
if (pred instanceof JsrBlock) |
|
|
|
/* The jump is preceeded by the right jsr. Remove |
|
|
|
/* The jump is preceeded by another jsr, okay. |
|
|
|
* the jsr. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
continue; |
|
|
|
tryFlow.removeSuccessor(jsrInner.jump); |
|
|
|
|
|
|
|
jsrInner.removeJump(); |
|
|
|
if (pred instanceof InstructionBlock) { |
|
|
|
|
|
|
|
Expression instr = |
|
|
|
|
|
|
|
((InstructionBlock)pred).getInstruction(); |
|
|
|
|
|
|
|
if (isMonitorExit(instr, local)) { |
|
|
|
|
|
|
|
pred.removeBlock(); |
|
|
|
pred.removeBlock(); |
|
|
|
if (prev instanceof ReturnBlock) |
|
|
|
if (prev instanceof ReturnBlock) |
|
|
|
removeReturnLocal((ReturnBlock) prev); |
|
|
|
removeReturnLocal((ReturnBlock) prev); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (getMonitorExitSlot(pred) == local.getSlot()) { |
|
|
|
} |
|
|
|
/* The jump is preceeded by the right monitor |
|
|
|
|
|
|
|
* exit instruction. |
|
|
|
if (prev instanceof InstructionBlock |
|
|
|
|
|
|
|
&& isMonitorExit(((InstructionBlock)prev).instr, local)) { |
|
|
|
|
|
|
|
/* This is probably the last expression in the |
|
|
|
|
|
|
|
* synchronized block, and has the right monitor exit |
|
|
|
|
|
|
|
* attached. Remove this block. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
prev.removeBlock(); |
|
|
|
pred.removeBlock(); |
|
|
|
|
|
|
|
if (prev instanceof ReturnBlock) |
|
|
|
|
|
|
|
removeReturnLocal((ReturnBlock) prev); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isFirstJump) { |
|
|
|
if (pred == null && isFirstJump) { |
|
|
|
/* This is the first jump to that destination. |
|
|
|
|
|
|
|
* Check if the destination does the monitorExit |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The block is a jsr that is not preceeded by |
|
|
|
|
|
|
|
* another jsr. This must be the monitorexit |
|
|
|
|
|
|
|
* subroutine. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (prev instanceof JsrBlock) { |
|
|
|
|
|
|
|
if (subRoutine == null |
|
|
|
|
|
|
|
&& successor.getBlockNr() >= start |
|
|
|
|
|
|
|
&& successor.getNextBlockNr() <= end) { |
|
|
|
|
|
|
|
successor.analyze(start, end); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isMonitorExitSubRoutine(successor, local)) |
|
|
|
|
|
|
|
subRoutine = successor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (subRoutine == successor) |
|
|
|
|
|
|
|
continue dest_loop; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Now we have a jump that is not preceded by a |
|
|
|
/* Now we have a jump that is not preceded by a |
|
|
|
* monitorexit. There's a last chance: the jump |
|
|
|
* monitorexit. There's a last chance: the jump |
|
|
|
* jumps directly to the correct monitorexit |
|
|
|
* jumps directly to the correct monitorexit |
|
|
@ -514,20 +475,18 @@ public class TransformExceptionHandlers { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (subRoutine == dest) { |
|
|
|
if (subRoutine == dest) { |
|
|
|
|
|
|
|
successor.removeSuccessor(jsrInner.jump); |
|
|
|
|
|
|
|
jsrInner.removeJump(); |
|
|
|
sb.removeBlock(); |
|
|
|
sb.removeBlock(); |
|
|
|
continue dest_loop; |
|
|
|
continue dest_loop; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (sb instanceof InstructionBlock) { |
|
|
|
if (getMonitorExitSlot(sb) == local.getSlot()) { |
|
|
|
Expression instr = ((InstructionBlock)sb) |
|
|
|
|
|
|
|
.getInstruction(); |
|
|
|
|
|
|
|
if (isMonitorExit(instr, local)) { |
|
|
|
|
|
|
|
sb.removeBlock(); |
|
|
|
sb.removeBlock(); |
|
|
|
continue dest_loop; |
|
|
|
continue dest_loop; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Complain! |
|
|
|
/* Complain! |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -539,7 +498,7 @@ public class TransformExceptionHandlers { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (subRoutine != null) { |
|
|
|
if (subRoutine != null) { |
|
|
|
removeJSR(tryFlow, catchBlock, subRoutine); |
|
|
|
removeBadJSR(tryFlow, catchBlock, subRoutine); |
|
|
|
tryFlow.mergeBlockNr(subRoutine); |
|
|
|
tryFlow.mergeBlockNr(subRoutine); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|