Skip to content

Commit 474b526

Browse files
bashorSpace Team
authored andcommitted
[Wasm] Introduce getWasmAbiVersion to simplify bootstrapping
The intrinsic aims to help with bootstrapping when we need to make changes in the compiler and in the runtime implementation inside stdlib simultaneously, allowing to choose behavior depending on the wasmAbiVersion value.
1 parent 5927c91 commit 474b526

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

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
@@ -228,6 +228,8 @@ class WasmSymbols(
228228
val stringGetLiteralLatin1 = getFunction("stringLiteralLatin1", StandardNames.BUILT_INS_PACKAGE_FQ_NAME)
229229
val stringGetPoolSize = getInternalFunction("stringGetPoolSize")
230230

231+
val getWasmAbiVersion = getInternalFunction("getWasmAbiVersion")
232+
231233
val testFun = maybeGetFunction("test", kotlinTestPackageFqName)
232234
val suiteFun = maybeGetFunction("suite", kotlinTestPackageFqName)
233235
val registerRootSuiteBlock = maybeGetFunction("registerRootSuiteBlock", kotlinTestPackageFqName)

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,10 @@ class BodyGenerator(
11411141
body.buildConstI32Symbol(wasmFileCodegenContext.stringPoolSize, location)
11421142
}
11431143

1144+
wasmSymbols.getWasmAbiVersion -> {
1145+
body.buildConstI32Symbol(wasmAbiVersion, location)
1146+
}
1147+
11441148
wasmSymbols.wasmArrayNewData0 -> {
11451149
val arrayGcType = WasmImmediate.GcType(
11461150
wasmFileCodegenContext.referenceGcType(call.typeArguments[0]!!.getRuntimeClass(irBuiltIns).symbol)
@@ -1552,6 +1556,7 @@ class BodyGenerator(
15521556
}
15531557

15541558
companion object {
1559+
val wasmAbiVersion = WasmSymbol(0)
15551560
val anyVtableFieldId = WasmSymbol(0)
15561561
val anyITableFieldId = WasmSymbol(1)
15571562
val anyRttiFieldId = WasmSymbol(2)

libraries/stdlib/wasm/internal/kotlin/wasm/internal/Runtime.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ internal fun consumeFloatIntoVoid(a: Float): Void =
120120
internal fun consumeDoubleIntoVoid(a: Double): Void =
121121
implementedAsIntrinsic
122122

123+
// TODO make intrinsic after bootstrap
124+
internal fun getWasmAbiVersion(): Int = 0
125+
123126
@ExcludedFromCodegen
124127
internal fun stringGetPoolSize(): Int =
125128
implementedAsIntrinsic

0 commit comments

Comments
 (0)