Skip to content
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

Use mainReadsParams metadata from wasm-emscripten-finalize #9064

Merged
merged 8 commits into from
Jul 23, 2019

Conversation

kripken
Copy link
Member

@kripken kripken commented Jul 23, 2019

This lets the wasm backend path not emit code to set up argc/argv if main doesn't need them. It also avoids that code bringing in some string and stack allocation support (metadce improvements are from the latter).

This reduces --closure 1 -O3 size of hello world by almost 10%.

src/postamble.js Outdated
#endif
](
#if MAIN_READS_PARAMS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky to read, because we're parameterizing on two #ifs and this is better than having 4 slightly-different copies of the same statement.

Would this still work if we had earlier

#else // not MAIN_READS_PARAMS
  var argc = 1;
  var argv = 0;
#endif

? Because then we can leave the _proxy_main/_main logic alone.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, yeah - it will add 0,0 to the code size that way, but that might be slightly better for the VM anyhow (to not have to coerce an undefined). I'll change it.

src/postamble.js Outdated
#endif
](
#if MAIN_READS_PARAMS
argc, argv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops the 0, I assume that's fine? Presumably an undefined can get synthesized to a 0 in the case where we have a char* envp[] in main

run_process([PYTHON, EMCC, 'yes.c', '-O3', '-o', 'yes.js'])
yes = os.path.getsize('yes.js')
# not having to set up argc/argv allows us to avoid including a
# significant amount of JS for string support (which is not needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because metadce... that's really cool :)

@kripken kripken merged commit ccb19f9 into incoming Jul 23, 2019
@kripken kripken deleted the mainReadsParams2 branch July 23, 2019 21:19
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
…n-core#9064)

This lets the wasm backend path not emit code to set up argc/argv if main doesn't need them. It also avoids that code bringing in some string and stack allocation support (metadce improvements are from the latter).

This reduces --closure 1 -O3 size of hello world by almost 10%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants