-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove varargs from g_assert and g_assert_not_reachable (save 200+ bytes per frame in wasm interp). #17254
Conversation
g_assertf unchanged. I have a strong suspicion, this will save approximately 432 bytes of stack per function call in the WebAssembly interpreter. It will not significantly benefit or hurt any other system. Systems with disabled asserts will receive a small size improvement. WebAssembly has no provision for varargs. Emscripten emulates it. It appears the emulation allocates room in the frame per outgoing varargs call. No stack packing. So each g_assert takes space. Alternative would be to discourage or disable or remove asserts.
How does one check the stack size on wasm ? Disassembly ? |
So, this part of the stack, is just in global memory. |
It is a little murky, because, hey, JIT can optimize, but we have this from objdump:
That 432 is what was bugging me. Aside then, the recurse/nonrecursive split is seemingly very effective, producing this, saving about 116 bytes:
however this is from an incorrect merge so not final. As to how to find the runtime JITed code, I don't know. |
Is that with a build where Anyway, nice find! |
I can confirm that this change reduces stack size from 480 to 272 on wasm. Nice work. |
@monojenkins build failed |
This was Ken @kjpou1's private build. With extra Note that assert could be better other ways. |
@monojenkins squash |
Thanks to @kjpou1 for help & persistance here. |
Cannot squash because the following required status checks are not successful:
|
@monojenkins build OS X x64 Android SDK |
@monojenkins build Windows x64 Interpreter |
…7254) Remove varargs from g_assert and g_assert_not_reachable (save 200+ bytes per frame in wasm interp). g_assertf unchanged. I have a strong suspicion, this will save approximately 432 - sizeof (InterpFrame) bytes of stack per function call in the WebAssembly interpreter. It will not significantly benefit or hurt any other system. Systems with disabled asserts will receive a small size improvement. WebAssembly has no provision for varargs. Emscripten emulates it. It appears the emulation allocates room in the frame per outgoing varargs call. No stack packing. So each g_assert takes space. Alternative would be to discourage or disable or remove asserts. Commit migrated from mono/mono@8718b75
g_assertf unchanged.
I have a strong suspicion, this will save approximately 432 - sizeof (InterpFrame) bytes of stack
per function call in the WebAssembly interpreter.
It will not significantly benefit or hurt any other system.
Systems with disabled asserts will receive a small size improvement.
WebAssembly has no provision for varargs.
Emscripten emulates it.
It appears the emulation allocates room in the frame per outgoing varargs call.
No stack packing.
So each g_assert takes space.
Alternative would be to discourage or disable or remove asserts.