Bug 1533571 - Do not mark the return opcode as breakable for expression-body arrow functions. r=jlast
authorLogan Smyth <loganfsmyth@gmail.com>
Fri, 08 Mar 2019 14:54:18 +0000
changeset 521169 ea20a62a2fa0
parent 521168 2ccf4b1b18ad
child 521170 0f38d240b024
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1533571
milestone67.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 1533571 - Do not mark the return opcode as breakable for expression-body arrow functions. r=jlast Differential Revision: https://phabricator.services.mozilla.com/D22617
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2540,18 +2540,25 @@ bool BytecodeEmitter::emitFunctionScript
   setFunctionBodyEndPos(body->pn_pos);
   if (!emitTree(body)) {
     return false;
   }
 
   if (!updateSourceCoordNotes(body->pn_pos.end)) {
     return false;
   }
-  if (!markSimpleBreakpoint()) {
-    return false;
+
+  // We only want to mark the end of a function as a breakable position if
+  // there is token there that the user can easily associate with the function
+  // as a whole. Since arrow function single-expression bodies have no closing
+  // curly bracket, we do not place a breakpoint at their end position.
+  if (!funbox->hasExprBody()) {
+    if (!markSimpleBreakpoint()) {
+      return false;
+    }
   }
 
   // Always end the script with a JSOP_RETRVAL. Some other parts of the
   // codebase depend on this opcode,
   // e.g. InterpreterRegs::setToEndOfScript.
   if (!emit1(JSOP_RETRVAL)) {
     return false;
   }
--- a/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js
+++ b/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js
@@ -279,16 +279,22 @@ assertBreakpoints(`
   /*B*/};
 `);
 assertBreakpoints(`
   var fn = /*S*/async arg => {
     /*S*/console./*B*/log("fn");
   /*B*/};
 `);
 assertBreakpoints(`
+  var fn = /*S*/(arg) => /*S*/console./*B*/log("fn");
+  var fn = /*S*/async (arg) => /*S*/console./*B*/log("fn");
+  var fn = /*S*/arg => /*S*/console./*B*/log("fn");
+  var fn = /*S*/async arg => /*S*/console./*B*/log("fn");
+`);
+assertBreakpoints(`
   if ((/*S*/delete /*B*/fn().prop) + /*B*/b()) {
     /*S*/console./*B*/log("foo");
   }
 `);
 assertBreakpoints(`
   for (var j = /*S*/0; (/*S*/o.a) < 3; (/*S*/j++, /*B*/a(), /*B*/b())) {
     /*S*/console./*B*/log(i);
   }