From eaa7240105811ffa565dc97768f1399e7855744b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 7 Apr 2020 11:59:29 -0700 Subject: JS/Wasm BigInt support for wasm-emscripten-finalize (#2726) If wasm-emscripten-finalize is given the BigInt flag, then we will be using BigInts on the JS side, and need no legalization at all since i64s will just be BigInts. --- src/tools/wasm-emscripten-finalize.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 576b64a1a..ce1729bb9 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -52,6 +52,7 @@ int main(int argc, const char* argv[]) { bool DWARF = false; bool sideModule = false; bool legalizeJavaScriptFFI = true; + bool bigInt = false; bool checkStackOverflow = false; uint64_t globalBase = INVALID_BASE; bool standaloneWasm = false; @@ -118,6 +119,13 @@ int main(int argc, const char* argv[]) { [&legalizeJavaScriptFFI](Options* o, const std::string&) { legalizeJavaScriptFFI = false; }) + .add("--bigint", + "-bi", + "Assume JS will use wasm/JS BigInt integration, so wasm i64s will " + "turn into JS BigInts, and there is no need for any legalization at " + "all (not even minimal legalization of dynCalls)", + Options::Arguments::Zero, + [&bigInt](Options* o, const std::string&) { bigInt = true; }) .add("--output-source-map", "-osm", "Emit source map to the specified file", @@ -272,8 +280,8 @@ int main(int argc, const char* argv[]) { generator.generateDynCallThunks(); } - // Legalize the wasm. - { + // Legalize the wasm, if BigInts don't make that moot. + if (!bigInt) { BYN_TRACE("legalizing types\n"); PassRunner passRunner(&wasm); passRunner.setOptions(options.passOptions); -- cgit v1.2.3