Bug 1528057 - Set async method name properly. r=jorendorff
authorTooru Fujisawa <arai_a@mac.com>
Fri, 15 Feb 2019 19:22:16 +0000
changeset 459586 64eed6f2cc174243c9a17b4583e75e2256d2cd70
parent 459585 95b6997c334afa45b588408bc25b99c9f26b391d
child 459587 b2eade4222d67953d708c5b47111cf1f6bcec2e5
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1528057
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 1528057 - Set async method name properly. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D19905
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/auto-regress/class-method-async.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3165,25 +3165,40 @@ bool BytecodeEmitter::emitAnonymousFunct
 }
 
 bool BytecodeEmitter::emitAnonymousFunctionWithComputedName(
     ParseNode* node, FunctionPrefixKind prefixKind) {
   MOZ_ASSERT(node->isDirectRHSAnonFunction());
 
   if (node->is<FunctionNode>()) {
     if (!emitTree(node)) {
+      //            [stack] # !isAsync || !needsHomeObject
       //            [stack] NAME FUN
-      return false;
-    }
-    if (!emitDupAt(1)) {
+      //            [stack] # isAsync && needsHomeObject
+      //            [stack] NAME UNWRAPPED WRAPPED
+      return false;
+    }
+    unsigned depth = 1;
+    FunctionNode* funNode = &node->as<FunctionNode>();
+    FunctionBox* funbox = funNode->funbox();
+    if (funbox->isAsync() && funbox->needsHomeObject()) {
+      depth = 2;
+    }
+    if (!emitDupAt(depth)) {
+      //            [stack] # !isAsync || !needsHomeObject
       //            [stack] NAME FUN NAME
+      //            [stack] # isAsync && needsHomeObject
+      //            [stack] NAME UNWRAPPED WRAPPED NAME
       return false;
     }
     if (!emit2(JSOP_SETFUNNAME, uint8_t(prefixKind))) {
+      //            [stack] # !isAsync || !needsHomeObject
       //            [stack] NAME FUN
+      //            [stack] # isAsync && needsHomeObject
+      //            [stack] NAME UNWRAPPED WRAPPED
       return false;
     }
     return true;
   }
 
   MOZ_ASSERT(node->is<ClassNode>());
   MOZ_ASSERT(prefixKind == FunctionPrefixKind::None);
 
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/auto-regress/class-method-async.js
@@ -0,0 +1,5 @@
+class X {
+    async ["foo"]() {
+        return eval();
+    }
+}