Fixed: label copies should be added to all labels

This commit is contained in:
Svetlana Isakova
2014-09-05 15:45:37 +04:00
parent 976d5ab030
commit f5feb3bf33
6 changed files with 31 additions and 6 deletions
@@ -460,7 +460,7 @@ public class PseudocodeImpl implements Pseudocode {
Integer finishIndex = ((PseudocodeLabel) finishLabel).getTargetInstructionIndex();
assert finishIndex != null;
Map<Label, Label> originalToCopy = Maps.newHashMap();
Map<Label, Label> originalToCopy = Maps.newLinkedHashMap();
Multimap<Instruction, Label> originalLabelsForInstruction = HashMultimap.create();
for (PseudocodeLabel label : labels) {
Integer index = label.getTargetInstructionIndex();
@@ -472,6 +472,9 @@ public class PseudocodeImpl implements Pseudocode {
originalLabelsForInstruction.put(getJumpTarget(label), label);
}
}
for (Label label : originalToCopy.values()) {
labels.add((PseudocodeLabel) label);
}
for (int index = startIndex; index < finishIndex; index++) {
Instruction originalInstruction = mutableInstructionList.get(index);
repeatLabelsBindingForInstruction(originalInstruction, originalToCopy, originalLabelsForInstruction);
@@ -22,6 +22,7 @@ L4 [start finally]:
L5 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L3 [skipFinallyToErrorBlock]:
L6 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L3)]
r(2) -> <v1>
2 merge(try { 1 } finally { 2 }|<v0>) -> <v2>
@@ -119,6 +120,7 @@ L9 [start finally]:
L10 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L8 [skipFinallyToErrorBlock]:
L11 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L8)]
r(2) -> <v2>
2 merge(try { 1 @l{ () -> if (2 > 3) { return@l } } } finally { 2 }|<v1>) -> <v3>
@@ -363,6 +365,7 @@ L11 [start finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L10 [skipFinallyToErrorBlock]:
L13 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L10)]
r(2) -> <v10>
2 merge(try { @l while(true) { 1 if (2 > 3) { break @l } } 5 } finally { 2 }|<v9>) -> <v11>
@@ -427,6 +430,7 @@ L11 [start finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L10 [skipFinallyToErrorBlock]:
L13 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L10)]
r(2) -> <v9>
2 merge(try { @l while(true) { 1 if (2 > 3) { break @l } } } finally { 2 }|!<v8>) -> <v10>
@@ -577,6 +581,7 @@ L11 [start finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L10 [skipFinallyToErrorBlock]:
L13 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L10)]
r(2) -> <v13>
2 merge(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 } finally { 2 }|<v12>) -> <v14>
@@ -650,6 +655,7 @@ L11 [start finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L10 [skipFinallyToErrorBlock]:
L13 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L10)]
r(2) -> <v12>
2 merge(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } } finally { 2 }|!<v11>) -> <v13>
@@ -979,4 +985,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -107,6 +107,7 @@ L7 [start finally]:
L8 [finish finally]:
- 2 jmp(error) NEXT:[<ERROR>] PREV:[]
L6 [skipFinallyToErrorBlock]:
L9 [copy of L3, onExceptionToFinallyBlock]:
3 mark({ return 1 }) PREV:[jmp(L6)]
r(1) -> <v5>
ret(*|<v5>) L1 NEXT:[<END>]
@@ -190,6 +191,7 @@ L14 ['if' expression result]:
L15 [finish finally]:
- 3 jmp(error) NEXT:[<ERROR>] PREV:[]
L11 [skipFinallyToErrorBlock]:
L16 [copy of L8, onExceptionToFinallyBlock]:
4 mark({ if (cond()) return else continue }) PREV:[jmp(L11)]
mark(if (cond()) return else continue)
mark(cond())
@@ -197,7 +199,9 @@ L11 [skipFinallyToErrorBlock]:
jf(L17|<v6>) NEXT:[jmp(L6), ret L1]
ret L1 NEXT:[<END>]
- jmp(L18) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
L17 [copy of L13, else branch]:
jmp(L6) NEXT:[mark(cond())] PREV:[jf(L17|<v6>)]
L18 [copy of L14, 'if' expression result]:
- merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9> PREV:[]
- 3 merge(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue }|<v1>, <v3>, <v5>) -> <v10> PREV:[]
- 2 jmp(L2) NEXT:[mark(cond())] PREV:[]
@@ -273,12 +277,18 @@ L11 [body exit point]:
L13 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L6 [skipFinallyToErrorBlock]:
L14 [copy of L3, onExceptionToFinallyBlock]:
3 mark({ while (cond()); }) PREV:[jmp(L6)]
L15 [copy of L8, loop entry point]:
L19 [copy of L12, condition entry point]:
mark(cond()) PREV:[mark({ while (cond()); }), jmp(L15)]
call(cond(), cond) -> <v5>
mark(while (cond()))
jf(L16|<v5>) NEXT:[read (Unit), jmp(L15)]
L17 [copy of L10, body entry point]:
jmp(L15) NEXT:[mark(cond())]
L16 [copy of L9, loop exit point]:
L18 [copy of L11, body exit point]:
read (Unit) PREV:[jf(L16|<v5>)]
2 merge(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { while (cond()); }|<v0>, <v2>, <v4>) -> <v7>
L1:
@@ -330,6 +340,7 @@ L6 ['if' expression result]:
L7 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L3 [skipFinallyToErrorBlock]:
L8 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ if(list != null) { } }) PREV:[jmp(L3)]
mark(if(list != null) { })
r(list) -> <v2>
@@ -340,7 +351,9 @@ L3 [skipFinallyToErrorBlock]:
4 mark({ })
read (Unit)
3 jmp(L10) NEXT:[merge(if(list != null) { }|!<v5>) -> <v6>]
L9 [copy of L5, else branch]:
read (Unit) PREV:[jf(L9|<v4>)]
L10 [copy of L6, 'if' expression result]:
merge(if(list != null) { }|!<v5>) -> <v6> PREV:[jmp(L10), read (Unit)]
2 merge(try { doSmth() } finally { if(list != null) { } }|<v1>) -> <v7>
L1:
@@ -349,4 +362,4 @@ error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -23,6 +23,7 @@ L4 [start finally]:
L5 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L3 [skipFinallyToErrorBlock]:
L6 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ test() }) PREV:[jmp(L3)]
mark(test())
call(test(), test) -> <v0>
@@ -33,4 +34,4 @@ error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -24,6 +24,7 @@ L4 [start finally]:
L5 [finish finally]:
- 2 jmp(error) NEXT:[<ERROR>] PREV:[]
L3 [skipFinallyToErrorBlock]:
L6 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ return test() }) PREV:[jmp(L3)]
mark(test())
call(test(), test) -> <v0>
@@ -35,4 +36,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -37,6 +37,7 @@ L6 [start finally]:
L7 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L5 [skipFinallyToErrorBlock]:
L8 [copy of L3, onExceptionToFinallyBlock]:
3 mark({ test() }) PREV:[jmp(L5)]
mark(test())
call(test(), test) -> <v3>
@@ -47,4 +48,4 @@ error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================