[Wasm] Simplify a message printed in case of WebAssembly.CompileError

#KT-59720
This commit is contained in:
Zalim Bashorov
2023-09-14 12:03:30 +02:00
committed by Space Team
parent 44f9199f66
commit eecfc2c6d3
6 changed files with 8 additions and 22 deletions
@@ -250,8 +250,6 @@ fun WasmCompiledModuleFragment.generateAsyncJsWrapper(
}.sorted()
.joinToString("\n")
val d = "$"
//language=js
return """
export async function instantiate(imports={}, runInitializer=true) {
@@ -320,23 +318,11 @@ $imports
}
} catch (e) {
if (e instanceof WebAssembly.CompileError) {
const styles = [];
const styled = (t, css, escSeq) => isBrowser ? (styles.push(css, /* reset */""), `%c$d{t}%c`) : `\x1b[$d{escSeq}m$d{t}\x1b[m`;
const name = t => styled(t, "font-weight:bold", 1);
const uri = t => styled(t, "text-decoration:underline", 4);
const cli = t => styled(t, "font-family:monospace", 2);
let text = `Using experimental Kotlin/Wasm may require enabling experimental features in the target environment.
- $d{name("Chrome")}: enable $d{name("WebAssembly Garbage Collection")} at $d{uri("chrome://flags/#enable-webassembly-garbage-collection")} or run the program with the $d{cli("--js-flags=--experimental-wasm-gc")} command line argument.
- $d{name("Firefox")}: enable $d{name("javascript.options.wasm_function_references")} and $d{name("javascript.options.wasm_gc")} at $d{uri("about:config")}.
- $d{name("Edge")}: run the program with the $d{cli("--js-flags=--experimental-wasm-gc")} command line argument.
- $d{name("Node.js")}: run the program with the $d{cli("--experimental-wasm-gc")} command line argument.
For more information see $d{uri("https://kotl.in/wasm_help/")}.
let text = `Please make sure that your runtime environment supports the latest version of Wasm GC and Exception-Handling proposals.
For more information, see https://kotl.in/wasm-help
`;
if (isBrowser) {
console.error(text, ...styles);
console.error(text);
} else {
const t = "\n" + text;
if (typeof console !== "undefined" && console.log !== void 0)
+1 -1
View File
@@ -1,7 +1,7 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 12_946
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_456
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 4_526
// FILE: test.kt
+1 -1
View File
@@ -1,7 +1,7 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 48_430
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_482
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 4_552
fun box(): String {
println("Hello, World!")
+1 -1
View File
@@ -1,7 +1,7 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 14_307
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_011
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_081
// FILE: test.kt
+1 -1
View File
@@ -1,7 +1,7 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 18_621
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_328
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 4_398
// Muting because K2 DCE code size was less than expected (17377)
// IGNORE_BACKEND_K2: WASM
+1 -1
View File
@@ -1,6 +1,6 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 12_988
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_328
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 4_398
fun box() = "OK"