[Wasm] Loader improvements

- Output ES modules instead of plain files
- Support -Xwasm-launcher=d8 for d8 shell used in tests and benchmarks.
- Reuse launcher generation logic in CLI and box tests runners.
- Create separate output directory for each box since
  there are multiple output files generated for each test.
- Stop using absolute paths in generate JS files
  to simplify running generated code on different machine
- Remove ">>>" from println output


Merge-request: KT-MR-5729
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
This commit is contained in:
Svyatoslav Kuzmich
2022-02-10 22:59:44 +00:00
committed by Space
parent 918a91dbdf
commit 4636f71076
12 changed files with 236 additions and 211 deletions
@@ -139,8 +139,8 @@ internal fun anyToExternRef(x: Any): ExternalInterfaceType {
}
@JsFun("""(addr) => {
const mem16 = new Uint16Array(wasmInstance.exports.memory.buffer);
const mem32 = new Int32Array(wasmInstance.exports.memory.buffer);
const mem16 = new Uint16Array(wasmExports.memory.buffer);
const mem32 = new Int32Array(wasmExports.memory.buffer);
const len = mem32[addr / 4];
const str_start_addr = (addr + 4) / 2;
const slice = mem16.slice(str_start_addr, str_start_addr + len);
@@ -163,7 +163,7 @@ internal fun convertJsStringToKotlinString(x: ExternalInterfaceType): String {
//language=js
@JsFun(
""" (str, addr) => {
const memory = new DataView(wasmInstance.exports.memory.buffer);
const memory = new DataView(wasmExports.memory.buffer);
for (var i = 0; i < str.length; i++) {
memory.setInt16(addr + i * 2, str.charCodeAt(i), true);
}
+3 -3
View File
@@ -7,11 +7,11 @@ package kotlin.io
import kotlin.wasm.internal.*
@JsFun("(error) => console.error(\">>> \" + error)")
@JsFun("(error) => console.error(error)")
internal external fun printError(error: String?): Unit
@JsFun("(message) => console.log(\">>> \" + message)")
private external fun printlnImpl(error: String?): Unit
@JsFun("(message) => console.log(message)")
private external fun printlnImpl(message: String?): Unit
/** Prints the line separator to the standard output stream. */
public actual fun println() {