-
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
Add sign-ext lowering pass when target browser doesn't support it #17689
Conversation
This is really a WIP to show what we will likely have to do in preparation for the llvm-side change. |
should we do a no-op change first, which doesn't bump the versions? Another question. I assume that if a user passes |
Yes that works both before and after this change explicit user flags come later and therefore take precedence |
New feature matrix code looks good to me 👍 |
I split out the actual bumping the default versions into #17690 |
bbe0aa0
to
b408293
Compare
Added a test. PTAL |
722187e
to
0407a6b
Compare
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 guess we could also ask the opposite question of "what if the user only passes the feature flags at link time and doesn't at compile time": I guess in that case things would also work as they do now... wasm features would be unaffected, but JS/web features would be adjusted accordingly.
test/test_other.py
Outdated
self.assertNotContained('nontrapping-fptoint', enabled) | ||
self.assertNotContained('mutable-globals', enabled) | ||
|
||
# If we not disable all support for Edge/Safari/Firefox those feature should now be |
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.
# If we not disable all support for Edge/Safari/Firefox those feature should now be | |
# If we disable all support for Edge/Safari/Firefox those feature should now be |
test/test_other.py
Outdated
self.run_process([EMCC, '-mcpu=bleeding-edge', '-c', test_file('hello_world.c'), | ||
'-sMIN_EDGE_VERSION=-1', | ||
'-sMIN_SAFARI_VERSION=-1', | ||
'-sMIN_FIREFOX_VERSION=-1']) |
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.
Why is Chrome different here?
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.
Because its the default values of the other browsers that prevent those features being enabled. The default chrome version is good enough apparently. I updated the comment.
3fc9bc8
to
88cce67
Compare
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.
Please mention this in the changelog. Would be good to mention both directions - both that we disable as needed, and enable based on pthreads and bulk memory now.
704cf80
to
c534e46
Compare
We ended up landing on a much simpler solution that doesn't involve CFLAGS or llvm flags. We simply lower sign-ext operations away in a binaryen pass if user is targeting an older browser. As a followup we plan to update the default browser versions such that sign-ext is support by default. |
5058ccd
to
c530c66
Compare
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.
lgtm % comments
c530c66
to
5a9c009
Compare
If I understand correctly:
Do the Wasm object files record which features had been enabled when they were being built? That would allow quickly detecting if a lowering pass is needed at all? |
Correct.
Correct. The lowering pass happens when you target older browsers, regardless of whether One compelling reason for doing it this way is it ensuring that all input files are built with
Yes, wasm object files do contain that information, and actually I think we could rely on the linker outputting the features needed in the final binary. However, I'm not sure its worth doing this, since the running of this pass is only done if a non-default set of browsers are targeted. If such older browser are being targeted then is almost certain that |
Do you think reporting this information is important? I don't think we report it when we perform i64 lowering, which happens in the default case (i.e. when |
d259b90
to
4a0c219
Compare
4a0c219
to
00e136d
Compare
@@ -476,7 +477,6 @@ def default_min_browser_version(browser, version): | |||
|
|||
if settings.WASM_BIGINT: | |||
default_min_browser_version('Safari', 150000) | |||
default_min_browser_version('Edge', 79) |
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.
unrelated change?
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.
Actually its needed, since setting the edge version to anything by -1 currently means no features are supported. i.e. the edge version currently means only EdgeHTML and not modern Edge.
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 don't follow. First, why can't we use a single number for both browsers? I thought their version numbers did not overlap, and were monotonically increasing.
Second, what does it mean to not mention Edge here at all? Will anyone setting any value of Edge get sign-ext lowered out?
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.
The proposal is that for now the edge version only refers to the old edge browser, and if the features of modern edge ever diverge from chromium we can start to support MIN_EDGE_VERSION
being distinct from MIN_CHROME_VERSION
Not mentioning edge at all there just means that default of "-1" (not supported at all) will prevail.
Right now I'm not considering edge at all in the feature_matix.py because we currently assume that folks can use the MIN_CHROMIUM_VERSION to target modern versions of edge. Instead of removing this line I could instead extend feature_matrix.py to include support for MIN_EDGE_VERSION (but it would just be identical what is already there for chromium).
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.
OK, I reworked feature_matrix.py
such that this change is no longer needed.
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.
Oh, then the Chrome version refers to modern Edge too? Sgtm, but I wasn't aware their features had even been in sync so far. Is that the case in practice?
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.
If you looks at the versions in https://en.wikipedia.org/wiki/Microsoft_Edge (expand "New Edge release history") you will see that edge versions correspond 1-to-1 with blink versions.. to from a JS/wasm perspective one would expect them to always match.
00e136d
to
66596c4
Compare
llvm and binaryen now default to enabling sign-ext and mutable-globals by default. See https://reviews.llvm.org/D125728. In order to allow users to continue to target older browsers we will now lower sign-ext operations in a binaryen pass if the target browsers don't support it.
66596c4
to
95eb395
Compare
Good point, forgot about that. Agree, we wouldn't want to build different variants of the system libs for each combination. |
Ah right, there's already other steps that are needed. Yeah sgtm like this. |
llvm and binaryen now default to enabling sign-ext and mutable-globals
by default. See https://reviews.llvm.org/D125728.
In order to allow users to continue to target older browsers we will
now lower sign-ext operations in a binaryen pass if the target browsers
don't support it.