Bug 1304551 - Properly handle bound functions in getBacktrace. r=efaust
authorTill Schneidereit <till@tillschneidereit.net>
Thu, 29 Sep 2016 15:31:20 +0200
changeset 321094 0394048027e82fc887c9e8008b6bd468d4c4a49e
parent 321093 ad7523af20b9386d4770e7d124ba42ba8b061a70
child 321095 c71bdc18c5c77be4f8b40ced4adac2ba44b6b34c
push id83527
push usertschneidereit@gmail.com
push dateFri, 04 Nov 2016 23:48:34 +0000
treeherdermozilla-inbound@c71bdc18c5c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1304551
milestone52.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 1304551 - Properly handle bound functions in getBacktrace. r=efaust getBacktrace, when invoked with `{locals:true}`, prints the `this` value for each frame, where applicable. When constructing bound functions, the `this` value is magic, which FormatFrame doesn't handle. Since printing that `this` value isn't useful, we just skip it. MozReview-Commit-ID: 8axhOqyrA2B
js/src/jit-test/tests/self-hosting/get-backtrace-in-constructing-bound-function.js
js/src/jsfriendapi.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/self-hosting/get-backtrace-in-constructing-bound-function.js
@@ -0,0 +1,6 @@
+function t() {
+    getBacktrace({ locals: true });
+}
+var f = t.bind();
+new f();
+f();
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -797,17 +797,18 @@ FormatFrame(JSContext* cx, const FrameIt
     RootedFunction fun(cx, iter.maybeCallee(cx));
     RootedString funname(cx);
     if (fun)
         funname = fun->displayAtom();
 
     RootedValue thisVal(cx);
     if (iter.hasUsableAbstractFramePtr() &&
         iter.isFunctionFrame() &&
-        fun && !fun->isArrow() && !fun->isDerivedClassConstructor())
+        fun && !fun->isArrow() && !fun->isDerivedClassConstructor() &&
+        !(fun->isBoundFunction() && iter.isConstructing()))
     {
         if (!GetFunctionThis(cx, iter.abstractFramePtr(), &thisVal))
             return nullptr;
     }
 
     // print the frame number and function name
     if (funname) {
         JSAutoByteString funbytes;