Bug 1261826 part 1.5 - Extract assertions from JSScript::fullyInitFromEmitter. r=jorendorff
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Tue, 17 May 2016 17:15:52 +0000
changeset 297689 c922e32b439f2afb13742d27eb11667765a97a3a
parent 297688 13a71864396dfbd48a764932e16a0abef067c5f3
child 297690 e89325dee16d630f531ba1e46a49da7fb6d1cef4
push id76868
push usernpierron@mozilla.com
push dateTue, 17 May 2016 17:16:30 +0000
treeherdermozilla-inbound@2e29695fee87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1261826
milestone49.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 1261826 part 1.5 - Extract assertions from JSScript::fullyInitFromEmitter. r=jorendorff
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -2989,41 +2989,17 @@ JSScript::fullyInitFromEmitter(Exclusive
     PodCopy<jsbytecode>(code + prologueLength, bce->main.code.begin(), mainLength);
     bce->copySrcNotes((jssrcnote*)(code + script->length()), nsrcnotes);
     InitAtomMap(bce->atomIndices.getMap(), ssd->atoms());
 
     if (!SaveSharedScriptData(cx, script, ssd, nsrcnotes))
         return false;
 
 #ifdef DEBUG
-    FunctionBox* funbox = bce->sc->isFunctionBox() ? bce->sc->asFunctionBox() : nullptr;
-
-    // Assert that the properties set by linkToFunctionFromEmitter are
-    // correct.
-    if (funbox) {
-        MOZ_ASSERT(script->funHasExtensibleScope_ == funbox->hasExtensibleScope());
-        MOZ_ASSERT(script->funNeedsDeclEnvObject_ == funbox->needsDeclEnvObject());
-        MOZ_ASSERT(script->needsHomeObject_ == funbox->needsHomeObject());
-        MOZ_ASSERT(script->isDerivedClassConstructor_ == funbox->isDerivedClassConstructor());
-        MOZ_ASSERT(script->argumentsHasVarBinding() == funbox->argumentsHasLocalBinding());
-        MOZ_ASSERT(script->hasMappedArgsObj() == funbox->hasMappedArgsObj());
-        MOZ_ASSERT(script->functionHasThisBinding() == funbox->hasThisBinding());
-        MOZ_ASSERT(script->functionNonDelazifying() == funbox->function());
-        MOZ_ASSERT(script->isGeneratorExp_ == funbox->inGenexpLambda);
-        MOZ_ASSERT(script->generatorKind() == funbox->generatorKind());
-    } else {
-        MOZ_ASSERT(!script->funHasExtensibleScope_);
-        MOZ_ASSERT(!script->funNeedsDeclEnvObject_);
-        MOZ_ASSERT(!script->needsHomeObject_);
-        MOZ_ASSERT(!script->isDerivedClassConstructor_);
-        MOZ_ASSERT(!script->argumentsHasVarBinding());
-        MOZ_ASSERT(!script->hasMappedArgsObj());
-        MOZ_ASSERT(!script->isGeneratorExp_);
-        MOZ_ASSERT(script->generatorKind() == NotGenerator);
-    }
+    script->assertLinkedProperties(bce);
 #endif
 
     if (bce->constList.length() != 0)
         bce->constList.finish(script->consts());
     if (bce->objectList.length != 0)
         bce->objectList.finish(script->objects());
     if (bce->tryNoteList.length() != 0)
         bce->tryNoteList.finish(script->trynotes());
@@ -3049,16 +3025,48 @@ JSScript::fullyInitFromEmitter(Exclusive
             script->funHasAnyAliasedFormal_ = true;
             break;
         }
     }
 
     return true;
 }
 
+#ifdef DEBUG
+void
+JSScript::assertLinkedProperties(js::frontend::BytecodeEmitter* bce) const
+{
+    FunctionBox* funbox = bce->sc->isFunctionBox() ? bce->sc->asFunctionBox() : nullptr;
+
+    // Assert that the properties set by linkToFunctionFromEmitter are
+    // correct.
+    if (funbox) {
+        MOZ_ASSERT(funHasExtensibleScope_ == funbox->hasExtensibleScope());
+        MOZ_ASSERT(funNeedsDeclEnvObject_ == funbox->needsDeclEnvObject());
+        MOZ_ASSERT(needsHomeObject_ == funbox->needsHomeObject());
+        MOZ_ASSERT(isDerivedClassConstructor_ == funbox->isDerivedClassConstructor());
+        MOZ_ASSERT(argumentsHasVarBinding() == funbox->argumentsHasLocalBinding());
+        MOZ_ASSERT(hasMappedArgsObj() == funbox->hasMappedArgsObj());
+        MOZ_ASSERT(functionHasThisBinding() == funbox->hasThisBinding());
+        MOZ_ASSERT(functionNonDelazifying() == funbox->function());
+        MOZ_ASSERT(isGeneratorExp_ == funbox->inGenexpLambda);
+        MOZ_ASSERT(generatorKind() == funbox->generatorKind());
+    } else {
+        MOZ_ASSERT(!funHasExtensibleScope_);
+        MOZ_ASSERT(!funNeedsDeclEnvObject_);
+        MOZ_ASSERT(!needsHomeObject_);
+        MOZ_ASSERT(!isDerivedClassConstructor_);
+        MOZ_ASSERT(!argumentsHasVarBinding());
+        MOZ_ASSERT(!hasMappedArgsObj());
+        MOZ_ASSERT(!isGeneratorExp_);
+        MOZ_ASSERT(generatorKind() == NotGenerator);
+    }
+}
+#endif
+
 size_t
 JSScript::computedSizeOfData() const
 {
     return dataSize();
 }
 
 size_t
 JSScript::sizeOfData(mozilla::MallocSizeOf mallocSizeOf) const
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1242,16 +1242,23 @@ class JSScript : public js::gc::TenuredC
                                      js::frontend::BytecodeEmitter* bce);
     static void linkToFunctionFromEmitter(js::ExclusiveContext* cx, JS::Handle<JSScript*> script,
                                           js::frontend::FunctionBox* funbox);
     static void linkToModuleFromEmitter(js::ExclusiveContext* cx, JS::Handle<JSScript*> script,
                                         js::frontend::ModuleBox* funbox);
     // Initialize a no-op script.
     static bool fullyInitTrivial(js::ExclusiveContext* cx, JS::Handle<JSScript*> script);
 
+#ifdef DEBUG
+  private:
+    // Assert that the properties set by linkToFunctionFromEmitter are correct.
+    void assertLinkedProperties(js::frontend::BytecodeEmitter* bce) const;
+#endif
+
+  public:
     inline JSPrincipals* principals();
 
     JSCompartment* compartment() const { return compartment_; }
     JSCompartment* maybeCompartment() const { return compartment(); }
 
     void setVersion(JSVersion v) { version = v; }
 
     // Script bytecode is immutable after creation.