mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1899813 - Add pref for regexp pattern modifiers. r=iain,spidermonkey-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D212971
This commit is contained in:
parent
afe00f4e28
commit
0e2ead6892
@ -645,6 +645,8 @@ MSG_DEF(JSMSG_ESCAPE_AT_END_OF_REGEXP, 0, JSEXN_SYNTAXERR, "\\ at end of pattern
|
||||
MSG_DEF(JSMSG_EXEC_NOT_OBJORNULL, 0, JSEXN_TYPEERR, "RegExp exec method should return object or null")
|
||||
MSG_DEF(JSMSG_INVALID_DECIMAL_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid decimal escape in regular expression")
|
||||
MSG_DEF(JSMSG_INVALID_GROUP, 0, JSEXN_SYNTAXERR, "invalid regexp group")
|
||||
MSG_DEF(JSMSG_REPEATED_FLAG, 0, JSEXN_SYNTAXERR, "repeated flag in regexp modifier")
|
||||
MSG_DEF(JSMSG_INVALID_FLAG_GROUP, 0, JSEXN_SYNTAXERR, "invalid flag group")
|
||||
MSG_DEF(JSMSG_INVALID_IDENTITY_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid identity escape in regular expression")
|
||||
MSG_DEF(JSMSG_INVALID_UNICODE_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid unicode escape in regular expression")
|
||||
MSG_DEF(JSMSG_MISSING_PAREN, 0, JSEXN_SYNTAXERR, "unterminated parenthetical")
|
||||
|
@ -109,9 +109,11 @@ static uint32_t ErrorNumber(RegExpError err) {
|
||||
return JSMSG_INVALID_QUANTIFIER;
|
||||
case RegExpError::kInvalidGroup:
|
||||
return JSMSG_INVALID_GROUP;
|
||||
case RegExpError::kMultipleFlagDashes:
|
||||
case RegExpError::kRepeatedFlag:
|
||||
return JSMSG_REPEATED_FLAG;
|
||||
case RegExpError::kInvalidFlagGroup:
|
||||
return JSMSG_INVALID_FLAG_GROUP;
|
||||
case RegExpError::kMultipleFlagDashes:
|
||||
// V8 contains experimental support for turning regexp flags on
|
||||
// and off in the middle of a regular expression. Unless it
|
||||
// becomes standardized, SM does not support this feature.
|
||||
|
@ -4426,6 +4426,12 @@ JS_PUBLIC_API void JS_SetGlobalJitCompilerOption(JSContext* cx,
|
||||
jit::JitOptions.js_regexp_duplicate_named_groups = !!value;
|
||||
break;
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
case JSJITCOMPILER_REGEXP_MODIFIERS:
|
||||
jit::JitOptions.js_regexp_modifiers = !!value;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
case JSJITCOMPILER_FULL_DEBUG_CHECKS:
|
||||
jit::JitOptions.fullDebugChecks = !!value;
|
||||
|
@ -862,7 +862,8 @@ extern JS_PUBLIC_API void JS_SetOffthreadIonCompilationEnabled(JSContext* cx,
|
||||
Register(WASM_DELAY_TIER2, "wasm.delay-tier2") \
|
||||
Register(WASM_JIT_BASELINE, "wasm.baseline") \
|
||||
Register(WASM_JIT_OPTIMIZING, "wasm.optimizing") \
|
||||
Register(REGEXP_DUPLICATE_NAMED_GROUPS, "regexp.duplicate-named-groups") // clang-format on
|
||||
Register(REGEXP_DUPLICATE_NAMED_GROUPS, "regexp.duplicate-named-groups") \
|
||||
Register(REGEXP_MODIFIERS, "regexp.modifiers") // clang-format on
|
||||
|
||||
typedef enum JSJitCompilerOption {
|
||||
#define JIT_COMPILER_DECLARE(key, str) JSJITCOMPILER_##key,
|
||||
|
@ -12197,6 +12197,8 @@ bool InitOptionParser(OptionParser& op) {
|
||||
!op.addBoolOption('\0', "enable-float16array", "Enable Float16Array") ||
|
||||
!op.addBoolOption('\0', "enable-regexp-duplicate-named-groups",
|
||||
"Enable Duplicate Named Capture Groups") ||
|
||||
!op.addBoolOption('\0', "enable-regexp-modifiers",
|
||||
"Enable Pattern Modifiers") ||
|
||||
!op.addBoolOption('\0', "enable-top-level-await",
|
||||
"Enable top-level await") ||
|
||||
!op.addBoolOption('\0', "enable-import-assertions",
|
||||
@ -12594,6 +12596,9 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) {
|
||||
if (op.getBoolOption("enable-uint8array-base64")) {
|
||||
JS::Prefs::setAtStartup_experimental_uint8array_base64(true);
|
||||
}
|
||||
if (op.getBoolOption("enable-regexp-modifiers")) {
|
||||
JS::Prefs::setAtStartup_experimental_regexp_modifiers(true);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
|
||||
if (op.getBoolOption("enable-json-parse-with-source")) {
|
||||
@ -13411,6 +13416,12 @@ bool SetContextJITOptions(JSContext* cx, const OptionParser& op) {
|
||||
jit::JitOptions.js_regexp_duplicate_named_groups = true;
|
||||
}
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
if (op.getBoolOption("enable-regexp-modifiers")) {
|
||||
jit::JitOptions.js_regexp_modifiers = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -986,6 +986,12 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
|
||||
StaticPrefs::
|
||||
javascript_options_experimental_regexp_duplicate_named_groups());
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
cx, JSJITCOMPILER_REGEXP_MODIFIERS,
|
||||
StaticPrefs::javascript_options_experimental_regexp_modifiers());
|
||||
#endif
|
||||
|
||||
// Set options not shared with workers.
|
||||
contextOptions
|
||||
.setThrowOnDebuggeeWouldRun(Preferences::GetBool(
|
||||
|
@ -7959,6 +7959,13 @@
|
||||
mirror: always
|
||||
set_spidermonkey_pref: startup
|
||||
|
||||
# Experimental support for Pattern Modifiers in JavaScript.
|
||||
- name: javascript.options.experimental.regexp_modifiers
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
set_spidermonkey_pref: startup
|
||||
|
||||
# Experimental support for Import Assertions in JavaScript.
|
||||
- name: javascript.options.experimental.import_attributes
|
||||
type: bool
|
||||
|
Loading…
Reference in New Issue
Block a user