Bug 1559275 - Add TransistiveCompileOptions::discardSource. r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Wed, 19 Jun 2019 00:27:40 +0000
changeset 479171 28a43f9cc6b1db6a5e8dea7b71f712f834b7be5f
parent 479170 901f51251ea98b9dda14859c4ae09c5655ceed63
child 479172 960c9f0926e9e5a557e09d1f017e8d5996a4237d
push id36172
push userrgurzau@mozilla.com
push dateWed, 19 Jun 2019 09:55:37 +0000
treeherdermozilla-central@8bce401b8833 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1559275
milestone69.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 1559275 - Add TransistiveCompileOptions::discardSource. r=jandem Check realm flags at when creating CompileOptions rather than during compilation. This is helpful for pre-compiling self-hosting code. Differential Revision: https://phabricator.services.mozilla.com/D34976
js/public/CompileOptions.h
js/src/frontend/BytecodeCompiler.cpp
js/src/jsapi.cpp
js/src/vm/JSScript.cpp
--- a/js/public/CompileOptions.h
+++ b/js/public/CompileOptions.h
@@ -107,16 +107,17 @@ class JS_PUBLIC_API TransitiveCompileOpt
   bool selfHostingMode = false;
   bool canLazilyParse = true;
   bool strictOption = false;
   bool extraWarningsOption = false;
   bool werrorOption = false;
   AsmJSOption asmJSOption = AsmJSOption::Disabled;
   bool throwOnAsmJSValidationFailureOption = false;
   bool forceAsync = false;
+  bool discardSource = false;
   bool sourceIsLazy = false;
   bool allowHTMLComments = true;
   bool hideScriptFromDebugger = false;
   bool bigIntEnabledOption = false;
   bool fieldsEnabledOption = false;
 
   /**
    * |introductionType| is a statically allocated C string: one of "eval",
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -399,17 +399,17 @@ bool BytecodeCompiler::createScriptSourc
 
   scriptSource = sourceObject->source();
   return true;
 }
 
 bool BytecodeCompiler::canLazilyParse() const {
   return options.canLazilyParse &&
          !cx->realm()->behaviors().disableLazyParsing() &&
-         !cx->realm()->behaviors().discardSource() && !options.sourceIsLazy &&
+         !options.discardSource && !options.sourceIsLazy &&
          !coverage::IsLCovEnabled() &&
          // Disabled during record/replay. The replay debugger requires
          // scripts to be constructed in a consistent order, which might not
          // happen with lazy parsing.
          !mozilla::recordreplay::IsRecordingOrReplaying();
 }
 
 template <typename Unit>
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3463,16 +3463,17 @@ void JS::TransitiveCompileOptions::copyP
   selfHostingMode = rhs.selfHostingMode;
   canLazilyParse = rhs.canLazilyParse;
   strictOption = rhs.strictOption;
   extraWarningsOption = rhs.extraWarningsOption;
   werrorOption = rhs.werrorOption;
   asmJSOption = rhs.asmJSOption;
   throwOnAsmJSValidationFailureOption = rhs.throwOnAsmJSValidationFailureOption;
   forceAsync = rhs.forceAsync;
+  discardSource = rhs.discardSource;
   sourceIsLazy = rhs.sourceIsLazy;
   introductionType = rhs.introductionType;
   introductionLineno = rhs.introductionLineno;
   introductionOffset = rhs.introductionOffset;
   hasIntroductionInfo = rhs.hasIntroductionInfo;
   hideScriptFromDebugger = rhs.hideScriptFromDebugger;
   bigIntEnabledOption = rhs.bigIntEnabledOption;
   fieldsEnabledOption = rhs.fieldsEnabledOption;
@@ -3555,16 +3556,17 @@ bool JS::OwningCompileOptions::copy(JSCo
 JS::CompileOptions::CompileOptions(JSContext* cx)
     : ReadOnlyCompileOptions(),
       elementRoot(cx),
       elementAttributeNameRoot(cx),
       introductionScriptRoot(cx),
       scriptOrModuleRoot(cx) {
   strictOption = cx->options().strictMode();
   extraWarningsOption = cx->realm()->behaviors().extraWarnings(cx);
+  discardSource = cx->realm()->behaviors().discardSource();
   werrorOption = cx->options().werror();
   if (!cx->options().asmJS()) {
     asmJSOption = AsmJSOption::Disabled;
   } else if (cx->realm()->debuggerObservesAsmJS()) {
     asmJSOption = AsmJSOption::DisabledByDebugger;
   } else {
     asmJSOption = AsmJSOption::Enabled;
   }
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -2295,17 +2295,17 @@ MOZ_MUST_USE bool ScriptSource::initiali
 
 template <typename Unit>
 bool ScriptSource::assignSource(JSContext* cx,
                                 const ReadOnlyCompileOptions& options,
                                 SourceText<Unit>& srcBuf) {
   MOZ_ASSERT(data.is<Missing>(),
              "source assignment should only occur on fresh ScriptSources");
 
-  if (cx->realm()->behaviors().discardSource()) {
+  if (options.discardSource) {
     return true;
   }
 
   if (options.sourceIsLazy) {
     data = SourceType(Retrievable<Unit>());
     return true;
   }