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