From e69bbdd5b4d21334d080f96b180bfd94d58eb0b2 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Wed, 7 Dec 2022 12:41:27 +0100 Subject: [PATCH] [Wasm] Require location for `buildConstF32` & `buildConstF64` and fix all usages --- .../kotlin/backend/wasm/ir2wasm/DeclarationGenerator.kt | 8 ++++---- .../org/jetbrains/kotlin/wasm/ir/WasmExpressionBuilder.kt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/DeclarationGenerator.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/DeclarationGenerator.kt index dc0734adcf3..436091596c5 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/DeclarationGenerator.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/DeclarationGenerator.kt @@ -478,8 +478,8 @@ fun generateDefaultInitializerForType(type: WasmType, g: WasmExpressionBuilder) when (type) { WasmI32 -> g.buildConstI32(0, location) WasmI64 -> g.buildConstI64(0, location) - WasmF32 -> g.buildConstF32(0f) - WasmF64 -> g.buildConstF64(0.0) + WasmF32 -> g.buildConstF32(0f, location) + WasmF64 -> g.buildConstF64(0.0, location) is WasmRefNullType -> g.buildRefNull(type.heapType) is WasmRefNullNoneType -> g.buildRefNull(WasmHeapType.Simple.NullNone) is WasmRefNullExternrefType -> g.buildRefNull(WasmHeapType.Simple.NullNoExtern) @@ -512,8 +512,8 @@ fun generateConstExpression(expression: IrConst<*>, body: WasmExpressionBuilder, is IrConstKind.Int -> body.buildConstI32(kind.valueOf(expression), location) is IrConstKind.Long -> body.buildConstI64(kind.valueOf(expression), location) is IrConstKind.Char -> body.buildConstI32(kind.valueOf(expression).code, location) - is IrConstKind.Float -> body.buildConstF32(kind.valueOf(expression)) - is IrConstKind.Double -> body.buildConstF64(kind.valueOf(expression)) + is IrConstKind.Float -> body.buildConstF32(kind.valueOf(expression), location) + is IrConstKind.Double -> body.buildConstF64(kind.valueOf(expression), location) is IrConstKind.String -> { val stringValue = kind.valueOf(expression) val (literalAddress, literalPoolId) = context.referenceStringLiteralAddressAndId(stringValue) diff --git a/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/WasmExpressionBuilder.kt b/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/WasmExpressionBuilder.kt index 128a62a195f..ad6f1a6f90f 100644 --- a/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/WasmExpressionBuilder.kt +++ b/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/WasmExpressionBuilder.kt @@ -24,12 +24,12 @@ abstract class WasmExpressionBuilder { buildInstr(WasmOp.I64_CONST, location, WasmImmediate.ConstI64(value)) } - fun buildConstF32(value: Float) { - buildInstr(WasmOp.F32_CONST, WasmImmediate.ConstF32(value.toRawBits().toUInt())) + fun buildConstF32(value: Float, location: SourceLocation) { + buildInstr(WasmOp.F32_CONST, location, WasmImmediate.ConstF32(value.toRawBits().toUInt())) } - fun buildConstF64(value: Double) { - buildInstr(WasmOp.F64_CONST, WasmImmediate.ConstF64(value.toRawBits().toULong())) + fun buildConstF64(value: Double, location: SourceLocation) { + buildInstr(WasmOp.F64_CONST, location, WasmImmediate.ConstF64(value.toRawBits().toULong())) } fun buildConstI32Symbol(value: WasmSymbol) {