Bug 1603188 - Add a pref to allow enabling deferred allocation mode by default in the browser r=tcampbell
authorMatthew Gaudet <mgaudet@mozilla.com>
Mon, 16 Dec 2019 21:43:48 +0000
changeset 507300 4b53cc825709c6dd1751e82837a76d07826a629a
parent 507299 419b94b1210e4304609821a7a4a1cb94e5317f99
child 507301 3cc518a2949a4127e8a4d6e0a062ba11545d0cf8
push id36925
push userapavel@mozilla.com
push dateTue, 17 Dec 2019 10:44:40 +0000
treeherdermozilla-central@83fc8cf83221 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1603188
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1603188 - Add a pref to allow enabling deferred allocation mode by default in the browser r=tcampbell Differential Revision: https://phabricator.services.mozilla.com/D57356
js/xpconnect/src/XPCJSContext.cpp
modules/libpref/init/StaticPrefList.yaml
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -753,29 +753,31 @@ static mozilla::Atomic<bool> sExtraWarni
 bool xpc::ExtraWarningsForSystemJS() { return sExtraWarningsForSystemJS; }
 #else
 bool xpc::ExtraWarningsForSystemJS() { return false; }
 #endif
 
 static mozilla::Atomic<bool> sSharedMemoryEnabled(false);
 static mozilla::Atomic<bool> sStreamsEnabled(false);
 static mozilla::Atomic<bool> sFieldsEnabled(false);
+static mozilla::Atomic<bool> sParserDeferAllocationEnabled(false);
 static mozilla::Atomic<bool> sAwaitFixEnabled(false);
 
 void xpc::SetPrefableRealmOptions(JS::RealmOptions& options) {
   options.creationOptions()
       .setSharedMemoryAndAtomicsEnabled(sSharedMemoryEnabled)
       .setCoopAndCoepEnabled(
           StaticPrefs::browser_tabs_remote_useCrossOriginOpenerPolicy() &&
           StaticPrefs::browser_tabs_remote_useCrossOriginEmbedderPolicy())
       .setStreamsEnabled(sStreamsEnabled)
       .setWritableStreamsEnabled(
           StaticPrefs::javascript_options_writable_streams())
       .setFieldsEnabled(sFieldsEnabled)
       .setAwaitFixEnabled(sAwaitFixEnabled);
+  options.behaviors().setDeferredParserAlloc(sParserDeferAllocationEnabled);
 }
 
 static void LoadStartupJSPrefs(XPCJSContext* xpccx) {
   // Prefs that require a restart are handled here. This includes the
   // process-wide JIT options because toggling these at runtime can easily cause
   // races or get us into an inconsistent state.
   //
   // 'Live' prefs are handled by ReloadPrefsCallback below.
@@ -926,16 +928,18 @@ static void ReloadPrefsCallback(const ch
 
   bool werror = Preferences::GetBool(JS_OPTIONS_DOT_STR "werror");
 
   bool extraWarnings = Preferences::GetBool(JS_OPTIONS_DOT_STR "strict");
 
   sSharedMemoryEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "shared_memory");
   sStreamsEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "streams");
+  sParserDeferAllocationEnabled =
+      Preferences::GetBool(JS_OPTIONS_DOT_STR "parser_defer_allocation");
   sFieldsEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.fields");
   sAwaitFixEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.await_fix");
 
 #ifdef DEBUG
   sExtraWarningsForSystemJS =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "strict.debug");
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -4098,16 +4098,22 @@
   type: uint32_t
 #ifdef NIGHTLY_BUILD
   value: 15000
 #else
   value: 300000
 #endif
   mirror: always
 
+# Defer allocation of GC objects as late as possible in a parse
+- name: javascript.options.parser_defer_allocation
+  type: RelaxedAtomicBool
+  value: false
+  mirror: always
+
 - name: javascript.options.experimental.fields
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
 - name: javascript.options.experimental.await_fix
   type: RelaxedAtomicBool
   value: true