Add Isolate parameter to HandleScope::NumberOfHandles.

LOG=y
BUG=324225
R=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18510 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2014-01-09 10:37:15 +00:00
parent 7baadbfac1
commit 8f7720aa25
3 changed files with 22 additions and 26 deletions

View File

@ -823,7 +823,7 @@ class V8_EXPORT HandleScope {
/**
* Counts the number of allocated handles.
*/
static int NumberOfHandles();
static int NumberOfHandles(Isolate* isolate);
private:
/**

View File

@ -662,12 +662,9 @@ HandleScope::~HandleScope() {
}
int HandleScope::NumberOfHandles() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) {
return 0;
}
return i::HandleScope::NumberOfHandles(isolate);
int HandleScope::NumberOfHandles(Isolate* isolate) {
return i::HandleScope::NumberOfHandles(
reinterpret_cast<i::Isolate*>(isolate));
}

View File

@ -11022,45 +11022,44 @@ THREADED_TEST(CallableObject) {
}
static int CountHandles() {
return v8::HandleScope::NumberOfHandles();
}
static int Recurse(int depth, int iterations) {
v8::HandleScope scope(CcTest::isolate());
if (depth == 0) return CountHandles();
static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
v8::HandleScope scope(isolate);
if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);
for (int i = 0; i < iterations; i++) {
Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42));
Local<v8::Number> n(v8::Integer::New(isolate, 42));
}
return Recurse(depth - 1, iterations);
return Recurse(isolate, depth - 1, iterations);
}
THREADED_TEST(HandleIteration) {
static const int kIterations = 500;
static const int kNesting = 200;
CHECK_EQ(0, CountHandles());
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope0(isolate);
CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate));
{
v8::HandleScope scope1(CcTest::isolate());
CHECK_EQ(0, CountHandles());
v8::HandleScope scope1(isolate);
CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate));
for (int i = 0; i < kIterations; i++) {
Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42));
CHECK_EQ(i + 1, CountHandles());
CHECK_EQ(i + 1, v8::HandleScope::NumberOfHandles(isolate));
}
CHECK_EQ(kIterations, CountHandles());
CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate));
{
v8::HandleScope scope2(CcTest::isolate());
for (int j = 0; j < kIterations; j++) {
Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42));
CHECK_EQ(j + 1 + kIterations, CountHandles());
CHECK_EQ(j + 1 + kIterations,
v8::HandleScope::NumberOfHandles(isolate));
}
}
CHECK_EQ(kIterations, CountHandles());
CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate));
}
CHECK_EQ(0, CountHandles());
CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations));
CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate));
CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations));
}