| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); | 267 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); |
| 268 CHECK_EQ(1, gc_starts); | 268 CHECK_EQ(1, gc_starts); |
| 269 CHECK_EQ(gc_ends, gc_starts); | 269 CHECK_EQ(gc_ends, gc_starts); |
| 270 } | 270 } |
| 271 | 271 |
| 272 | 272 |
| 273 static int NumberOfWeakCalls = 0; | 273 static int NumberOfWeakCalls = 0; |
| 274 static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) { | 274 static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) { |
| 275 NumberOfWeakCalls++; | 275 NumberOfWeakCalls++; |
| 276 handle.Dispose(); |
| 276 } | 277 } |
| 277 | 278 |
| 278 TEST(ObjectGroups) { | 279 TEST(ObjectGroups) { |
| 279 InitializeVM(); | 280 InitializeVM(); |
| 280 | 281 |
| 281 NumberOfWeakCalls = 0; | 282 NumberOfWeakCalls = 0; |
| 282 v8::HandleScope handle_scope; | 283 v8::HandleScope handle_scope; |
| 283 | 284 |
| 284 Handle<Object> g1s1 = | 285 Handle<Object> g1s1 = |
| 285 GlobalHandles::Create(Heap::AllocateFixedArray(1)); | 286 GlobalHandles::Create(Heap::AllocateFixedArray(1)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 333 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 333 GlobalHandles::AddGroup(g1_objects, 2); | 334 GlobalHandles::AddGroup(g1_objects, 2); |
| 334 GlobalHandles::AddGroup(g2_objects, 2); | 335 GlobalHandles::AddGroup(g2_objects, 2); |
| 335 } | 336 } |
| 336 | 337 |
| 337 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); | 338 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); |
| 338 | 339 |
| 339 // All objects should be gone. 5 global handles in total. | 340 // All objects should be gone. 5 global handles in total. |
| 340 CHECK_EQ(5, NumberOfWeakCalls); | 341 CHECK_EQ(5, NumberOfWeakCalls); |
| 341 } | 342 } |
| OLD | NEW |