Bug 1826573 - Add pref for duplicate named capture groups; r=iain

Differential Revision: https://phabricator.services.mozilla.com/D209744
This commit is contained in:
Daniel Minor 2024-05-15 19:26:47 +00:00
parent d7ad02fc32
commit 2fad61d3b0
5 changed files with 32 additions and 1 deletions

View File

@ -4423,6 +4423,12 @@ JS_PUBLIC_API void JS_SetGlobalJitCompilerOption(JSContext* cx,
JS::ContextOptionsRef(cx).setWasmIon(!!value);
break;
#ifdef NIGHTLY_BUILD
case JSJITCOMPILER_REGEXP_DUPLICATE_NAMED_GROUPS:
jit::JitOptions.js_regexp_duplicate_named_groups = !!value;
break;
#endif
#ifdef DEBUG
case JSJITCOMPILER_FULL_DEBUG_CHECKS:
jit::JitOptions.fullDebugChecks = !!value;

View File

@ -861,7 +861,8 @@ extern JS_PUBLIC_API void JS_SetOffthreadIonCompilationEnabled(JSContext* cx,
Register(WASM_FOLD_OFFSETS, "wasm.fold-offsets") \
Register(WASM_DELAY_TIER2, "wasm.delay-tier2") \
Register(WASM_JIT_BASELINE, "wasm.baseline") \
Register(WASM_JIT_OPTIMIZING, "wasm.optimizing") // clang-format on
Register(WASM_JIT_OPTIMIZING, "wasm.optimizing") \
Register(REGEXP_DUPLICATE_NAMED_GROUPS, "regexp.duplicate-named-groups") // clang-format on
typedef enum JSJitCompilerOption {
#define JIT_COMPILER_DECLARE(key, str) JSJITCOMPILER_##key,

View File

@ -12125,6 +12125,8 @@ bool InitOptionParser(OptionParser& op) {
!op.addBoolOption('\0', "enable-uint8array-base64",
"Enable Uint8Array base64/hex methods") ||
!op.addBoolOption('\0', "enable-float16array", "Enable Float16Array") ||
!op.addBoolOption('\0', "enable-regexp-duplicate-named-groups",
"Enable Duplicate Named Capture Groups") ||
!op.addBoolOption('\0', "enable-top-level-await",
"Enable top-level await") ||
!op.addBoolOption('\0', "enable-import-assertions",
@ -12519,6 +12521,9 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) {
if (op.getBoolOption("enable-float16array")) {
JS::Prefs::setAtStartup_experimental_float16array(true);
}
if (op.getBoolOption("enable-regexp-duplicate-named-groups")) {
JS::Prefs::setAtStartup_experimental_regexp_duplicate_named_groups(true);
}
#endif
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
JS::Prefs::setAtStartup_experimental_json_parse_with_source(
@ -13330,6 +13335,11 @@ bool SetContextJITOptions(JSContext* cx, const OptionParser& op) {
# endif
#endif
#ifdef NIGHTLY_BUILD
if (op.getBoolOption("enable-regexp-duplicate-named-groups")) {
jit::JitOptions.js_regexp_duplicate_named_groups = true;
}
#endif
return true;
}

View File

@ -981,6 +981,13 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
auto& contextOptions = JS::ContextOptionsRef(cx);
SetPrefableContextOptions(contextOptions);
#ifdef NIGHTLY_BUILD
JS_SetGlobalJitCompilerOption(
cx, JSJITCOMPILER_REGEXP_DUPLICATE_NAMED_GROUPS,
StaticPrefs::
javascript_options_experimental_regexp_duplicate_named_groups());
#endif
// Set options not shared with workers.
contextOptions
.setThrowOnDebuggeeWouldRun(Preferences::GetBool(

View File

@ -7743,6 +7743,13 @@
mirror: always
set_spidermonkey_pref: startup
# Experimental support for Duplicate Named Capture Groups in JavaScript.
- name: javascript.options.experimental.regexp_duplicate_named_groups
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