dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.37k stars 189 forks source link

[NativeAOT-LLVM] Enable bigint in emscripten linking #2485

Closed yowl closed 6 months ago

yowl commented 6 months ago

This PR adds -s WASM_BIGINT to the linking step for emscripten (not wasi where we link without emscripten and without javascript support so this doesn't apply). https://emscripten.org/docs/optimizing/Optimizing-Code.html?highlight=wasm_bigint

Bigint is widely supported now in browsers : https://caniuse.com/bigint

Rough measurements for HelloWasm using powershell

Measure-Command {start-process "C:/github/emsdk/upstream/emscripten/emcc.bat" -argumentList "@C:\github\runtimelab\artifacts\tests\coreclr/obj/browser.wasm.Debug/Managed/nativeaot\SmokeTests\HelloWasm\HelloWasm\native\link.rsp --js-library C:\github\runtimelab\src\tests\nativeaot\SmokeTests\HelloWasm\dotnet_support.js --pre-js C:\github\runtimelab\src\tests\nativeaot\SmokeTests\HelloWasm\Microsoft.JSInterop.js --pre-js C:\github\runtimelab\src\tests\nativeaot\SmokeTests\HelloWasm\shell.js --post-js C:\github\runtimelab\src\tests\nativeaot\SmokeTests\HelloWasm\HelloWasm.js" -Wait}

And the equivalent for the release build.

Debug Current : 23191 ms WIth Bigint: 2035 ms

Release: Current: 6086 ms With Bigint: 2028 ms

This improvement, as I understand it, is due to the fact that legalizing i64 is an expensive operation which we naturally avoid enabling BIGINT.