JVM don't remove NOP starting a try-catch block
This commit is contained in:
committed by
teamcityserver
parent
9325660f06
commit
cc885f9b24
+3
-2
@@ -37,7 +37,6 @@ class TemporaryVariablesEliminationTransformer(private val state: GenerationStat
|
|||||||
methodNode.removeUnusedLocalVariables()
|
methodNode.removeUnusedLocalVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun simplifyTrivialInstructions(methodNode: MethodNode) {
|
private fun simplifyTrivialInstructions(methodNode: MethodNode) {
|
||||||
val insnList = methodNode.instructions
|
val insnList = methodNode.instructions
|
||||||
for (insn in insnList.toArray()) {
|
for (insn in insnList.toArray()) {
|
||||||
@@ -61,12 +60,14 @@ class TemporaryVariablesEliminationTransformer(private val state: GenerationStat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val tcbStartLabels = methodNode.tryCatchBlocks.mapTo(HashSet()) { it.start }
|
||||||
for (insn in insnList.toArray()) {
|
for (insn in insnList.toArray()) {
|
||||||
// Remove NOPs immediately preceded or immediately followed by an instruction that does something
|
// Remove NOPs immediately preceded or immediately followed by an instruction that does something
|
||||||
// - not a LINENUMBER, not a LABEL, and not a FRAME.
|
// - not a LINENUMBER, not a LABEL, and not a FRAME.
|
||||||
if (insn.opcode == Opcodes.NOP) {
|
if (insn.opcode == Opcodes.NOP) {
|
||||||
val next = insn.next
|
|
||||||
val prev = insn.previous
|
val prev = insn.previous
|
||||||
|
if (prev in tcbStartLabels) continue
|
||||||
|
val next = insn.next
|
||||||
if (next != null && next.isMeaningful || prev != null && prev.isMeaningful) {
|
if (next != null && next.isMeaningful || prev != null && prev.isMeaningful) {
|
||||||
insnList.remove(insn)
|
insnList.remove(insn)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user