Bug 1143679 - Make TryNoteIterIon behave more like Baseline/interpreter iterators. r=shu, a=2.1+
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 10 Jun 2015 18:01:09 +0200
changeset 222256 7d767fc15126d98a5551573a963380d4c491931a
parent 222255 59a51b51fe1de9a9b4a4344c16b002affe35ea7f
child 222257 0fab69ac3d6ceedfdaf6486dff09d3085e45f507
child 222259 b88e1521b135d4c579033da782887f3a3e73e8b4
push id178
push uservliu@mozilla.com
push dateFri, 12 Jun 2015 01:39:17 +0000
treeherdermozilla-b2g34_v2_1s@0fab69ac3d6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu, 2
bugs1143679
milestone34.0
Bug 1143679 - Make TryNoteIterIon behave more like Baseline/interpreter iterators. r=shu, a=2.1+
js/src/jit/IonFrames.cpp
--- a/js/src/jit/IonFrames.cpp
+++ b/js/src/jit/IonFrames.cpp
@@ -368,24 +368,30 @@ JitFrameIterator::machineState() const
             (*iter).alignedAliased(a, &ftmp);
             machine.setRegisterLocation(ftmp, (double*)floatSpill);
         }
     }
 
     return machine;
 }
 
+static uint32_t
+NumArgAndLocalSlots(const InlineFrameIterator& frame)
+{
+    JSScript* script = frame.script();
+    return CountArgSlots(script, frame.maybeCallee()) + script->nfixed();
+}
+
 static void
-CloseLiveIterator(JSContext* cx, const InlineFrameIterator& frame, uint32_t localSlot)
+CloseLiveIterator(JSContext* cx, const InlineFrameIterator& frame, uint32_t stackSlot)
 {
     SnapshotIterator si = frame.snapshotIterator();
 
     // Skip stack slots until we reach the iterator object.
-    uint32_t base = CountArgSlots(frame.script(), frame.maybeCallee()) + frame.script()->nfixed();
-    uint32_t skipSlots = base + localSlot - 1;
+    uint32_t skipSlots = NumArgAndLocalSlots(frame) + stackSlot - 1;
 
     for (unsigned i = 0; i < skipSlots; i++)
         si.skip();
 
     Value v = si.read();
     RootedObject obj(cx, &v.toObject());
 
     if (cx->isExceptionPending())
@@ -419,26 +425,34 @@ HandleExceptionIon(JSContext* cx, const 
         ExceptionBailoutInfo propagateInfo;
         uint32_t retval = ExceptionHandlerBailout(cx, frame, rfe, propagateInfo, overrecursed);
         bailedOutForDebugMode = retval == BAILOUT_RETURN_OK;
     }
 
     if (!script->hasTrynotes())
         return;
 
+    uint32_t base = NumArgAndLocalSlots(frame);
+    SnapshotIterator si = frame.snapshotIterator();
+    JS_ASSERT(si.numAllocations() >= base);
+    const uint32_t stackDepth = si.numAllocations() - base;
+
     JSTryNote* tn = script->trynotes()->vector;
     JSTryNote* tnEnd = tn + script->trynotes()->length;
 
     uint32_t pcOffset = uint32_t(pc - script->main());
     for (; tn != tnEnd; ++tn) {
         if (pcOffset < tn->start)
             continue;
         if (pcOffset >= tn->start + tn->length)
             continue;
 
+        if (tn->stackDepth > stackDepth)
+            continue;
+
         switch (tn->kind) {
           case JSTRY_ITER: {
             JS_ASSERT(JSOp(*(script->main() + tn->start + tn->length)) == JSOP_ENDITER);
             JS_ASSERT(tn->stackDepth > 0);
 
             uint32_t localSlot = tn->stackDepth;
             CloseLiveIterator(cx, frame, localSlot);
             break;