Bug 1034477 - Save stacks that cross contexts in js::SavedStacks. r=shu
authorNick Fitzgerald <fitzgen@mozilla.com>
Thu, 10 Jul 2014 12:33:00 -0400
changeset 215507 5048d0b0b825eb024da2464db1d283cf0188e227
parent 215506 8c9cdf2b5ab4b1747afb4febedb50edf1f22578e
child 215508 6808a2c6eab4d647e66afa872a831ec392d456cc
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1034477
milestone33.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 1034477 - Save stacks that cross contexts in js::SavedStacks. r=shu
js/src/jit-test/tests/saved-stacks/new-context.js
js/src/vm/SavedStacks.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/saved-stacks/new-context.js
@@ -0,0 +1,24 @@
+// Test that we can save stacks that cross contexts.
+
+const stack = (function iife() {
+  return evaluate("(" + function evalFrame() {
+    return saveStack();
+  } + "())", {
+    newContext: true,
+    fileName: "evaluated"
+  });
+}());
+
+print(stack);
+
+assertEq(stack.functionDisplayName, "evalFrame");
+assertEq(stack.source, "evaluated");
+
+assertEq(stack.parent.source, "evaluated");
+
+assertEq(stack.parent.parent.functionDisplayName, "iife");
+assertEq(/new-context\.js$/.test(stack.parent.parent.source), true);
+
+assertEq(/new-context\.js$/.test(stack.parent.parent.parent.source), true);
+
+assertEq(stack.parent.parent.parent.parent, null);
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -396,17 +396,17 @@ SavedStacks::init()
 }
 
 bool
 SavedStacks::saveCurrentStack(JSContext *cx, MutableHandleSavedFrame frame, unsigned maxFrameCount)
 {
     JS_ASSERT(initialized());
     JS_ASSERT(&cx->compartment()->savedStacks() == this);
 
-    FrameIter iter(cx);
+    FrameIter iter(cx, FrameIter::ALL_CONTEXTS, FrameIter::GO_THROUGH_SAVED);
     return insertFrames(cx, iter, frame, maxFrameCount);
 }
 
 void
 SavedStacks::sweep(JSRuntime *rt)
 {
     if (frames.initialized()) {
         for (SavedFrame::Set::Enum e(frames); !e.empty(); e.popFront()) {