From f1aca2307f158720550c20577f6e7fe492d4f2ae Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Wed, 30 Oct 2019 20:19:55 +0100 Subject: [PATCH] [IR] support of changes in progression handlers and for loop lowerings in 8a4185202f53 --- .../org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt | 2 +- .../src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt | 3 +++ .../org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt | 7 +++++++ .../src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt index 5ed7aa77473..c9c1cf9597b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt @@ -282,6 +282,7 @@ internal val allLoweringsPhase = namedIrModulePhase( name = "IrLowerByFile", description = "IR Lowering by file", lower = lateinitPhase then + forLoopsPhase then stringConcatenationPhase then enumConstructorsPhase then initializersPhase then @@ -290,7 +291,6 @@ internal val allLoweringsPhase = namedIrModulePhase( tailrecPhase then defaultParameterExtentPhase then innerClassPhase then - forLoopsPhase then dataClassesPhase then builtinOperatorPhase then finallyBlocksPhase then diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index 8f8d4f7567d..5f5bea435a4 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -230,6 +230,9 @@ internal class KonanSymbols( val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException") val throwIllegalStateException = internalFunction("ThrowIllegalStateException") val throwIllegalStateExceptionWithMessage = internalFunction("ThrowIllegalStateExceptionWithMessage") + val throwIllegalArgumentException = internalFunction("ThrowIllegalArgumentException") + val throwIllegalArgumentExceptionWithMessage = internalFunction("ThrowIllegalArgumentExceptionWithMessage") + override val ThrowUninitializedPropertyAccessException = internalFunction("ThrowUninitializedPropertyAccessException") diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 25b78231e28..d0c5714d3c5 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -2195,6 +2195,13 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map icmpLe(args[0], args[1]) } } + functionSymbol == context.irBuiltIns.illegalArgumentExceptionSymbol -> { + callDirect( + context.ir.symbols.throwIllegalArgumentExceptionWithMessage.owner, + args, + Lifetime.GLOBAL + ) + } else -> TODO(function.name.toString()) } } diff --git a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index 24fbd80a50d..9b2890d69e3 100644 --- a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -61,6 +61,11 @@ internal fun ThrowIllegalArgumentException() : Nothing { throw IllegalArgumentException() } +@ExportForCppRuntime +internal fun ThrowIllegalArgumentExceptionWithMessage(message: String) : Nothing { + throw IllegalArgumentException(message) +} + @ExportForCppRuntime internal fun ThrowIllegalStateException() : Nothing { throw IllegalStateException()