Skip to content

Commit b90fad5

Browse files
bashorSpace Team
authored andcommitted
[Wasm] Remove bootstrapping code that accidentally broke exceptions in VMs without JSTag
Update the JSTag absence simulation to cover this case in tests. #KT-81372 Fixed
1 parent eacfddb commit b90fad5

File tree

8 files changed

+9
-10
lines changed

8 files changed

+9
-10
lines changed

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/wasmCompiler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ $referencesToQualifiedAndImportedDeclarations
349349
// Save WebAssembly.JSTag into a local variable to work around [a problem in JavaScriptCore](https://bugs.webkit.org/show_bug.cgi?id=297126),
350350
// which doesn't allow us to check if JSTag is used as a tag inside a wasm module.
351351
""
352-
}const wasmJsTag = WebAssembly.JSTag;
353-
const wasmTag =${if (useJsTag) " wasmJsTag ??" else "" } new WebAssembly.Tag({ parameters: ['externref'] });
352+
}const wasmJsTag = ${if (useJsTag) "WebAssembly.JSTag" else "void 0"};
353+
const wasmTag = wasmJsTag ?? new WebAssembly.Tag({ parameters: ['externref'] });
354354
355355
const js_code = {
356356
$jsCodeBodyIndented

compiler/testData/codegen/box/size/add.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN_THIRD_PARTY_OPTIMIZER
44
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 52_517
5-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_197
5+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_130
66
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 76
77

88
// FILE: test.kt

compiler/testData/codegen/box/size/helloWorld.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN_THIRD_PARTY_OPTIMIZER
44
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 52_821
5-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_132
5+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_065
66
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 3_911
77

88
// IGNORE_BACKEND: WASM_WASI

compiler/testData/codegen/box/size/helloWorldPromise.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN_THIRD_PARTY_OPTIMIZER
44
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 52_924
5-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_368
5+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_301
66
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 4_131
77

88
// FILE: test.kt

compiler/testData/codegen/box/size/objectsOptimization.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN_THIRD_PARTY_OPTIMIZER
44
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 57_045
5-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_063
5+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_996
66
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 4_822
77

88
// IGNORE_BACKEND: WASM_WASI

compiler/testData/codegen/box/size/ok.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN_THIRD_PARTY_OPTIMIZER
44
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 52_568
5-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_063
5+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_996
66
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 3_849
77

88
// IGNORE_BACKEND: WASM_WASI

compiler/testData/codegen/box/size/removeUnusedOverride.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// RUN_THIRD_PARTY_OPTIMIZER
55
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 53_274
6-
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_063
6+
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_996
77
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 3_875
88

99
// IGNORE_BACKEND: WASM_WASI

libraries/stdlib/wasm/js/internal/ExceptionHelpers.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ internal fun throwValue(t: Throwable): Nothing {
1717
// If WebAssembly.JSTag is going to be used for wasm exceptions, use a helper function throwing an exception from JS.
1818
// It's required to work around [an issue in JavaScriptCore](https://bugs.webkit.org/show_bug.cgi?id=297134)
1919
// Otherwise, an empty function is provided, and exceptions will be thrown from wasm code.
20-
// TODO remove 'typeof wasmJsTag === 'undefined' || ' after bootstrap
21-
@JsFun("typeof wasmJsTag === 'undefined' || wasmTag === wasmJsTag ? (e) => { throw e; } : () => {}")
20+
@JsFun("wasmTag === wasmJsTag ? (e) => { throw e; } : () => {}")
2221
internal external fun jsThrow(e: JsAny?)
2322

2423
@ExcludedFromCodegen

0 commit comments

Comments
 (0)