JVM_IR: never create temporaries in $default stubs

Given the strict pattern-matching in the inliner, this is the only way
to make it not crash when attempting to inline these stubs. Note that
the IR backend does not currently use the inliner's default method stub
handling; the crash only occurs when a module compiled with the non-IR
JVM backend is attempting to call an inline function with default
arguments defined in a module that was compiled with the IR backend.
This commit is contained in:
pyos
2019-10-16 13:23:57 +02:00
committed by max-kammerer
parent 95be7171bc
commit 55acc296a2
13 changed files with 136 additions and 19 deletions
@@ -31,6 +31,7 @@ class RedundantGotoMethodTransformer : MethodTransformer() {
* (1) subsequent labels
* ...
* goto Label (can be removed)
* nop (any number of them, or maybe none; will be removed by RedundantNopsCleanupMethodTransformer)
* Label:
* ...
* (2) indirect goto
@@ -49,6 +50,10 @@ class RedundantGotoMethodTransformer : MethodTransformer() {
var pendingGoto: JumpInsnNode? = null
for (insn in insns) {
// We can remove jumps over labels, NOPs, GOTOs with the same target, and fake
// instructions used to describe the current frame state. We have to keep jumps
// over line numbers, though, as otherwise something like an `if` with an empty
// `else` will trigger a breakpoint inside the `else` even when the condition is true.
when {
insn is LabelNode -> {
currentLabels.add(insn)
@@ -62,8 +67,7 @@ class RedundantGotoMethodTransformer : MethodTransformer() {
currentLabels.clear()
}
}
insn is LineNumberNode -> pendingGoto = null
insn.isMeaningful -> {
insn is LineNumberNode || (insn.isMeaningful && insn.opcode != Opcodes.NOP) -> {
currentLabels.clear()
pendingGoto = null
}