From 5169d96acdb7f16c453a343711608e9ae86afaf9 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Tue, 16 Aug 2022 18:31:48 +0200 Subject: [PATCH] [WASM] Function call codegen refactoring --- .../backend/wasm/ir2wasm/BodyGenerator.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 0ea017e390f..f41dcb13a02 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 @@ -269,16 +269,17 @@ class BodyGenerator( } // Some intrinsics are a special case because we want to remove them completely, including their arguments. - val removableIntrinsics = buildList { - if (backendContext.configuration.getNotNull(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS) == false) - add(wasmSymbols.rangeCheck) - if (backendContext.configuration.getNotNull(JSConfigurationKeys.WASM_ENABLE_ASSERTS) == false) - addAll(wasmSymbols.assertFuncs) + if (!backendContext.configuration.getNotNull(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS)) { + if (call.symbol == wasmSymbols.rangeCheck) { + body.buildGetUnit() + return + } } - - if (call.symbol in removableIntrinsics) { - body.buildGetUnit() - return + if (!backendContext.configuration.getNotNull(JSConfigurationKeys.WASM_ENABLE_ASSERTS)) { + if (call.symbol in wasmSymbols.assertFuncs) { + body.buildGetUnit() + return + } } val function: IrFunction = call.symbol.owner.realOverrideTarget