Bug 1304551 - Properly handle bound functions in getBacktrace. r=efaust
authorTill Schneidereit <till@tillschneidereit.net>
Thu, 29 Sep 2016 15:31:20 +0200
changeset 347929 0394048027e82fc887c9e8008b6bd468d4c4a49e
parent 347928 ad7523af20b9386d4770e7d124ba42ba8b061a70
child 347930 c71bdc18c5c77be4f8b40ced4adac2ba44b6b34c
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1304551
milestone52.0a1
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;