Skip to content

Commit 666a2f2

Browse files
committed
[Wasm] Implement IrLinkageError end enable partial linker
KT-58088
1 parent 4dc6689 commit 666a2f2

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
773773
mode = arguments.partialLinkageMode,
774774
logLevel = arguments.partialLinkageLogLevel,
775775
compilerModeAllowsUsingPartialLinkage =
776-
/* disabled for WASM for now */ !arguments.wasm && /* no PL when producing KLIB */ arguments.includes != null,
776+
/* no PL when producing KLIB */ arguments.includes != null,
777777
onWarning = { messageCollector.report(WARNING, it) },
778778
onError = { messageCollector.report(ERROR, it) }
779779
)

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmSymbols.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class WasmSymbols(
111111
override val returnIfSuspended =
112112
getInternalFunction("returnIfSuspended")
113113

114+
val throwLinkageError = getInternalFunction("throwLinkageError")
115+
114116
val enumEntries = getIrClass(FqName.fromSegments(listOf("kotlin", "enums", "EnumEntries")))
115117
val createEnumEntries = findFunctions(enumsInternalPackage.memberScope, Name.identifier("enumEntries"))
116118
.find { it.valueParameters.firstOrNull()?.type?.isFunctionType == false }

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/BuiltInsLowering.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class BuiltInsLowering(val context: WasmBackendContext) : FileLoweringPass {
4343
builder: DeclarationIrBuilder
4444
): IrExpression {
4545
when (val symbol = call.symbol) {
46+
irBuiltins.linkageErrorSymbol -> {
47+
return irCall(call, context.wasmSymbols.throwLinkageError)
48+
}
4649
irBuiltins.ieee754equalsFunByOperandType[irBuiltins.floatClass] -> {
4750
if (call.getValueArgument(0)!!.type.isNullable() || call.getValueArgument(1)!!.type.isNullable()) {
4851
return irCall(call, symbols.nullableFloatIeee754Equals)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package kotlin.wasm.internal
7+
8+
internal class IrLinkageError(message: String?) : Error(message)
9+
10+
internal fun throwLinkageError(message: String?): Nothing {
11+
throw IrLinkageError(message)
12+
}

0 commit comments

Comments
 (0)