Bug 1438121: Part 3: Add shell tests for implicit async stacks. r=fitzgen
authorJim Blandy <jimb@mozilla.com>
Sun, 25 Feb 2018 16:22:32 -0800
changeset 461706 f72fd25e822fc7c8f625a0b6f659a7aaee4d4a41
parent 461705 4ca86bbdc4090adb24956c783e1b42fd495e0f1f
child 461707 61ca8af8e31332158c4307c8277282d27012d46e
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1438121
milestone60.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 1438121: Part 3: Add shell tests for implicit async stacks. r=fitzgen MozReview-Commit-ID: BfPPrvEGSgg
js/src/jit-test/tests/saved-stacks/async-implicit.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/saved-stacks/async-implicit.js
@@ -0,0 +1,52 @@
+// Test AutoSetAsyncStackForNewCalls's IMPLICIT kind.
+
+// Given a SavedFrame stack, return a string listing the frame's function names
+// and their async causes, if any.
+function stackFunctions(stack) {
+  const frames = [];
+  for (; stack; stack = stack.parent || stack.asyncParent) {
+    if (!stack.functionDisplayName) {
+      frames.push('(top level)');
+    } else if (stack.asyncCause) {
+      frames.push(`${stack.asyncCause}*${stack.functionDisplayName}`);
+    } else {
+      frames.push(stack.functionDisplayName);
+    }
+  }
+  return frames.join(', ');
+}
+
+let fakeStack = (function fake1() {
+  function fake2() {
+    return saveStack();
+  }
+  return fake2();
+})();
+
+function bindAndExpect(options, expected) {
+  function bindee() {
+    assertEq(stackFunctions(saveStack()), expected);
+  }
+
+  return bindToAsyncStack(bindee, options);
+}
+
+function caller(f) {
+  return f();
+}
+
+// An explicit async stack always overrides the actual callers of the bindee.
+// An implicit async stack never overrides callers; it is only attached when
+// the stack is otherwise empty.
+caller(bindAndExpect({ stack: fakeStack, cause: 'ano', explicit: false },
+                     "bindee, caller, (top level)"));
+
+caller(bindAndExpect({ stack: fakeStack, cause: 'hi', explicit: true },
+                     "bindee, hi*fake2, fake1, (top level)"));
+
+enqueueJob(bindAndExpect({ stack: fakeStack, cause: 'mita', explicit: false },
+                         "bindee, mita*fake2, fake1, (top level)"));
+
+enqueueJob(bindAndExpect({ stack: fakeStack, cause: 'hana', explicit: true },
+                         "bindee, hana*fake2, fake1, (top level)"));
+