Bug 1498320 - Move script creation into prepareScriptParse. r=tcampbell
authorJeff Walden <jwalden@mit.edu>
Thu, 11 Oct 2018 13:54:42 -0700
changeset 445974 37b4694f5fcf00a528927af61f53aef699f994ee
parent 445973 ac6aea751ee94e8cdff017c7955ee4e92da7c190
child 445975 b0c005ef9cee4271fd458298d4f4a0f1d8c81cb3
push id35030
push usercsabou@mozilla.com
push dateTue, 13 Nov 2018 04:24:01 +0000
treeherdermozilla-central@f6df375b8698 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1498320
milestone65.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 1498320 - Move script creation into prepareScriptParse. r=tcampbell
js/src/frontend/BytecodeCompiler.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -46,17 +46,17 @@ class MOZ_STACK_CLASS BytecodeCompiler
     // Construct an object passing mandatory arguments.
     BytecodeCompiler(JSContext* cx,
                      const ReadOnlyCompileOptions& options,
                      SourceBufferHolder& sourceBuffer,
                      HandleScope enclosingScope);
 
     // Call this before calling compile{Global,Eval}Script.
     MOZ_MUST_USE bool prepareScriptParse() {
-        return createSourceAndParser(ParseGoal::Script);
+        return createSourceAndParser(ParseGoal::Script) && createScript();
     }
 
     JSScript* compileGlobalScript(ScopeKind scopeKind);
     JSScript* compileEvalScript(HandleObject environment, HandleScope enclosingScope);
 
     // Call this before calling compileModule.
     MOZ_MUST_USE bool prepareModuleParse() {
         return createSourceAndParser(ParseGoal::Module);
@@ -78,16 +78,21 @@ class MOZ_STACK_CLASS BytecodeCompiler
   private:
     void assertSourceAndParserCreated() const {
         MOZ_ASSERT(sourceObject != nullptr);
         MOZ_ASSERT(scriptSource != nullptr);
         MOZ_ASSERT(usedNames.isSome());
         MOZ_ASSERT(parser.isSome());
     }
 
+    void assertSourceParserAndScriptCreated() const {
+        assertSourceAndParserCreated();
+        MOZ_ASSERT(script != nullptr);
+    }
+
     JSScript* compileScript(HandleObject environment, SharedContext* sc);
     bool checkLength();
     bool createScriptSource(const Maybe<uint32_t>& parameterListEnd);
     bool canLazilyParse();
     bool createParser(ParseGoal goal);
     bool createSourceAndParser(ParseGoal goal,
                                const Maybe<uint32_t>& parameterListEnd = Nothing());
 
@@ -345,21 +350,17 @@ BytecodeCompiler::deoptimizeArgumentsInE
     }
 
     return true;
 }
 
 JSScript*
 BytecodeCompiler::compileScript(HandleObject environment, SharedContext* sc)
 {
-    assertSourceAndParserCreated();
-
-    if (!createScript()) {
-        return nullptr;
-    }
+    assertSourceParserAndScriptCreated();
 
     TokenStreamPosition startPosition(keepAtoms, parser->tokenStream);
 
     Maybe<BytecodeEmitter> emitter;
     if (!emplaceEmitter(emitter, sc)) {
         return nullptr;
     }