Reviewers: ,

Message:
ptal

Description:
Use counter for legacy const.

Please review this at https://codereview.chromium.org/1041863002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+21, -1 lines):
  M include/v8.h
  M src/parser.cc
  M test/cctest/test-parsing.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 3d5c2ecd9200fb628c414976048747c25ebad8cc..e8f709698f94d4444ac3bfec3f2bfa84f6e57a0f 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5135,7 +5135,7 @@ class V8_EXPORT Isolate {
   };

   /**
-   * Features reported via the SetUseCounterCallback callback. Do not chang
+ * Features reported via the SetUseCounterCallback callback. Do not change * assigned numbers of existing items; add new features to the end of this
    * list.
    */
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 8ed20ee2121cfec8d313b042ac5ea878e66be628..7ab9be2fefed678e4234af649591bc8dffcfc3be 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2272,6 +2272,7 @@ Block* Parser::ParseVariableDeclarations(
     if (is_sloppy(language_mode())) {
       mode = CONST_LEGACY;
       init_op = Token::INIT_CONST_LEGACY;
+      ++use_counts_[v8::Isolate::kLegacyConst];
     } else {
       DCHECK(var_context != kStatement);
       mode = CONST;
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 5b19746f937b043524f77b260d7ad32de8ed295c..69690261932d8eba45a3827d0227bc4ecdcb61a6 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -3441,6 +3441,25 @@ TEST(UseAsmUseCount) {
 }


+TEST(UseConstLegacyCount) {
+  i::Isolate* isolate = CcTest::i_isolate();
+  i::HandleScope scope(isolate);
+  LocalContext env;
+  int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
+  global_use_counts = use_counts;
+  CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
+  CompileRun(
+      "const x = 1;\n"
+      "var foo = 1;\n"
+      "const y = 1;\n"
+      "function bar() {\n"
+      "    const z = 1; var baz = 1;\n"
+      "    function q() { const k = 42; }\n"
+      "}");
+  CHECK_EQ(4, use_counts[v8::Isolate::kLegacyConst]);
+}
+
+
 TEST(ErrorsArrowFunctions) {
   // Tests that parser and preparser generate the same kind of errors
   // on invalid arrow function syntax.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to