| Index: test/cctest/test-global-handles.cc
|
| diff --git a/test/cctest/test-global-handles.cc b/test/cctest/test-global-handles.cc
|
| index 0b652db37b628a25d0f10e1e065366f283c00535..c2e5ae7f9ad42ed5a028a4a16346e282d2524bb6 100644
|
| --- a/test/cctest/test-global-handles.cc
|
| +++ b/test/cctest/test-global-handles.cc
|
| @@ -321,24 +321,25 @@ TEST(EternalHandles) {
|
| CcTest::InitializeVM();
|
| Isolate* isolate = Isolate::Current();
|
| v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
|
| - EternalHandles* eternals = isolate->eternal_handles();
|
| + EternalHandles* eternal_handles = isolate->eternal_handles();
|
|
|
| // Create a number of handles that will not be on a block boundary
|
| const int kArrayLength = 2048-1;
|
| int indices[kArrayLength];
|
| + v8::Eternal<v8::Value> eternals[kArrayLength];
|
|
|
| - CHECK_EQ(0, eternals->NumberOfHandles());
|
| + CHECK_EQ(0, eternal_handles->NumberOfHandles());
|
| for (int i = 0; i < kArrayLength; i++) {
|
| HandleScope scope(isolate);
|
| v8::Local<v8::Object> object = v8::Object::New();
|
| object->Set(i, v8::Integer::New(i, v8_isolate));
|
| - if (i % 2 == 0) {
|
| - // Create with internal api
|
| - indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object));
|
| - } else {
|
| - // Create with external api
|
| - indices[i] = object.Eternalize(v8_isolate);
|
| - }
|
| + // Create with internal api
|
| + eternal_handles->Create(
|
| + isolate, *v8::Utils::OpenHandle(*object), &indices[i]);
|
| + // Create with external api
|
| + CHECK(!eternals[i].IsEmpty());
|
| + eternals[i].Set(v8_isolate, object);
|
| + CHECK(eternals[i].IsEmpty());
|
| }
|
|
|
| isolate->heap()->CollectAllAvailableGarbage();
|
| @@ -346,21 +347,31 @@ TEST(EternalHandles) {
|
| for (int i = 0; i < kArrayLength; i++) {
|
| for (int j = 0; j < 2; j++) {
|
| HandleScope scope(isolate);
|
| - v8::Local<v8::Object> object;
|
| + v8::Local<v8::Value> local;
|
| if (j == 0) {
|
| // Test internal api
|
| - v8::Local<v8::Value> local =
|
| - v8::Utils::ToLocal(eternals->Get(indices[i]));
|
| - object = v8::Handle<v8::Object>::Cast(local);
|
| + local = v8::Utils::ToLocal(eternal_handles->Get(indices[i]));
|
| } else {
|
| // Test external api
|
| - object = v8::Local<v8::Object>::GetEternal(v8_isolate, indices[i]);
|
| + local = eternals[i].Get(v8_isolate);
|
| }
|
| + v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(local);
|
| v8::Local<v8::Value> value = object->Get(i);
|
| CHECK(value->IsInt32());
|
| CHECK_EQ(i, value->Int32Value());
|
| }
|
| }
|
|
|
| - CHECK_EQ(kArrayLength, eternals->NumberOfHandles());
|
| + CHECK_EQ(2*kArrayLength, eternal_handles->NumberOfHandles());
|
| +
|
| + // Create an eternal via the constructor
|
| + {
|
| + HandleScope scope(isolate);
|
| + v8::Local<v8::Object> object = v8::Object::New();
|
| + v8::Eternal<v8::Object> eternal(v8_isolate, object);
|
| + CHECK(eternal.IsEmpty());
|
| + CHECK(object == eternal.Get(v8_isolate));
|
| + }
|
| +
|
| + CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles());
|
| }
|
|
|