-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implicit wasm feature disabling based on min browser versions
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.
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 deletions.
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
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,60 @@ | ||
# 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 | ||
|
||
logger = logging.getLogger('feature_matrix') | ||
|
||
|
||
class Feature(IntEnum): | ||
NON_TRAPPING_FPTOINT = auto() | ||
SIGN_EXT = auto() | ||
BULK_MEMORY = auto() | ||
MUTABLE_GLOBALS = 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, | ||
}, | ||
} | ||
|
||
|
||
def caniuse(feature): | ||
min_versions = min_browser_versions[feature] | ||
if settings.MIN_CHROME_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 | ||
# IE and Edge don't support any non-MVP features | ||
if settings.MIN_IE_VERSION != 0x7FFFFFFF or settings.MIN_EDGE_VERSION != 0x7FFFFFFF: | ||
return False | ||
return True |