| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 .FromJust(); | 345 .FromJust(); |
| 346 // Create with internal api | 346 // Create with internal api |
| 347 eternal_handles->Create( | 347 eternal_handles->Create( |
| 348 isolate, *v8::Utils::OpenHandle(*object), &indices[i]); | 348 isolate, *v8::Utils::OpenHandle(*object), &indices[i]); |
| 349 // Create with external api | 349 // Create with external api |
| 350 CHECK(eternals[i].IsEmpty()); | 350 CHECK(eternals[i].IsEmpty()); |
| 351 eternals[i].Set(v8_isolate, object); | 351 eternals[i].Set(v8_isolate, object); |
| 352 CHECK(!eternals[i].IsEmpty()); | 352 CHECK(!eternals[i].IsEmpty()); |
| 353 } | 353 } |
| 354 | 354 |
| 355 isolate->heap()->CollectAllAvailableGarbage(); | 355 CcTest::CollectAllAvailableGarbage(); |
| 356 | 356 |
| 357 for (int i = 0; i < kArrayLength; i++) { | 357 for (int i = 0; i < kArrayLength; i++) { |
| 358 for (int j = 0; j < 2; j++) { | 358 for (int j = 0; j < 2; j++) { |
| 359 HandleScope scope(isolate); | 359 HandleScope scope(isolate); |
| 360 v8::Local<v8::Value> local; | 360 v8::Local<v8::Value> local; |
| 361 if (j == 0) { | 361 if (j == 0) { |
| 362 // Test internal api | 362 // Test internal api |
| 363 local = v8::Utils::ToLocal(eternal_handles->Get(indices[i])); | 363 local = v8::Utils::ToLocal(eternal_handles->Get(indices[i])); |
| 364 } else { | 364 } else { |
| 365 // Test external api | 365 // Test external api |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 int identity; | 438 int identity; |
| 439 | 439 |
| 440 { | 440 { |
| 441 v8::HandleScope scope(isolate); | 441 v8::HandleScope scope(isolate); |
| 442 v8::Local<v8::Object> o = v8::Object::New(isolate); | 442 v8::Local<v8::Object> o = v8::Object::New(isolate); |
| 443 identity = o->GetIdentityHash(); | 443 identity = o->GetIdentityHash(); |
| 444 g.Reset(isolate, o); | 444 g.Reset(isolate, o); |
| 445 g.SetWeak(&g, finalizer, v8::WeakCallbackType::kFinalizer); | 445 g.SetWeak(&g, finalizer, v8::WeakCallbackType::kFinalizer); |
| 446 } | 446 } |
| 447 | 447 |
| 448 CcTest::i_isolate()->heap()->CollectAllAvailableGarbage(); | 448 CcTest::CollectAllAvailableGarbage(); |
| 449 | 449 |
| 450 CHECK(!g.IsEmpty()); | 450 CHECK(!g.IsEmpty()); |
| 451 v8::HandleScope scope(isolate); | 451 v8::HandleScope scope(isolate); |
| 452 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, g); | 452 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, g); |
| 453 CHECK_EQ(identity, o->GetIdentityHash()); | 453 CHECK_EQ(identity, o->GetIdentityHash()); |
| 454 CHECK(o->Has(isolate->GetCurrentContext(), v8_str("finalizer")).FromJust()); | 454 CHECK(o->Has(isolate->GetCurrentContext(), v8_str("finalizer")).FromJust()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 TEST(PhatomHandlesWithoutCallbacks) { | 457 TEST(PhatomHandlesWithoutCallbacks) { |
| 458 CcTest::InitializeVM(); | 458 CcTest::InitializeVM(); |
| 459 v8::Isolate* isolate = CcTest::isolate(); | 459 v8::Isolate* isolate = CcTest::isolate(); |
| 460 | 460 |
| 461 v8::Global<v8::Object> g1, g2; | 461 v8::Global<v8::Object> g1, g2; |
| 462 { | 462 { |
| 463 v8::HandleScope scope(isolate); | 463 v8::HandleScope scope(isolate); |
| 464 g1.Reset(isolate, v8::Object::New(isolate)); | 464 g1.Reset(isolate, v8::Object::New(isolate)); |
| 465 g1.SetWeak(); | 465 g1.SetWeak(); |
| 466 g2.Reset(isolate, v8::Object::New(isolate)); | 466 g2.Reset(isolate, v8::Object::New(isolate)); |
| 467 g2.SetWeak(); | 467 g2.SetWeak(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 CHECK_EQ(0, isolate->NumberOfPhantomHandleResetsSinceLastCall()); | 470 CHECK_EQ(0, isolate->NumberOfPhantomHandleResetsSinceLastCall()); |
| 471 CcTest::i_isolate()->heap()->CollectAllAvailableGarbage(); | 471 CcTest::CollectAllAvailableGarbage(); |
| 472 CHECK_EQ(2, isolate->NumberOfPhantomHandleResetsSinceLastCall()); | 472 CHECK_EQ(2, isolate->NumberOfPhantomHandleResetsSinceLastCall()); |
| 473 CHECK_EQ(0, isolate->NumberOfPhantomHandleResetsSinceLastCall()); | 473 CHECK_EQ(0, isolate->NumberOfPhantomHandleResetsSinceLastCall()); |
| 474 } | 474 } |
| OLD | NEW |