OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 { | 363 { |
364 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; | 364 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
365 Object** g1_children[] = { g1c1.location() }; | 365 Object** g1_children[] = { g1c1.location() }; |
366 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 366 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
367 Object** g2_children[] = { g2c1.location() }; | 367 Object** g2_children[] = { g2c1.location() }; |
368 global_handles->AddObjectGroup(g1_objects, 2, NULL); | 368 global_handles->AddObjectGroup(g1_objects, 2, NULL); |
369 global_handles->AddImplicitReferences( | 369 global_handles->AddImplicitReferences( |
370 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); | 370 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); |
371 global_handles->AddObjectGroup(g2_objects, 2, NULL); | 371 global_handles->AddObjectGroup(g2_objects, 2, NULL); |
372 global_handles->AddImplicitReferences( | 372 global_handles->AddImplicitReferences( |
373 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); | 373 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); |
374 } | 374 } |
375 // Do a full GC | 375 // Do a full GC |
376 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 376 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
377 | 377 |
378 // All object should be alive. | 378 // All object should be alive. |
379 CHECK_EQ(0, NumberOfWeakCalls); | 379 CHECK_EQ(0, NumberOfWeakCalls); |
380 | 380 |
381 // Weaken the root. | 381 // Weaken the root. |
382 global_handles->MakeWeak(root.location(), | 382 global_handles->MakeWeak(root.location(), |
383 reinterpret_cast<void*>(1234), | 383 reinterpret_cast<void*>(1234), |
384 NULL, | 384 NULL, |
385 &WeakPointerCallback); | 385 &WeakPointerCallback); |
386 // But make children strong roots---all the objects (except for children) | 386 // But make children strong roots---all the objects (except for children) |
387 // should be collectable now. | 387 // should be collectable now. |
388 global_handles->ClearWeakness(g1c1.location()); | 388 global_handles->ClearWeakness(g1c1.location()); |
389 global_handles->ClearWeakness(g2c1.location()); | 389 global_handles->ClearWeakness(g2c1.location()); |
390 | 390 |
391 // Groups are deleted, rebuild groups. | 391 // Groups are deleted, rebuild groups. |
392 { | 392 { |
393 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; | 393 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
394 Object** g1_children[] = { g1c1.location() }; | 394 Object** g1_children[] = { g1c1.location() }; |
395 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 395 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
396 Object** g2_children[] = { g2c1.location() }; | 396 Object** g2_children[] = { g2c1.location() }; |
397 global_handles->AddObjectGroup(g1_objects, 2, NULL); | 397 global_handles->AddObjectGroup(g1_objects, 2, NULL); |
398 global_handles->AddImplicitReferences( | 398 global_handles->AddImplicitReferences( |
399 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); | 399 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); |
400 global_handles->AddObjectGroup(g2_objects, 2, NULL); | 400 global_handles->AddObjectGroup(g2_objects, 2, NULL); |
401 global_handles->AddImplicitReferences( | 401 global_handles->AddImplicitReferences( |
402 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); | 402 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); |
403 } | 403 } |
404 | 404 |
405 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 405 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
406 | 406 |
407 // All objects should be gone. 5 global handles in total. | 407 // All objects should be gone. 5 global handles in total. |
408 CHECK_EQ(5, NumberOfWeakCalls); | 408 CHECK_EQ(5, NumberOfWeakCalls); |
409 | 409 |
410 // And now make children weak again and collect them. | 410 // And now make children weak again and collect them. |
411 global_handles->MakeWeak(g1c1.location(), | 411 global_handles->MakeWeak(g1c1.location(), |
412 reinterpret_cast<void*>(1234), | 412 reinterpret_cast<void*>(1234), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 NULL, | 470 NULL, |
471 &WeakPointerCallback); | 471 &WeakPointerCallback); |
472 | 472 |
473 Handle<Object> root = global_handles->Create(*g1s1); // make a root. | 473 Handle<Object> root = global_handles->Create(*g1s1); // make a root. |
474 | 474 |
475 // Connect group 1 and 2, make a cycle. | 475 // Connect group 1 and 2, make a cycle. |
476 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); | 476 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); |
477 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); | 477 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); |
478 | 478 |
479 { | 479 { |
480 Object** g1_children[] = { g1c1.location() }; | |
481 Object** g2_children[] = { g2c1.location() }; | |
482 global_handles->SetObjectGroupId(g1s1.location(), v8::UniqueId(1)); | 480 global_handles->SetObjectGroupId(g1s1.location(), v8::UniqueId(1)); |
483 global_handles->SetObjectGroupId(g1s2.location(), v8::UniqueId(1)); | 481 global_handles->SetObjectGroupId(g1s2.location(), v8::UniqueId(1)); |
484 global_handles->AddImplicitReferences( | 482 global_handles->SetObjectGroupRepresentative( |
485 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); | 483 v8::UniqueId(1), reinterpret_cast<HeapObject**>(g1s1.location())); |
| 484 global_handles->AddImplicitReference(v8::UniqueId(1), g1c1.location()); |
486 global_handles->SetObjectGroupId(g2s1.location(), v8::UniqueId(2)); | 485 global_handles->SetObjectGroupId(g2s1.location(), v8::UniqueId(2)); |
487 global_handles->SetObjectGroupId(g2s2.location(), v8::UniqueId(2)); | 486 global_handles->SetObjectGroupId(g2s2.location(), v8::UniqueId(2)); |
488 global_handles->AddImplicitReferences( | 487 global_handles->SetObjectGroupRepresentative( |
489 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); | 488 v8::UniqueId(2), reinterpret_cast<HeapObject**>(g2s1.location())); |
| 489 global_handles->AddImplicitReference(v8::UniqueId(2), g2c1.location()); |
490 } | 490 } |
491 // Do a full GC | 491 // Do a full GC |
492 heap->CollectGarbage(OLD_POINTER_SPACE); | 492 heap->CollectGarbage(OLD_POINTER_SPACE); |
493 | 493 |
494 // All object should be alive. | 494 // All object should be alive. |
495 CHECK_EQ(0, NumberOfWeakCalls); | 495 CHECK_EQ(0, NumberOfWeakCalls); |
496 | 496 |
497 // Weaken the root. | 497 // Weaken the root. |
498 global_handles->MakeWeak(root.location(), | 498 global_handles->MakeWeak(root.location(), |
499 reinterpret_cast<void*>(1234), | 499 reinterpret_cast<void*>(1234), |
500 NULL, | 500 NULL, |
501 &WeakPointerCallback); | 501 &WeakPointerCallback); |
502 // But make children strong roots---all the objects (except for children) | 502 // But make children strong roots---all the objects (except for children) |
503 // should be collectable now. | 503 // should be collectable now. |
504 global_handles->ClearWeakness(g1c1.location()); | 504 global_handles->ClearWeakness(g1c1.location()); |
505 global_handles->ClearWeakness(g2c1.location()); | 505 global_handles->ClearWeakness(g2c1.location()); |
506 | 506 |
507 // Groups are deleted, rebuild groups. | 507 // Groups are deleted, rebuild groups. |
508 { | 508 { |
509 Object** g1_children[] = { g1c1.location() }; | |
510 Object** g2_children[] = { g2c1.location() }; | |
511 global_handles->SetObjectGroupId(g1s1.location(), v8::UniqueId(1)); | 509 global_handles->SetObjectGroupId(g1s1.location(), v8::UniqueId(1)); |
512 global_handles->SetObjectGroupId(g1s2.location(), v8::UniqueId(1)); | 510 global_handles->SetObjectGroupId(g1s2.location(), v8::UniqueId(1)); |
513 global_handles->AddImplicitReferences( | 511 global_handles->SetObjectGroupRepresentative( |
514 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); | 512 v8::UniqueId(1), reinterpret_cast<HeapObject**>(g1s1.location())); |
| 513 global_handles->AddImplicitReference(v8::UniqueId(1), g1c1.location()); |
515 global_handles->SetObjectGroupId(g2s1.location(), v8::UniqueId(2)); | 514 global_handles->SetObjectGroupId(g2s1.location(), v8::UniqueId(2)); |
516 global_handles->SetObjectGroupId(g2s2.location(), v8::UniqueId(2)); | 515 global_handles->SetObjectGroupId(g2s2.location(), v8::UniqueId(2)); |
517 global_handles->AddImplicitReferences( | 516 global_handles->SetObjectGroupRepresentative( |
518 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); | 517 v8::UniqueId(2), reinterpret_cast<HeapObject**>(g2s1.location())); |
| 518 global_handles->AddImplicitReference(v8::UniqueId(2), g2c1.location()); |
519 } | 519 } |
520 | 520 |
521 heap->CollectGarbage(OLD_POINTER_SPACE); | 521 heap->CollectGarbage(OLD_POINTER_SPACE); |
522 | 522 |
523 // All objects should be gone. 5 global handles in total. | 523 // All objects should be gone. 5 global handles in total. |
524 CHECK_EQ(5, NumberOfWeakCalls); | 524 CHECK_EQ(5, NumberOfWeakCalls); |
525 | 525 |
526 // And now make children weak again and collect them. | 526 // And now make children weak again and collect them. |
527 global_handles->MakeWeak(g1c1.location(), | 527 global_handles->MakeWeak(g1c1.location(), |
528 reinterpret_cast<void*>(1234), | 528 reinterpret_cast<void*>(1234), |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 if (v8::internal::Snapshot::IsEnabled()) { | 676 if (v8::internal::Snapshot::IsEnabled()) { |
677 CHECK_LE(delta, 2900 * 1024); | 677 CHECK_LE(delta, 2900 * 1024); |
678 } else { | 678 } else { |
679 CHECK_LE(delta, 3400 * 1024); | 679 CHECK_LE(delta, 3400 * 1024); |
680 } | 680 } |
681 } | 681 } |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 #endif // __linux__ and !USE_SIMULATOR | 685 #endif // __linux__ and !USE_SIMULATOR |
OLD | NEW |