-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Reboot EVAL_CTORS with the new wasm-ctor-eval #16011
Merged
Merged
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
1c1c911
re-enble
kripken af28037
Merge remote-tracking branch 'origin/main' into eval_ctors
kripken 95b67e7
test
kripken 9315ab0
Merge remote-tracking branch 'origin/main' into eval_ctors
kripken 7657c9a
Merge remote-tracking branch 'origin/main' into eval_ctors
kripken 495db3e
Get basic logic working again
kripken 72343db
Merge remote-tracking branch 'origin/main' into eval_ctors
kripken efdf2aa
don't eval ctors by default any more
kripken c402873
temp [ci skip]
kripken 4b5447a
force test
kripken 269a69a
fornow
kripken 773dcc6
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken df56bb8
work [ci skip]
kripken d6512b4
work
kripken ec504ba
nicer [ci skip]
kripken a136023
fix
kripken 279a23a
fix
kripken 86312e9
work [ci skip]
kripken 111bfc6
test [ci skip].
kripken dced5fb
restore
kripken af0358f
better
kripken bfd2561
work
kripken bb68e12
test [ci skip]
kripken 0cd741c
test [ci skip]
kripken 9a5a3cf
fix
kripken 40cc46d
fix
kripken 025acaa
todo [ci skip]
kripken 3fa026e
wip [ci skip]
kripken f6dea85
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken d17a184
rebaseline [ci skip]
kripken aab7908
main too!
kripken de94af7
fix [ci skip]
kripken 0f7b08d
progress [ci skip]
kripken d94fc70
test passes [ci skip]
kripken bae78c2
test [ci skip]
kripken bf24890
nicer
kripken 26fc132
fix [ci skip]
kripken 7933947
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken 6314ac1
comment
kripken 71c8503
update
kripken 2a525ed
docs [ci skip]
kripken 36ad34a
docs [ci skip]
kripken d40b95d
text [ci skip]
kripken ac10129
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken 22c33ba
fixes
kripken 67dd2da
fix
kripken ff71843
comments
kripken 8f5c13d
text
kripken 3ab442b
unbench
kripken 4fd2869
bench
kripken 0589371
cleanup
kripken b99db6b
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken 28b3945
changelog [ci skip]
kripken d80f2a4
comment [ci skip]
kripken cf66fc8
add PR #
kripken 19a7caa
warnings => errors
kripken 2251183
testfix
kripken ef875b4
unify WASM_CALL_CTORS
kripken ae7b9e2
loggingfix
kripken b1707c6
comment
kripken facd964
-sEVAL_CTORS, no space
kripken 4e720af
Merge remote-tracking branch 'origin/main' into eval_ctors2
kripken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,59 @@ linker can handle a mix wasm object files and LTO object files. Passing | |
Thus, to allow maximal LTO opportunities with the LLVM wasm backend, build all | ||
source files with ``-flto`` and also link with ``flto``. | ||
|
||
EVAL_CTORS | ||
========== | ||
|
||
Building with ``-s EVAL_CTORS`` will evaluate as much code as possible at | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should skip the space after |
||
compile time. That includes both the "global ctor" functions (functions LLVM | ||
emits that run before ``main()``) as well as ``main()`` itself. As much as can | ||
be evaluated will be, and the resulting state is then "snapshotted" into the | ||
wasm. Then when the program is run it will begin from that state, and not need | ||
to execute that code, which can save time. | ||
|
||
This optimization can either reduce or increase code size. If a small amount | ||
of code generates many changes in memory, for example, then overall size may | ||
increase. It is best to build with this flag and then measure code and startup | ||
speed and see if the tradeoff is worthwhile in your program. | ||
|
||
You can make an effort to write EVAL_CTORS-friendly code, by deferring things | ||
that cannot be evalled as much as possible. For example, calls to imports stop | ||
this optimization, and so if you have a game engine that creates a GL context | ||
and then does some pure computation to set up unrelated data structures in | ||
memory, then you could reverse that order. Then the pure computation could run | ||
first, and be evalled away, and the GL context creation call to an import would | ||
not prevent that. Other things you can do are to avoid using ``argc/argv``, to | ||
avoid using ``getenv()``, and so forth. | ||
|
||
Logging is shown when using this option so that you can see whether things can | ||
be improved. Here is an example of output from ``emcc -s EVAL_CTORS``: | ||
|
||
:: | ||
|
||
trying to eval __wasm_call_ctors | ||
...partial evalling successful, but stopping since could not eval: call import: wasi_snapshot_preview1.environ_sizes_get | ||
recommendation: consider --ignore-external-input | ||
...stopping | ||
|
||
The first line indicates an attempt to eval LLVM's function that runs global | ||
ctors. It evalled some of the function but then it stopped on the WASI import | ||
``environ_sizes_get``, which means it is trying to read from the environment. | ||
As the output says, you can tell ``EVAL_CTORS`` to ignore external input, which | ||
will ignore such things. You can enable that with mode ``2``, that is, build | ||
with ``emcc -s EVAL_CTORS=2``: | ||
|
||
:: | ||
|
||
trying to eval __wasm_call_ctors | ||
...success on __wasm_call_ctors. | ||
trying to eval main | ||
...stopping (in block) since could not eval: call import: wasi_snapshot_preview1.fd_write | ||
...stopping | ||
|
||
Now it has succeeded to eval ``__wasm_call_ctors`` completely. It then moved on | ||
to ``main``, where it stopped because of a call to WASI's ``fd_write``, that is, | ||
a call to print something. | ||
|
||
Very large codebases | ||
==================== | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
__errno_location | ||
__indirect_function_table | ||
__wasm_call_ctors | ||
dynCall_iiiiiijj | ||
dynCall_iiiiij | ||
dynCall_iiiiijj | ||
dynCall_jiji | ||
dynCall_viijii | ||
main | ||
memory | ||
stackAlloc | ||
stackRestore | ||
stackSave |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
env.abort | ||
env.emscripten_memcpy_big | ||
env.emscripten_resize_heap | ||
env.setTempRet0 | ||
env.strftime_l | ||
wasi_snapshot_preview1.environ_get | ||
wasi_snapshot_preview1.environ_sizes_get | ||
wasi_snapshot_preview1.fd_close | ||
wasi_snapshot_preview1.fd_read | ||
wasi_snapshot_preview1.fd_seek | ||
wasi_snapshot_preview1.fd_write |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
98089 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
abort | ||
emscripten_memcpy_big | ||
emscripten_resize_heap | ||
environ_get | ||
environ_sizes_get | ||
fd_close | ||
fd_read | ||
fd_seek | ||
fd_write | ||
setTempRet0 | ||
strftime_l |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
124645 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__errno_location | ||
__indirect_function_table | ||
dynCall_iiiiiijj | ||
dynCall_iiiiij | ||
dynCall_iiiiijj | ||
dynCall_jiji | ||
dynCall_viijii | ||
main | ||
memory | ||
stackAlloc | ||
stackRestore | ||
stackSave |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
env.abort | ||
env.emscripten_memcpy_big | ||
env.emscripten_resize_heap | ||
env.setTempRet0 | ||
env.strftime_l | ||
wasi_snapshot_preview1.fd_close | ||
wasi_snapshot_preview1.fd_read | ||
wasi_snapshot_preview1.fd_seek | ||
wasi_snapshot_preview1.fd_write |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
97987 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
abort | ||
emscripten_memcpy_big | ||
emscripten_resize_heap | ||
environ_get | ||
environ_sizes_get | ||
fd_close | ||
fd_read | ||
fd_seek | ||
fd_write | ||
setTempRet0 | ||
strftime_l |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
122060 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
a | ||
b | ||
c |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$add |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
11845 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
62 |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I all these cases I think its better to just error our given contradictory settings. That is what we normally do.