Bug 1535804 - Part 2: Decrease nesting level in emitCreateFieldInitializers. r=arai! draft
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 19 Feb 2020 11:31:57 -0800
changeset 2648922 341de446f754c7509a36bc6d5302ce45cf0e65c0
parent 2648921 fc2b1b3508d9b8e30fa65ab93bde73a54017d0ef
child 2648923 add73dcf4be5a7e310a4eaceaccf545a54ab4fb4
push id490869
push userandre.bargull@gmail.com
push dateSat, 22 Feb 2020 09:32:51 +0000
treeherdertry@ca279eef8570 [default view] [failures only]
reviewersarai
bugs1535804
milestone75.0a1
Bug 1535804 - Part 2: Decrease nesting level in emitCreateFieldInitializers. r=arai! Decrease the nesting level to improve the readibility a bit. Differential Revision: https://phabricator.services.mozilla.com/D63510
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -8768,33 +8768,35 @@ bool BytecodeEmitter::emitCreateFieldIni
   }
 
   if (!ce.prepareForFieldInitializers(numFields)) {
     //          [stack] HOMEOBJ HERITAGE? ARRAY
     return false;
   }
 
   for (ParseNode* propdef : obj->contents()) {
-    if (propdef->is<ClassField>()) {
-      FunctionNode* initializer = propdef->as<ClassField>().initializer();
-      if (!emitTree(initializer)) {
+    if (!propdef->is<ClassField>()) {
+      continue;
+    }
+
+    FunctionNode* initializer = propdef->as<ClassField>().initializer();
+    if (!emitTree(initializer)) {
+      //            [stack] HOMEOBJ HERITAGE? ARRAY LAMBDA
+      return false;
+    }
+    if (initializer->funbox()->needsHomeObject()) {
+      MOZ_ASSERT(initializer->funbox()->allowSuperProperty());
+      if (!ce.emitFieldInitializerHomeObject()) {
         //          [stack] HOMEOBJ HERITAGE? ARRAY LAMBDA
         return false;
       }
-      if (initializer->funbox()->needsHomeObject()) {
-        MOZ_ASSERT(initializer->funbox()->allowSuperProperty());
-        if (!ce.emitFieldInitializerHomeObject()) {
-          //          [stack] CTOR OBJ ARRAY LAMBDA
-          return false;
-        }
-      }
-      if (!ce.emitStoreFieldInitializer()) {
-        //          [stack] HOMEOBJ HERITAGE? ARRAY
-        return false;
-      }
+    }
+    if (!ce.emitStoreFieldInitializer()) {
+      //            [stack] HOMEOBJ HERITAGE? ARRAY
+      return false;
     }
   }
 
   if (!ce.emitFieldInitializersEnd()) {
     //              [stack] HOMEOBJ HERITAGE?
     return false;
   }