Bug 996533 - Add some BaselineScript/IonScript asserts. r=till
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 15 Apr 2014 13:24:42 +0200
changeset 178556 f2808e5f4afe113d914b6e332411c765d6a3b06b
parent 178555 e17d61d6acf688fa6bec1b98b201dcdde47de5b6
child 178557 4d46754ac133ecbc09f2a311340ab17a79b9443e
push id26590
push userryanvm@gmail.com
push dateTue, 15 Apr 2014 16:25:35 +0000
treeherderautoland@1f932e462b84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs996533
milestone31.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 996533 - Add some BaselineScript/IonScript asserts. r=till
js/src/jit/BaselineBailouts.cpp
js/src/jit/IonFrames.cpp
js/src/jsscript.h
js/src/jsscriptinlines.h
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -477,16 +477,18 @@ GetNextNonLoopEntryPc(jsbytecode *pc)
 //
 static bool
 InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
                 HandleFunction fun, HandleScript script, IonScript *ionScript,
                 SnapshotIterator &iter, bool invalidate, BaselineStackBuilder &builder,
                 AutoValueVector &startFrameFormals, MutableHandleFunction nextCallee,
                 jsbytecode **callPC, const ExceptionBailoutInfo *excInfo)
 {
+    MOZ_ASSERT(script->hasBaselineScript());
+
     // If excInfo is non-nullptr, we are bailing out to a catch or finally block
     // and this is the frame where we will resume. Usually the expression stack
     // should be empty in this case but there can be iterators on the stack.
     uint32_t exprStackSlots;
     if (excInfo)
         exprStackSlots = excInfo->numExprSlots;
     else
         exprStackSlots = iter.numAllocations() - (script->nfixed() + CountArgSlots(script, fun));
@@ -1539,16 +1541,17 @@ jit::FinishBailoutToBaseline(BaselineBai
     IonFrameIterator iter(cx);
 
     uint32_t frameno = 0;
     while (frameno < numFrames) {
         JS_ASSERT(!iter.isIonJS());
 
         if (iter.isBaselineJS()) {
             BaselineFrame *frame = iter.baselineFrame();
+            MOZ_ASSERT(frame->script()->hasBaselineScript());
 
             // If the frame doesn't even have a scope chain set yet, then it's resuming
             // into the the prologue before the scope chain is initialized.  Any
             // necessary args object will also be initialized there.
             if (frame->scopeChain() && frame->script()->needsArgsObj()) {
                 ArgumentsObject *argsObj;
                 if (frame->hasArgsObj()) {
                     argsObj = &frame->argsObj();
--- a/js/src/jit/IonFrames.cpp
+++ b/js/src/jit/IonFrames.cpp
@@ -1589,16 +1589,17 @@ InlineFrameIteratorMaybeGC<allowGC>::fin
 {
     JS_ASSERT(more());
 
     si_ = start_;
 
     // Read the initial frame out of the C stack.
     callee_ = frame_->maybeCallee();
     script_ = frame_->script();
+    MOZ_ASSERT(script_->hasBaselineScript());
 
     // Settle on the outermost frame without evaluating any instructions before
     // looking for a pc.
     if (!si_.instruction()->isResumePoint())
         si_.nextFrame();
 
     pc_ = script_->offsetToPC(si_.pcOffset());
 #ifdef DEBUG
@@ -1647,16 +1648,17 @@ InlineFrameIteratorMaybeGC<allowGC>::fin
         si_.nextFrame();
 
         callee_ = &funval.toObject().as<JSFunction>();
 
         // Inlined functions may be clones that still point to the lazy script
         // for the executed script, if they are clones. The actual script
         // exists though, just make sure the function points to it.
         script_ = callee_->existingScript();
+        MOZ_ASSERT(script_->hasBaselineScript());
 
         pc_ = script_->offsetToPC(si_.pcOffset());
     }
 
     // The first time we do not know the number of frames, we only settle on the
     // last frame, and update the number of frames based on the number of
     // iteration that we have done.
     if (frameCount_ == UINT32_MAX) {
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1162,17 +1162,19 @@ class JSScript : public js::gc::Barriere
         return needsArgsObj() && !strict();
     }
 
     bool hasAnyIonScript() const {
         return hasIonScript() || hasParallelIonScript();
     }
 
     bool hasIonScript() const {
-        return ion && ion != ION_DISABLED_SCRIPT && ion != ION_COMPILING_SCRIPT;
+        bool res = ion && ion != ION_DISABLED_SCRIPT && ion != ION_COMPILING_SCRIPT;
+        MOZ_ASSERT_IF(res, baseline);
+        return res;
     }
     bool canIonCompile() const {
         return ion != ION_DISABLED_SCRIPT;
     }
 
     bool isIonCompilingOffThread() const {
         return ion == ION_COMPILING_SCRIPT;
     }
@@ -1186,21 +1188,24 @@ class JSScript : public js::gc::Barriere
     }
     js::jit::IonScript *const *addressOfIonScript() const {
         return &ion;
     }
     void setIonScript(js::jit::IonScript *ionScript) {
         if (hasIonScript())
             js::jit::IonScript::writeBarrierPre(tenuredZone(), ion);
         ion = ionScript;
+        MOZ_ASSERT_IF(hasIonScript(), hasBaselineScript());
         updateBaselineOrIonRaw();
     }
 
     bool hasBaselineScript() const {
-        return baseline && baseline != BASELINE_DISABLED_SCRIPT;
+        bool res = baseline && baseline != BASELINE_DISABLED_SCRIPT;
+        MOZ_ASSERT_IF(!res, !ion || ion == ION_DISABLED_SCRIPT);
+        return res;
     }
     bool canBaselineCompile() const {
         return baseline != BASELINE_DISABLED_SCRIPT;
     }
     js::jit::BaselineScript *baselineScript() const {
         JS_ASSERT(hasBaselineScript());
         return baseline;
     }
--- a/js/src/jsscriptinlines.h
+++ b/js/src/jsscriptinlines.h
@@ -163,13 +163,14 @@ JSScript::setIsCallsiteClone(JSObject *f
 
 inline void
 JSScript::setBaselineScript(JSContext *maybecx, js::jit::BaselineScript *baselineScript)
 {
 #ifdef JS_ION
     if (hasBaselineScript())
         js::jit::BaselineScript::writeBarrierPre(tenuredZone(), baseline);
 #endif
+    MOZ_ASSERT(!hasIonScript());
     baseline = baselineScript;
     updateBaselineOrIonRaw();
 }
 
 #endif /* jsscriptinlines_h */