diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt index b88a8b65fc3..34c39bf0857 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt @@ -134,9 +134,10 @@ class BodyGenerator( check(wasmArrayType != null) - generateAnyParameters(arrayClass.symbol, expression.getSourceLocation()) + val location = expression.getSourceLocation() + generateAnyParameters(arrayClass.symbol, location) if (!tryGenerateConstVarargArray(expression, wasmArrayType)) tryGenerateVarargArray(expression, wasmArrayType) - body.buildStructNew(context.referenceGcType(expression.type.getRuntimeClass(irBuiltIns).symbol)) + body.buildStructNew(context.referenceGcType(expression.type.getRuntimeClass(irBuiltIns).symbol), location) } override fun visitThrow(expression: IrThrow) { @@ -284,11 +285,12 @@ class BodyGenerator( } if (expression.symbol.owner.hasWasmPrimitiveConstructorAnnotation()) { - generateAnyParameters(klassSymbol, expression.getSourceLocation()) + val location = expression.getSourceLocation() + generateAnyParameters(klassSymbol, location) for (i in 0 until expression.valueArgumentsCount) { generateExpression(expression.getValueArgument(i)!!) } - body.buildStructNew(wasmGcType) + body.buildStructNew(wasmGcType, location) body.commentPreviousInstr { "@WasmPrimitiveConstructor ctor call: ${klass.fqNameWhenAvailable}" } return } @@ -329,7 +331,7 @@ class BodyGenerator( generateDefaultInitializerForType(context.transformType(field.type), body) } } - body.buildStructNew(context.referenceGcType(parentClass.symbol)) + body.buildStructNew(context.referenceGcType(parentClass.symbol), location) body.buildSetLocal(thisParameter, location) body.buildEnd() } @@ -351,9 +353,10 @@ class BodyGenerator( private fun generateBox(expression: IrExpression, type: IrType) { val klassSymbol = type.getRuntimeClass(irBuiltIns).symbol - generateAnyParameters(klassSymbol, expression.getSourceLocation()) + val location = expression.getSourceLocation() + generateAnyParameters(klassSymbol, location) generateExpression(expression) - body.buildStructNew(context.referenceGcType(klassSymbol)) + body.buildStructNew(context.referenceGcType(klassSymbol), location) body.commentPreviousInstr { "box" } } 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 b83fcfe0508..377c283f608 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 @@ -269,7 +269,7 @@ class DeclarationGenerator( buildRefNull(vtableStruct.fields[i].type.getHeapType()) } } - buildStructNew(vTableTypeReference) + buildStructNew(vTableTypeReference, SourceLocation.NoLocation("Create instance of vtable struct")) } context.defineGlobalVTable( irClass = symbol, @@ -278,6 +278,7 @@ class DeclarationGenerator( } private fun createClassITable(metadata: ClassMetadata) { + val location = SourceLocation.NoLocation("Create instance of itable struct") val klass = metadata.klass if (klass.isAbstractOrSealed) return val supportedInterface = metadata.interfaces.firstOrNull()?.symbol ?: return @@ -313,9 +314,9 @@ class DeclarationGenerator( buildRefNull(WasmHeapType.Type(context.referenceFunctionType(method.function.symbol))) } } - buildStructNew(iFaceVTableGcType) + buildStructNew(iFaceVTableGcType, location) } - buildStructNew(classInterfaceType) + buildStructNew(classInterfaceType, location) } val wasmClassIFaceGlobal = WasmGlobal( 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 34da4f78cae..5d0e4093861 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 @@ -153,8 +153,8 @@ abstract class WasmExpressionBuilder { ) } - fun buildStructNew(struct: WasmSymbol) { - buildInstr(WasmOp.STRUCT_NEW, WasmImmediate.GcType(struct)) + fun buildStructNew(struct: WasmSymbol, location: SourceLocation) { + buildInstr(WasmOp.STRUCT_NEW, location, WasmImmediate.GcType(struct)) } fun buildStructSet(struct: WasmSymbol, fieldId: WasmSymbol) {