Reland: Add a use counter for Intl.v8BreakIterator

This relands https://codereview.chromium.org/619913002/
The test has been fixed to do a GC so it does not appear to leak in
ASAN.  In addition the test has been fixed to work in the no-i18n
build, by incorporating the change from https://codereview.chromium.org/631743002/
R=ishell@chromium.org
BUG=

Review URL: https://codereview.chromium.org/628223002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24423 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 041c80e7
......@@ -4528,6 +4528,7 @@ class V8_EXPORT Isolate {
*/
enum UseCounterFeature {
kUseAsm = 0,
kBreakIterator = 1,
kUseCounterFeatureCount // This enum value must be last.
};
......
......@@ -631,6 +631,8 @@ icu::BreakIterator* CreateICUBreakIterator(
return NULL;
}
isolate->CountUsage(v8::Isolate::UseCounterFeature::kBreakIterator);
return break_iterator;
}
......
......@@ -1292,6 +1292,42 @@ 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(
"(function() {"
" if (!this.Intl) return 0;"
" var iterator = Intl.v8BreakIterator(['en']);"
" iterator.adoptText('Now is the time');"
" iterator.next();"
" return iterator.next();"
"})();");
CHECK(result->IsNumber());
int uses = result->ToInt32()->Value() == 0 ? 0 : 1;
CHECK_EQ(uses, use_counts[v8::Isolate::kBreakIterator]);
// Make sure GC cleans up the break iterator, so we don't get a memory leak
// reported by ASAN.
CcTest::isolate()->LowMemoryNotification();
}
TEST(StringReplaceAtomTwoByteResult) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment