[class] Add harmony-public-fields flag

Change the existing uses of the harmony-class-fields flag to
harmony-public-fields so that we can stage this separately
from the upcoming harmony-private-fields to get some
clusterfuzz coverage.

Bug: v8:5367
Change-Id: I76cdefa4faf34eae73d3a5f6d6089cf75677732a
Reviewed-on: https://chromium-review.googlesource.com/792940
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49661}
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 4caf9a9..ce9680a 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -4286,6 +4286,7 @@
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_tostring)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_public_fields)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_fields)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_dynamic_import)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_import_meta)
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 4b59fa4..9b9565d 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -190,6 +190,7 @@
 DEFINE_IMPLICATION(es_staging, harmony)
 // Enabling import.meta requires to also enable import()
 DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
+DEFINE_IMPLICATION(harmony_class_fields, harmony_public_fields)
 
 // Features that are still work in progress (behind individual flags).
 #define HARMONY_INPROGRESS(V)                                         \
@@ -197,7 +198,8 @@
   V(harmony_array_prototype_values, "harmony Array.prototype.values") \
   V(harmony_function_sent, "harmony function.sent")                   \
   V(harmony_do_expressions, "harmony do-expressions")                 \
-  V(harmony_class_fields, "harmony public fields in class literals")  \
+  V(harmony_class_fields, "harmony fields in class literals")         \
+  V(harmony_public_fields, "harmony public fields in class literals") \
   V(harmony_bigint, "harmony arbitrary precision integers")
 
 // Features that are complete (but still behind --harmony/es-staging flag).
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index ac6248d..9313d43 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -278,7 +278,7 @@
         allow_natives_(false),
         allow_harmony_do_expressions_(false),
         allow_harmony_function_sent_(false),
-        allow_harmony_class_fields_(false),
+        allow_harmony_public_fields_(false),
         allow_harmony_dynamic_import_(false),
         allow_harmony_import_meta_(false),
         allow_harmony_async_iteration_(false),
@@ -291,7 +291,7 @@
   ALLOW_ACCESSORS(natives);
   ALLOW_ACCESSORS(harmony_do_expressions);
   ALLOW_ACCESSORS(harmony_function_sent);
-  ALLOW_ACCESSORS(harmony_class_fields);
+  ALLOW_ACCESSORS(harmony_public_fields);
   ALLOW_ACCESSORS(harmony_dynamic_import);
   ALLOW_ACCESSORS(harmony_import_meta);
   ALLOW_ACCESSORS(harmony_async_iteration);
@@ -1534,7 +1534,7 @@
   bool allow_natives_;
   bool allow_harmony_do_expressions_;
   bool allow_harmony_function_sent_;
-  bool allow_harmony_class_fields_;
+  bool allow_harmony_public_fields_;
   bool allow_harmony_dynamic_import_;
   bool allow_harmony_import_meta_;
   bool allow_harmony_async_iteration_;
@@ -2314,7 +2314,7 @@
                                  // as an uninitialized field.
     case PropertyKind::kShorthandProperty:
     case PropertyKind::kValueProperty:
-      if (allow_harmony_class_fields()) {
+      if (allow_harmony_public_fields()) {
         *property_kind = ClassLiteralProperty::FIELD;
         ExpressionT initializer = ParseClassFieldInitializer(
             class_info, *is_static, CHECK_OK_CUSTOM(NullLiteralProperty));
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 6a7bf1f..63593ba 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -542,7 +542,7 @@
   set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
   set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
   set_allow_harmony_function_sent(FLAG_harmony_function_sent);
-  set_allow_harmony_class_fields(FLAG_harmony_class_fields);
+  set_allow_harmony_public_fields(FLAG_harmony_public_fields);
   set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import);
   set_allow_harmony_import_meta(FLAG_harmony_import_meta);
   set_allow_harmony_async_iteration(FLAG_harmony_async_iteration);
@@ -3241,7 +3241,7 @@
     return;
   }
 
-  DCHECK(allow_harmony_class_fields());
+  DCHECK(allow_harmony_public_fields());
 
   if (is_static) {
     class_info->static_fields->Add(property, zone());
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index 76014c7..0e89f9b 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -291,7 +291,7 @@
       SET_ALLOW(natives);
       SET_ALLOW(harmony_do_expressions);
       SET_ALLOW(harmony_function_sent);
-      SET_ALLOW(harmony_class_fields);
+      SET_ALLOW(harmony_public_fields);
       SET_ALLOW(harmony_dynamic_import);
       SET_ALLOW(harmony_import_meta);
       SET_ALLOW(harmony_async_iteration);
diff --git a/test/cctest/interpreter/bytecode_expectations/ClassFields.golden b/test/cctest/interpreter/bytecode_expectations/ClassFields.golden
index 5b91709..ab9fb2e 100644
--- a/test/cctest/interpreter/bytecode_expectations/ClassFields.golden
+++ b/test/cctest/interpreter/bytecode_expectations/ClassFields.golden
@@ -4,7 +4,7 @@
 
 ---
 wrap: yes
-class fields: yes
+public fields: yes
 
 ---
 snippet: "
diff --git a/test/cctest/interpreter/generate-bytecode-expectations.cc b/test/cctest/interpreter/generate-bytecode-expectations.cc
index 34839de..2f202a5 100644
--- a/test/cctest/interpreter/generate-bytecode-expectations.cc
+++ b/test/cctest/interpreter/generate-bytecode-expectations.cc
@@ -44,7 +44,7 @@
         top_level_(false),
         do_expressions_(false),
         async_iteration_(false),
-        class_fields_(false),
+        public_fields_(false),
         verbose_(false) {}
 
   bool Validate() const;
@@ -64,7 +64,7 @@
   bool top_level() const { return top_level_; }
   bool do_expressions() const { return do_expressions_; }
   bool async_iteration() const { return async_iteration_; }
-  bool class_fields() const { return class_fields_; }
+  bool public_fields() const { return public_fields_; }
   bool verbose() const { return verbose_; }
   bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; }
   std::vector<std::string> input_filenames() const { return input_filenames_; }
@@ -82,7 +82,7 @@
   bool top_level_;
   bool do_expressions_;
   bool async_iteration_;
-  bool class_fields_;
+  bool public_fields_;
   bool verbose_;
   std::vector<std::string> input_filenames_;
   std::string output_filename_;
@@ -172,8 +172,8 @@
       options.do_expressions_ = true;
     } else if (strcmp(argv[i], "--async-iteration") == 0) {
       options.async_iteration_ = true;
-    } else if (strcmp(argv[i], "--class-fields") == 0) {
-      options.class_fields_ = true;
+    } else if (strcmp(argv[i], "--public-fields") == 0) {
+      options.public_fields_ = true;
     } else if (strcmp(argv[i], "--verbose") == 0) {
       options.verbose_ = true;
     } else if (strncmp(argv[i], "--output=", 9) == 0) {
@@ -278,8 +278,8 @@
       do_expressions_ = ParseBoolean(line.c_str() + 16);
     } else if (line.compare(0, 17, "async iteration: ") == 0) {
       async_iteration_ = ParseBoolean(line.c_str() + 17);
-    } else if (line.compare(0, 14, "class fields: ") == 0) {
-      class_fields_ = ParseBoolean(line.c_str() + 14);
+    } else if (line.compare(0, 14, "public fields: ") == 0) {
+      public_fields_ = ParseBoolean(line.c_str() + 14);
     } else if (line == "---") {
       break;
     } else if (line.empty()) {
@@ -303,7 +303,7 @@
   if (top_level_) stream << "\ntop level: yes";
   if (do_expressions_) stream << "\ndo expressions: yes";
   if (async_iteration_) stream << "\nasync iteration: yes";
-  if (class_fields_) stream << "\nclass fields: yes";
+  if (public_fields_) stream << "\npublic fields: yes";
 
   stream << "\n\n";
 }
@@ -408,7 +408,7 @@
 
   if (options.do_expressions()) i::FLAG_harmony_do_expressions = true;
   if (options.async_iteration()) i::FLAG_harmony_async_iteration = true;
-  if (options.class_fields()) i::FLAG_harmony_class_fields = true;
+  if (options.public_fields()) i::FLAG_harmony_public_fields = true;
 
   stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n";
   options.PrintHeader(stream);
@@ -418,7 +418,7 @@
 
   i::FLAG_harmony_do_expressions = false;
   i::FLAG_harmony_async_iteration = false;
