You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import{readFileSync}from"node:fs";constwasmBuffer=readFileSync("itoa.wasm");constimportObj={}constwasmModule=awaitWebAssembly.instantiate(wasmBuffer,importObj,{builtins: ['js-string']});const{ test }=wasmModule.instance.exports;
We (I?) want to make the scala-js wasm backend generate wasm binaries that can run on stand-alone wasm runtime.
However, that requires a lot of changes, and most of them are not self-contained (for example, WASI preview 1/2 support alone doesn't mean anything to users).
It's not desirable to add such non-self-contained changes to the main branch of scala-js. Only changes that are meaningful to users should be merged into the main branch.
Therefore, if we use the main branch as the target branch for stand-alone wasm development, we'll inevitably end up holding a gigantic changes locally and submitting extremely large pull requests. This puts a significant burden on reviewers and is undesirable.
We want to proceed with frequent reviews and agreements among tanishiking, sjrd, and gzm0 on changes.
I attempted to implement a String representation in our Wasm backend using an i16 array with WasmGC. However, we cannot simply switch the String representation from a JS String to an i16 array, as we still rely on JS Strings for JS interoperation. The plan is to allow these two String representations to coexist, using i16 arrays wherever possible while retaining JS Strings where necessary. This way, we should be able to keep the test suites passing, start using i16 arrays, and gradually remove JS interoperation.
To achieve this, we need to convert between JS Strings and i16 array Strings. The main idea is to
convert an i16 array String to a JS String when upcasting String into Any and
convert a JS String into an i16 array when down casting from Any to String
Additionally, we must handle conversions between JS Strings and i16 arrays when passing Strings between non-JS and JS classes (because we keep using JSStrings inside the JSClasses).