Revision: 24400
Author:   [email protected]
Date:     Fri Oct  3 10:29:12 2014 UTC
Log:      Add a use counter for Intl.v8BreakIterator

[email protected]
BUG=

Review URL: https://codereview.chromium.org/619913002
https://code.google.com/p/v8/source/detail?r=24400

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/i18n.cc
 /branches/bleeding_edge/test/cctest/test-strings.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Thu Oct  2 09:39:13 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Fri Oct  3 10:29:12 2014 UTC
@@ -4528,6 +4528,7 @@
    */
   enum UseCounterFeature {
     kUseAsm = 0,
+    kBreakIterator = 1,
     kUseCounterFeatureCount  // This enum value must be last.
   };

=======================================
--- /branches/bleeding_edge/src/i18n.cc Wed Sep 10 12:38:12 2014 UTC
+++ /branches/bleeding_edge/src/i18n.cc Fri Oct  3 10:29:12 2014 UTC
@@ -630,6 +630,8 @@
     delete break_iterator;
     return NULL;
   }
+
+  isolate->CountUsage(v8::Isolate::UseCounterFeature::kBreakIterator);

   return break_iterator;
 }
=======================================
--- /branches/bleeding_edge/test/cctest/test-strings.cc Tue Sep 16 09:15:02 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-strings.cc Fri Oct 3 10:29:12 2014 UTC
@@ -1290,6 +1290,35 @@
   CompileRun("var slice = long.slice(1, 15);");
   CheckException("%_SubString(slice, 0, 17);");
 }
+
+
+namespace {
+
+int* global_use_counts = NULL;
+
+void MockUseCounterCallback(v8::Isolate* isolate,
+                            v8::Isolate::UseCounterFeature feature) {
+  ++global_use_counts[feature];
+}
+}
+
+
+TEST(CountBreakIterator) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+  LocalContext context;
+  int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
+  global_use_counts = use_counts;
+  CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
+  CHECK_EQ(0, use_counts[v8::Isolate::kBreakIterator]);
+  v8::Local<v8::Value> result = CompileRun(
+      "var iterator = Intl.v8BreakIterator(['en']);"
+      "iterator.adoptText('Now is the time');"
+      "iterator.next();"
+      "iterator.next();");
+  CHECK(result->IsNumber());
+  CHECK_EQ(1, use_counts[v8::Isolate::kBreakIterator]);
+}


 TEST(StringReplaceAtomTwoByteResult) {

--
--
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