-  i::FLAG_harmony_class_fields = false;
+  i::FLAG_harmony_public_fields = false;
 }
 
 bool WriteExpectationsFile(const std::vector<std::string>& snippet_list,
@@ -466,7 +466,7 @@
          "  --top-level   Process top level code, not the top-level function.\n"
          "  --do-expressions  Enable harmony_do_expressions flag.\n"
          "  --async-iteration  Enable harmony_async_iteration flag.\n"
-         "  --class-fields  Enable harmony_class_fields flag.\n"
+         "  --public-fields  Enable harmony_public_fields flag.\n"
          "  --output=file.name\n"
          "      Specify the output file. If not specified, output goes to "
          "stdout.\n"
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index 3f628bd..ab10b62 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -2234,8 +2234,8 @@
 }
 
 TEST(ClassFields) {
-  bool old_flag = i::FLAG_harmony_class_fields;
-  i::FLAG_harmony_class_fields = true;
+  bool old_flag = i::FLAG_harmony_public_fields;
+  i::FLAG_harmony_public_fields = true;
   InitializedIgnitionHandleScope scope;
   BytecodeExpectationsPrinter printer(CcTest::isolate());
 
@@ -2269,7 +2269,7 @@
 
   CHECK(CompareTexts(BuildActual(printer, snippets),
                      LoadGolden("ClassFields.golden")));
-  i::FLAG_harmony_class_fields = old_flag;
+  i::FLAG_harmony_public_fields = old_flag;
 }
 
 TEST(Generators) {
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index f96332b..d155745 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1314,7 +1314,7 @@
   kAllowLazy,
   kAllowNatives,
   kAllowHarmonyFunctionSent,
-  kAllowHarmonyClassFields,
+  kAllowHarmonyPublicFields,
   kAllowHarmonyDynamicImport,
   kAllowHarmonyAsyncIteration,
   kAllowHarmonyTemplateEscapes,
@@ -1330,7 +1330,7 @@
 void SetGlobalFlags(i::EnumSet<ParserFlag> flags) {
   i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives);
   i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent);
-  i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields);
+  i::FLAG_harmony_public_fields = flags.Contains(kAllowHarmonyPublicFields);
   i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport);
   i::FLAG_harmony_import_meta = flags.Contains(kAllowHarmonyImportMeta);
   i::FLAG_harmony_async_iteration = flags.Contains(kAllowHarmonyAsyncIteration);
@@ -1342,8 +1342,8 @@
   parser->set_allow_natives(flags.Contains(kAllowNatives));
   parser->set_allow_harmony_function_sent(
       flags.Contains(kAllowHarmonyFunctionSent));
-  parser->set_allow_harmony_class_fields(
-      flags.Contains(kAllowHarmonyClassFields));
+  parser->set_allow_harmony_public_fields(
+      flags.Contains(kAllowHarmonyPublicFields));
   parser->set_allow_harmony_dynamic_import(
       flags.Contains(kAllowHarmonyDynamicImport));
   parser->set_allow_harmony_import_meta(
@@ -4809,7 +4809,7 @@
   };
   // clang-format on
 
-  static const ParserFlag always_flags[] = {kAllowHarmonyClassFields};
+  static const ParserFlag always_flags[] = {kAllowHarmonyPublicFields};
   RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr, 0,
                     always_flags, arraysize(always_flags));
 }
@@ -4850,7 +4850,7 @@
   };
   // clang-format on
 
-  static const ParserFlag always_flags[] = {kAllowHarmonyClassFields};
+  static const ParserFlag always_flags[] = {kAllowHarmonyPublicFields};
   RunParserSyncTest(context_data, class_body_data, kError, nullptr, 0,
                     always_flags, arraysize(always_flags));
 }
diff --git a/test/mjsunit/harmony/public-instance-class-fields.js b/test/mjsunit/harmony/public-instance-class-fields.js
index 7ba4188..e45cde7 100644
--- a/test/mjsunit/harmony/public-instance-class-fields.js
+++ b/test/mjsunit/harmony/public-instance-class-fields.js
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Flags: --harmony-class-fields
+// Flags: --harmony-public-fields
 "use strict";
 
 {
diff --git a/test/mjsunit/harmony/public-static-class-fields.js b/test/mjsunit/harmony/public-static-class-fields.js
index 081da00..0477e3d 100644
--- a/test/mjsunit/harmony/public-static-class-fields.js
+++ b/test/mjsunit/harmony/public-static-class-fields.js
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Flags: --harmony-class-fields
+// Flags: --harmony-public-fields
 
 "use strict";