Bug 1729563 - Add shell flag for change-array-by-copy methods r=mgaudet,arai

Add a build flag and shell flag for enabling change-array-by-copy methods.
    The flags currently have no effect.

Differential Revision: https://phabricator.services.mozilla.com/D127201
This commit is contained in:
Tim Chevalier 2021-10-22 18:38:09 +00:00
parent ba084e0a3e
commit be12c6c29d
10 changed files with 90 additions and 0 deletions

View File

@ -1126,3 +1126,25 @@ set_define(
True,
when=depends(target)(lambda t: t.os == "WASI"),
)
# Enable change-array-by-copy
# ===================================================
def use_change_array_by_copy():
return False
option(
"--enable-change-array-by-copy",
default=use_change_array_by_copy(),
help="{Enable|Disable} change-array-by-copy method pref/command-line option (disabled by default)",
)
@depends("--enable-change-array-by-copy")
def enable_change_array_by_copy(value):
if value:
return True
set_config("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)
set_define("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)

View File

@ -51,6 +51,9 @@ class JS_PUBLIC_API ContextOptions {
fuzzing_(false),
privateClassFields_(false),
privateClassMethods_(false),
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
changeArrayByCopy_(false),
#endif
ergonomicBrandChecks_(false) {
}
// clang-format on
@ -161,6 +164,14 @@ class JS_PUBLIC_API ContextOptions {
return *this;
}
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
bool changeArrayByCopy() const { return changeArrayByCopy_; }
ContextOptions& setChangeArrayByCopy(bool enabled) {
changeArrayByCopy_ = enabled;
return *this;
}
#endif
bool classStaticBlocks() const { return classStaticBlocks_; }
ContextOptions& setClassStaticBlocks(bool enabled) {
classStaticBlocks_ = enabled;
@ -276,6 +287,9 @@ class JS_PUBLIC_API ContextOptions {
bool fuzzing_ : 1;
bool privateClassFields_ : 1;
bool privateClassMethods_ : 1;
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
bool changeArrayByCopy_ : 1;
#endif
bool ergonomicBrandChecks_ : 1;
bool classStaticBlocks_ : 1;
};

View File

@ -212,6 +212,14 @@ static bool GetRealmConfiguration(JSContext* cx, unsigned argc, Value* vp) {
return false;
}
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
bool changeArrayByCopy = cx->options().changeArrayByCopy();
if (!JS_SetProperty(cx, info, "enableChangeArrayByCopy",
changeArrayByCopy ? TrueHandleValue : FalseHandleValue)) {
return false;
}
#endif
args.rval().setObject(*info);
return true;
}
@ -523,6 +531,15 @@ static bool GetBuildConfiguration(JSContext* cx, unsigned argc, Value* vp) {
return false;
}
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
value = BooleanValue(true);
#else
value = BooleanValue(false);
#endif
if (!JS_SetProperty(cx, info, "change-array-by-copy", value)) {
return false;
}
args.rval().setObject(*info);
return true;
}

View File

@ -630,6 +630,9 @@ bool shell::enableIteratorHelpers = false;
bool shell::enablePrivateClassFields = false;
bool shell::enablePrivateClassMethods = false;
bool shell::enableErgonomicBrandChecks = true;
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
bool shell::enableChangeArrayByCopy = false;
#endif
bool shell::useOffThreadParseGlobal = true;
bool shell::enableClassStaticBlocks = true;
#ifdef JS_GC_ZEAL
@ -11303,6 +11306,9 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
enablePrivateClassMethods = !op.getBoolOption("disable-private-methods");
enableErgonomicBrandChecks =
!op.getBoolOption("disable-ergonomic-brand-checks");
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
enableChangeArrayByCopy = op.getBoolOption("enable-change-array-by-copy");
#endif
enableClassStaticBlocks = !op.getBoolOption("disable-class-static-blocks");
useOffThreadParseGlobal = op.getBoolOption("off-thread-parse-global");
useFdlibmForSinCosTan = op.getBoolOption("use-fdlibm-for-sin-cos-tan");
@ -11335,6 +11341,9 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
.setPrivateClassFields(enablePrivateClassFields)
.setPrivateClassMethods(enablePrivateClassMethods)
.setErgnomicBrandChecks(enableErgonomicBrandChecks)
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
.setChangeArrayByCopy(enableChangeArrayByCopy)
#endif
.setClassStaticBlocks(enableClassStaticBlocks);
JS::SetUseOffThreadParseGlobal(useOffThreadParseGlobal);
@ -12285,6 +12294,15 @@ int main(int argc, char** argv) {
!op.addBoolOption(
'\0', "disable-ergonomic-brand-checks",
"Disable ergonomic brand checks for private class fields") ||
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
!op.addBoolOption('\0', "enable-change-array-by-copy",
"Enable change-array-by-copy methods") ||
!op.addBoolOption('\0', "disable-change-array-by-copy",
"Disable change-array-by-copy methods") ||
#else
!op.addBoolOption('\0', "enable-change-array-by-copy", "no-op") ||
!op.addBoolOption('\0', "disable-change-array-by-copy", "no-op") ||
#endif
!op.addBoolOption('\0', "enable-top-level-await",
"Enable top-level await") ||
!op.addBoolOption('\0', "disable-class-static-blocks",

View File

@ -136,6 +136,9 @@ extern bool enableIteratorHelpers;
extern bool enablePrivateClassFields;
extern bool enablePrivateClassMethods;
extern bool enableErgonomicBrandChecks;
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
extern bool enableChangeArrayByCopy;
#endif
extern bool enableClassStaticBlocks;
#ifdef JS_GC_ZEAL
extern uint32_t gZealBits;

View File

@ -34,3 +34,4 @@ user_pref("javascript.options.experimental.weakrefs.expose_cleanupSome", true);
user_pref("javascript.options.experimental.iterator_helpers", true);
user_pref("javascript.options.experimental.top_level_await", true);
user_pref("javascript.options.experimental.ergonomic_brand_checks", true);
user_pref("javascript.options.experimental.enable_change_array_by_copy", false);

View File

@ -989,6 +989,10 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
bool ergnomicBrandChecksEnabled = Preferences::GetBool(
JS_OPTIONS_DOT_STR "experimental.ergonomic_brand_checks");
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
bool enableChangeArrayByCopy = Preferences::GetBool(
JS_OPTIONS_DOT_STR "experimental.enable_change_array_by_copy");
#endif
bool classStaticBlocksEnabled = Preferences::GetBool(
JS_OPTIONS_DOT_STR "experimental.class_static_blocks");
@ -1042,6 +1046,9 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
.setPrivateClassFields(privateFieldsEnabled)
.setPrivateClassMethods(privateMethodsEnabled)
.setClassStaticBlocks(classStaticBlocksEnabled)
#ifdef ENABLE_CHANGE_ARRAY_BY_COPY
.setChangeArrayByCopy(enableChangeArrayByCopy)
#endif
.setErgnomicBrandChecks(ergnomicBrandChecksEnabled);
JS::SetUseFdlibmForSinCosTan(

View File

@ -34,6 +34,7 @@ support-files =
prefs =
javascript.options.large_arraybuffers=true
javascript.options.experimental.ergonomic_brand_checks=true
javascript.options.experimental.enable_change_array_by_copy=false
[test_APIExposer.xhtml]
[test_bug361111.xhtml]

View File

@ -44,6 +44,7 @@ prefs =
javascript.options.weakrefs=true
javascript.options.experimental.ergonomic_brand_checks=true
javascript.options.experimental.top_level_await=true
javascript.options.experimental.enable_change_array_by_copy=false
[test_bug384632.html]
[test_bug390488.html]

View File

@ -6088,6 +6088,12 @@
value: true
mirror: always
# Experimental support for change-array-by-copy methods
- name: javascript.options.experimental.enable_change_array_by_copy
type: bool
value: false
mirror: always
# Experimental support for Top-level Await in JavaScript.
- name: javascript.options.experimental.top_level_await
type: bool