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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 GlobalHandles::MakeWeak(g2s2.location(), | 275 GlobalHandles::MakeWeak(g2s2.location(), |
276 reinterpret_cast<void*>(1234), | 276 reinterpret_cast<void*>(1234), |
277 &WeakPointerCallback); | 277 &WeakPointerCallback); |
278 | 278 |
279 Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. | 279 Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. |
280 | 280 |
281 // Connect group 1 and 2, make a cycle. | 281 // Connect group 1 and 2, make a cycle. |
282 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); | 282 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); |
283 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); | 283 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); |
284 | 284 |
285 GlobalHandles::AddToGroup(reinterpret_cast<void*>(1), g1s1.location()); | 285 { |
286 GlobalHandles::AddToGroup(reinterpret_cast<void*>(1), g1s2.location()); | 286 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
287 GlobalHandles::AddToGroup(reinterpret_cast<void*>(2), g2s1.location()); | 287 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
288 GlobalHandles::AddToGroup(reinterpret_cast<void*>(2), g2s2.location()); | 288 GlobalHandles::AddGroup(g1_objects, 2); |
| 289 GlobalHandles::AddGroup(g2_objects, 2); |
| 290 } |
289 // Do a full GC | 291 // Do a full GC |
290 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); | 292 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); |
291 | 293 |
292 // All object should be alive. | 294 // All object should be alive. |
293 CHECK_EQ(0, NumberOfWeakCalls); | 295 CHECK_EQ(0, NumberOfWeakCalls); |
294 | 296 |
295 // Weaken the root. | 297 // Weaken the root. |
296 GlobalHandles::MakeWeak(root.location(), | 298 GlobalHandles::MakeWeak(root.location(), |
297 reinterpret_cast<void*>(1234), | 299 reinterpret_cast<void*>(1234), |
298 &WeakPointerCallback); | 300 &WeakPointerCallback); |
299 | 301 |
300 // Groups are deleted, rebuild groups. | 302 // Groups are deleted, rebuild groups. |
301 GlobalHandles::AddToGroup(reinterpret_cast<void*>(1), g1s1.location()); | 303 { |
302 GlobalHandles::AddToGroup(reinterpret_cast<void*>(1), g1s2.location()); | 304 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
303 GlobalHandles::AddToGroup(reinterpret_cast<void*>(2), g2s1.location()); | 305 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
304 GlobalHandles::AddToGroup(reinterpret_cast<void*>(2), g2s2.location()); | 306 GlobalHandles::AddGroup(g1_objects, 2); |
| 307 GlobalHandles::AddGroup(g2_objects, 2); |
| 308 } |
305 | 309 |
306 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); | 310 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); |
307 | 311 |
308 // All objects should be gone. 5 global handles in total. | 312 // All objects should be gone. 5 global handles in total. |
309 CHECK_EQ(5, NumberOfWeakCalls); | 313 CHECK_EQ(5, NumberOfWeakCalls); |
310 } | 314 } |
OLD | NEW |