-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Allow user override of default-enabled compile-time wasm features #22966
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
Changes from 3 commits
ff3e19a
86d3d4f
27935e5
a62c634
7936268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ class Feature(IntEnum): | |
|
|
||
|
|
||
| default_features = {Feature.SIGN_EXT, Feature.MUTABLE_GLOBALS} | ||
| disable_override_features = set() | ||
| enable_override_features = set() | ||
|
|
||
| min_browser_versions = { | ||
| Feature.NON_TRAPPING_FPTOINT: { | ||
|
|
@@ -93,6 +95,11 @@ class Feature(IntEnum): | |
|
|
||
|
|
||
| def caniuse(feature): | ||
| if feature in disable_override_features: | ||
| return False | ||
| if feature in enable_override_features: | ||
| return True | ||
|
|
||
| min_versions = min_browser_versions[feature] | ||
|
|
||
| def report_missing(setting_name): | ||
|
|
@@ -114,10 +121,12 @@ def report_missing(setting_name): | |
| return True | ||
|
|
||
|
|
||
| def enable_feature(feature, reason): | ||
| def enable_feature(feature, reason, is_explicit=False): | ||
dschuff marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """Updates default settings for browser versions such that the given | ||
| feature is available everywhere. | ||
| """ | ||
| if is_explicit: | ||
| enable_override_features.add(feature) | ||
| for name, min_version in min_browser_versions[feature].items(): | ||
| name = f'MIN_{name.upper()}_VERSION' | ||
| if settings[name] < min_version: | ||
|
|
@@ -132,6 +141,12 @@ def enable_feature(feature, reason): | |
| setattr(settings, name, min_version) | ||
|
|
||
|
|
||
| def disable_feature(feature): | ||
| """Allow the user to disable a feature that would otherwise be on by default. | ||
| """ | ||
| disable_override_features.add(feature) | ||
|
Member
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. Can we have the same default override behavior in enable and disable, so they are parallel?
Member
Author
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. The behavior is asymmetric in that there is no implicit disabling, only implicit enabling. So disable_feature can only be an explicit disable and will always override. But enable_feature can be explicit for a feature requested by a user, or implicit for a feature enabled as a result of another feature bumping the min browser versions. |
||
|
|
||
|
|
||
| # 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. | ||
|
|
||
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 not do the same for bulk memory? I guess because we don't have a link time lowering yet?
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.
Right, link time lowering is in my local branch but not upstream yet.
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, perhaps we can generalize this once we do the same for bulk memory, perhaps even make it data driven? e.g.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, I'll come back to the best way to do this this with bulk and nontrapping once they are hooked up to feature_matrix.