Skip to content

Commit

Permalink
Bug 1681046 - Enable Top Level Await by default r=mgaudet
Browse files Browse the repository at this point in the history
  • Loading branch information
codehag committed Apr 8, 2021
1 parent 3322a7e commit 685df4d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/public/CompileOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class JS_PUBLIC_API TransitiveCompileOptions {
bool nonSyntacticScope = false;
bool privateClassFields = false;
bool privateClassMethods = false;
bool topLevelAwait = false;
bool topLevelAwait = true;

// True if transcoding to XDR should use Stencil instead of JSScripts.
bool useStencilXDR = false;
Expand Down
2 changes: 1 addition & 1 deletion js/public/ContextOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class JS_PUBLIC_API ContextOptions {
fuzzing_(false),
privateClassFields_(false),
privateClassMethods_(false),
topLevelAwait_(false) {
topLevelAwait_(true) {
}

bool asmJS() const { return asmJS_; }
Expand Down
6 changes: 4 additions & 2 deletions js/src/jsapi-tests/testStencil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ bool basic_test(const CharT* chars) {
JS::RootedValue rval(cx);
CHECK(JS::ModuleInstantiate(cx, moduleObject));
CHECK(JS::ModuleEvaluate(cx, moduleObject, &rval));
CHECK(rval.isUndefined());
CHECK(!rval.isUndefined());

js::RunJobs(cx);
CHECK(JS_GetProperty(cx, global, "x", &rval));
CHECK(rval.isNumber() && rval.toNumber() == 42);

Expand Down Expand Up @@ -339,8 +340,9 @@ BEGIN_TEST(testStencil_OffThreadModule) {
JS::RootedValue rval(cx);
CHECK(JS::ModuleInstantiate(cx, moduleObject));
CHECK(JS::ModuleEvaluate(cx, moduleObject, &rval));
CHECK(rval.isUndefined());
CHECK(!rval.isUndefined());

js::RunJobs(cx);
CHECK(JS_GetProperty(cx, global, "x", &rval));
CHECK(rval.isNumber() && rval.toNumber() == 42);

Expand Down
2 changes: 1 addition & 1 deletion js/src/shell/js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ bool shell::enablePropertyErrorMessageFix = false;
bool shell::enableIteratorHelpers = false;
bool shell::enablePrivateClassFields = false;
bool shell::enablePrivateClassMethods = false;
bool shell::enableTopLevelAwait = false;
bool shell::enableTopLevelAwait = true;
bool shell::useOffThreadParseGlobal = true;
#ifdef JS_GC_ZEAL
uint32_t shell::gZealBits = 0;
Expand Down
10 changes: 3 additions & 7 deletions js/xpconnect/src/XPCJSContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,9 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
sWeakRefsExposeCleanupSome = Preferences::GetBool(
JS_OPTIONS_DOT_STR "experimental.weakrefs.expose_cleanupSome");

bool topLevelAwaitEnabled =
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.top_level_await");

// Require private fields disabled outside of nightly.
bool privateFieldsEnabled = false;
bool privateMethodsEnabled = false;
Expand All @@ -987,13 +990,6 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.private_methods");
#endif

// Require top level await disabled outside of nightly.
bool topLevelAwaitEnabled = false;
#ifdef NIGHTLY_BUILD
topLevelAwaitEnabled =
Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.top_level_await");
#endif

#ifdef JS_GC_ZEAL
int32_t zeal = Preferences::GetInt(JS_OPTIONS_DOT_STR "gczeal", -1);
int32_t zeal_frequency = Preferences::GetInt(
Expand Down
4 changes: 2 additions & 2 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5592,13 +5592,13 @@
type: bool
value: false
mirror: always
#endif // NIGHTLY_BUILD

# Experimental support for Top-level Await in JavaScript.
- name: javascript.options.experimental.top_level_await
type: bool
value: false
value: true
mirror: always
#endif // NIGHTLY_BUILD

# The amount of time we wait between a request to GC (due to leaving a page) and doing the actual GC, in ms.
- name: javascript.options.gc_delay
Expand Down

0 comments on commit 685df4d

Please sign in to comment.