Add NOP as first instruction in coroutine's try blocks

#KT-35035 Fixed
This commit is contained in:
Ilmir Usmanov
2019-12-02 21:32:18 +03:00
parent 4777dd652b
commit df0a86ea57
9 changed files with 85 additions and 3 deletions
@@ -783,13 +783,15 @@ class CoroutineTransformerMethodVisitor(
// See 'splitTryCatchBlocksContainingSuspensionPoint'
val possibleTryCatchBlockStart = suspension.tryCatchBlocksContinuationLabel
// Remove NOP as it's unnecessary anymore
// Move NOP, which is inserted in `splitTryCatchBlocksContainingSuspentionPoint`, inside the try catch block,
// so the inliner can transform suspend lambdas during inlining
assert(possibleTryCatchBlockStart.previous.opcode == Opcodes.NOP) {
"NOP expected but ${possibleTryCatchBlockStart.previous.opcode} was found"
}
remove(possibleTryCatchBlockStart.previous)
insert(possibleTryCatchBlockStart, withInstructionAdapter {
nop()
generateResumeWithExceptionCheck(languageVersionSettings.isReleaseCoroutines(), dataIndex, exceptionIndex)
// Load continuation argument just like suspending function returns it