| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. | 333 Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. |
| 334 | 334 |
| 335 // Connect group 1 and 2, make a cycle. | 335 // Connect group 1 and 2, make a cycle. |
| 336 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); | 336 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); |
| 337 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); | 337 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); |
| 338 | 338 |
| 339 { | 339 { |
| 340 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; | 340 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
| 341 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 341 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 342 GlobalHandles::AddGroup(g1_objects, 2); | 342 GlobalHandles::AddGroup(g1_objects, 2, NULL); |
| 343 GlobalHandles::AddGroup(g2_objects, 2); | 343 GlobalHandles::AddGroup(g2_objects, 2, NULL); |
| 344 } | 344 } |
| 345 // Do a full GC | 345 // Do a full GC |
| 346 Heap::CollectGarbage(OLD_POINTER_SPACE); | 346 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 347 | 347 |
| 348 // All object should be alive. | 348 // All object should be alive. |
| 349 CHECK_EQ(0, NumberOfWeakCalls); | 349 CHECK_EQ(0, NumberOfWeakCalls); |
| 350 | 350 |
| 351 // Weaken the root. | 351 // Weaken the root. |
| 352 GlobalHandles::MakeWeak(root.location(), | 352 GlobalHandles::MakeWeak(root.location(), |
| 353 reinterpret_cast<void*>(1234), | 353 reinterpret_cast<void*>(1234), |
| 354 &WeakPointerCallback); | 354 &WeakPointerCallback); |
| 355 | 355 |
| 356 // Groups are deleted, rebuild groups. | 356 // Groups are deleted, rebuild groups. |
| 357 { | 357 { |
| 358 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; | 358 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
| 359 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 359 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 360 GlobalHandles::AddGroup(g1_objects, 2); | 360 GlobalHandles::AddGroup(g1_objects, 2, NULL); |
| 361 GlobalHandles::AddGroup(g2_objects, 2); | 361 GlobalHandles::AddGroup(g2_objects, 2, NULL); |
| 362 } | 362 } |
| 363 | 363 |
| 364 Heap::CollectGarbage(OLD_POINTER_SPACE); | 364 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 365 | 365 |
| 366 // All objects should be gone. 5 global handles in total. | 366 // All objects should be gone. 5 global handles in total. |
| 367 CHECK_EQ(5, NumberOfWeakCalls); | 367 CHECK_EQ(5, NumberOfWeakCalls); |
| 368 } | 368 } |
| OLD | NEW |