Inline genFinallyBlockOrGoto
This commit is contained in:
+14
-22
@@ -1000,7 +1000,11 @@ class ExpressionCodegen(
|
|||||||
val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd)
|
val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd)
|
||||||
|
|
||||||
val tryCatchBlockEnd = Label()
|
val tryCatchBlockEnd = Label()
|
||||||
genFinallyBlockOrGoto(tryInfo, tryCatchBlockEnd, null, data)
|
if (tryInfo != null) {
|
||||||
|
data.handleBlock { genFinallyBlock(tryInfo, tryCatchBlockEnd, null, data) }
|
||||||
|
} else {
|
||||||
|
mv.goTo(tryCatchBlockEnd)
|
||||||
|
}
|
||||||
|
|
||||||
val catches = aTry.catches
|
val catches = aTry.catches
|
||||||
for (clause in catches) {
|
for (clause in catches) {
|
||||||
@@ -1023,31 +1027,27 @@ class ExpressionCodegen(
|
|||||||
index
|
index
|
||||||
)
|
)
|
||||||
|
|
||||||
genFinallyBlockOrGoto(
|
if (tryInfo != null) {
|
||||||
tryInfo,
|
data.handleBlock { genFinallyBlock(tryInfo, tryCatchBlockEnd, null, data) }
|
||||||
if (clause != catches.last() || aTry.finallyExpression != null) tryCatchBlockEnd else null,
|
} else if (clause != catches.last()) {
|
||||||
null,
|
mv.goTo(tryCatchBlockEnd)
|
||||||
data
|
}
|
||||||
)
|
|
||||||
|
|
||||||
generateExceptionTable(clauseStart, tryRegions, descriptorType.internalName)
|
generateExceptionTable(clauseStart, tryRegions, descriptorType.internalName)
|
||||||
}
|
}
|
||||||
|
|
||||||
//for default catch clause
|
//for default catch clause
|
||||||
if (aTry.finallyExpression != null) {
|
if (tryInfo != null) {
|
||||||
val defaultCatchStart = Label()
|
val defaultCatchStart = markNewLabel()
|
||||||
mv.mark(defaultCatchStart)
|
|
||||||
val savedException = frame.enterTemp(JAVA_THROWABLE_TYPE)
|
val savedException = frame.enterTemp(JAVA_THROWABLE_TYPE)
|
||||||
mv.store(savedException, JAVA_THROWABLE_TYPE)
|
mv.store(savedException, JAVA_THROWABLE_TYPE)
|
||||||
|
val defaultCatchEnd = markNewLabel()
|
||||||
val defaultCatchEnd = Label()
|
|
||||||
mv.mark(defaultCatchEnd)
|
|
||||||
|
|
||||||
//do it before finally block generation
|
//do it before finally block generation
|
||||||
//javac also generates entry in exception table for default catch clause too!!!! so defaultCatchEnd as end parameter
|
//javac also generates entry in exception table for default catch clause too!!!! so defaultCatchEnd as end parameter
|
||||||
val defaultCatchRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, defaultCatchEnd)
|
val defaultCatchRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, defaultCatchEnd)
|
||||||
|
|
||||||
genFinallyBlockOrGoto(tryInfo, null, null, data)
|
data.handleBlock { genFinallyBlock(tryInfo, null, null, data) }
|
||||||
|
|
||||||
mv.load(savedException, JAVA_THROWABLE_TYPE)
|
mv.load(savedException, JAVA_THROWABLE_TYPE)
|
||||||
frame.leaveTemp(JAVA_THROWABLE_TYPE)
|
frame.leaveTemp(JAVA_THROWABLE_TYPE)
|
||||||
@@ -1085,14 +1085,6 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun genFinallyBlockOrGoto(tryInfo: TryInfo?, tryCatchBlockEnd: Label?, afterJumpLabel: Label?, data: BlockInfo) {
|
|
||||||
if (tryInfo != null) {
|
|
||||||
data.handleBlock { genFinallyBlock(tryInfo, tryCatchBlockEnd, afterJumpLabel, data) }
|
|
||||||
} else if (tryCatchBlockEnd != null) {
|
|
||||||
mv.goTo(tryCatchBlockEnd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun genFinallyBlock(tryInfo: TryInfo, tryCatchBlockEnd: Label?, afterJumpLabel: Label?, data: BlockInfo) {
|
private fun genFinallyBlock(tryInfo: TryInfo, tryCatchBlockEnd: Label?, afterJumpLabel: Label?, data: BlockInfo) {
|
||||||
assert(tryInfo.gaps.size % 2 == 0) { "Finally block gaps are inconsistent" }
|
assert(tryInfo.gaps.size % 2 == 0) { "Finally block gaps are inconsistent" }
|
||||||
tryInfo.gaps.add(markNewLabel())
|
tryInfo.gaps.add(markNewLabel())
|
||||||
|
|||||||
Reference in New Issue
Block a user