-
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
Merged
Merged
Changes from all commits
Commits
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
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,6 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
int main(int argc, char* argv[]) { | ||
printf("%lld\n", (int64_t)argc); | ||
} |
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,88 @@ | ||
# Copyright 2022 The Emscripten Authors. All rights reserved. | ||
# Emscripten is available under two separate licenses, the MIT license and the | ||
# University of Illinois/NCSA Open Source License. Both these licenses can be | ||
# found in the LICENSE file. | ||
|
||
"""Utilities for mapping browser versions to webassembly features.""" | ||
|
||
import logging | ||
from enum import IntEnum, auto | ||
|
||
from .settings import settings, user_settings | ||
|
||
logger = logging.getLogger('feature_matrix') | ||
|
||
|
||
class Feature(IntEnum): | ||
NON_TRAPPING_FPTOINT = auto() | ||
SIGN_EXT = auto() | ||
BULK_MEMORY = auto() | ||
MUTABLE_GLOBALS = auto() | ||
JS_BIGINT_INTEGRATION = auto() | ||
|
||
|
||
default_features = {Feature.SIGN_EXT, Feature.MUTABLE_GLOBALS} | ||
|
||
min_browser_versions = { | ||
Feature.NON_TRAPPING_FPTOINT: { | ||
'chrome': 75, | ||
'firefox': 65, | ||
'safari': 150000, | ||
}, | ||
Feature.SIGN_EXT: { | ||
'chrome': 74, | ||
'firefox': 62, | ||
'safari': 140100, | ||
}, | ||
Feature.BULK_MEMORY: { | ||
'chrome': 75, | ||
'firefox': 79, | ||
'safari': 150000, | ||
}, | ||
Feature.MUTABLE_GLOBALS: { | ||
'chrome': 74, | ||
'firefox': 61, | ||
'safari': 120000, | ||
}, | ||
Feature.JS_BIGINT_INTEGRATION: { | ||
'chrome': 67, | ||
'firefox': 68, | ||
'safari': 150000, | ||
}, | ||
} | ||
|
||
|
||
def caniuse(feature): | ||
min_versions = min_browser_versions[feature] | ||
if settings.MIN_CHROME_VERSION < min_versions['chrome']: | ||
return False | ||
# For edge we just use the same version requirements as chrome since, | ||
# at least for modern versions of edge, they share version numbers. | ||
if settings.MIN_EDGE_VERSION < min_versions['chrome']: | ||
return False | ||
if settings.MIN_FIREFOX_VERSION < min_versions['firefox']: | ||
return False | ||
if settings.MIN_SAFARI_VERSION < min_versions['safari']: | ||
return False | ||
sbc100 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# IE don't support any non-MVP features | ||
if settings.MIN_IE_VERSION != 0x7FFFFFFF: | ||
return False | ||
return True | ||
|
||
|
||
def enable_feature(feature): | ||
"""Updates default settings for browser versions such that the given | ||
feature is available everywhere. | ||
""" | ||
for name, min_version in min_browser_versions[feature].items(): | ||
name = f'MIN_{name.upper()}_VERSION' | ||
if settings[name] < min_version and name not in user_settings: | ||
setattr(settings, name, min_version) | ||
|
||
|
||
# apply minimum browser version defaults based on user settings. if | ||
# a user requests a feature that we know is only supported in browsers | ||
# from a specific version and above, we can assume that browser version. | ||
def apply_min_browser_versions(): | ||
if settings.WASM_BIGINT: | ||
enable_feature(Feature.JS_BIGINT_INTEGRATION) |
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.
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 fromMIN_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.