Skip to content

Commit

Permalink
[Wasm] Implement IrLinkageError end enable partial linker
Browse files Browse the repository at this point in the history
KT-58088
  • Loading branch information
igoriakovlev committed Mar 5, 2024
1 parent 4dc6689 commit 666a2f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
mode = arguments.partialLinkageMode,
logLevel = arguments.partialLinkageLogLevel,
compilerModeAllowsUsingPartialLinkage =
/* disabled for WASM for now */ !arguments.wasm && /* no PL when producing KLIB */ arguments.includes != null,
/* no PL when producing KLIB */ arguments.includes != null,
onWarning = { messageCollector.report(WARNING, it) },
onError = { messageCollector.report(ERROR, it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class WasmSymbols(
override val returnIfSuspended =
getInternalFunction("returnIfSuspended")

val throwLinkageError = getInternalFunction("throwLinkageError")

val enumEntries = getIrClass(FqName.fromSegments(listOf("kotlin", "enums", "EnumEntries")))
val createEnumEntries = findFunctions(enumsInternalPackage.memberScope, Name.identifier("enumEntries"))
.find { it.valueParameters.firstOrNull()?.type?.isFunctionType == false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class BuiltInsLowering(val context: WasmBackendContext) : FileLoweringPass {
builder: DeclarationIrBuilder
): IrExpression {
when (val symbol = call.symbol) {
irBuiltins.linkageErrorSymbol -> {
return irCall(call, context.wasmSymbols.throwLinkageError)
}
irBuiltins.ieee754equalsFunByOperandType[irBuiltins.floatClass] -> {
if (call.getValueArgument(0)!!.type.isNullable() || call.getValueArgument(1)!!.type.isNullable()) {
return irCall(call, symbols.nullableFloatIeee754Equals)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

package kotlin.wasm.internal

internal class IrLinkageError(message: String?) : Error(message)

internal fun throwLinkageError(message: String?): Nothing {
throw IrLinkageError(message)
}

0 comments on commit 666a2f2

Please sign in to comment.