Reviewers: marja,

Description:
Add a use counter for Intl.v8BreakIterator

[email protected]
BUG=

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+32, -0 lines):
  M include/v8.h
  M src/i18n.cc
  M test/cctest/test-strings.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 274dedb6755acec5315e4b4a83c9537ed9e0f620..3c83abee6125d1a611da45c2add121646e94f864 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4523,6 +4523,7 @@ class V8_EXPORT Isolate {
    */
   enum UseCounterFeature {
     kUseAsm = 0,
+    kBreakIterator = 1,
     kUseCounterFeatureCount  // This enum value must be last.
   };

Index: src/i18n.cc
diff --git a/src/i18n.cc b/src/i18n.cc
index cae3a327a1b924b60edad2d9f326ccd01df2b6ad..ba44687aa90dd57932cc36f4feb3986004dac856 100644
--- a/src/i18n.cc
+++ b/src/i18n.cc
@@ -631,6 +631,8 @@ icu::BreakIterator* CreateICUBreakIterator(
     return NULL;
   }

+  isolate->CountUsage(v8::Isolate::UseCounterFeature::kBreakIterator);
+
   return break_iterator;
 }

Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index ef13c4dadf682f6e178dce71c9e70009d703a7e9..88aa72fb00800e064091429aea05acb6d24ecc64 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1292,6 +1292,35 @@ TEST(RobustSubStringStub) {
 }


+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) {
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());


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