Bug 1143679 - Make TryNoteIterIon behave more like Baseline/interpreter iterators. r=shu, a=sledru
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 10 Jun 2015 18:01:09 +0200
changeset 266216 c5327254125d
parent 266211 4241def0561b
child 266217 d787fb3b86be
push id4791
push userjandemooij@gmail.com
push date2015-06-10 16:01 +0000
treeherdermozilla-beta@c5327254125d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu, sledru
bugs1143679
milestone39.0
Bug 1143679 - Make TryNoteIterIon behave more like Baseline/interpreter iterators. r=shu, a=sledru
js/src/jit/JitFrames.cpp
--- a/js/src/jit/JitFrames.cpp
+++ b/js/src/jit/JitFrames.cpp
@@ -364,24 +364,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.maybeCalleeTemplate()) + 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.maybeCalleeTemplate()) + 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())
@@ -440,26 +446,34 @@ HandleExceptionIon(JSContext* cx, const 
         if (rematFrame)
             Debugger::assertNotInFrameMaps(rematFrame);
 #endif
     }
 
     if (!script->hasTrynotes())
         return;
 
+    uint32_t base = NumArgAndLocalSlots(frame);
+    SnapshotIterator si = frame.snapshotIterator();
+    MOZ_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_FOR_IN: {
             MOZ_ASSERT(JSOp(*(script->main() + tn->start + tn->length)) == JSOP_ENDITER);
             MOZ_ASSERT(tn->stackDepth > 0);
 
             uint32_t localSlot = tn->stackDepth;
             CloseLiveIterator(cx, frame, localSlot);
             break;