Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | #include "v8.h" |
| 31 | |
| 32 | #include "global-handles.h" |
| 33 | #include "snapshot.h" |
| 34 | #include "top.h" |
| 35 | #include "cctest.h" |
| 36 | |
| 37 | using namespace v8::internal; |
| 38 | |
| 39 | static v8::Persistent<v8::Context> env; |
| 40 | |
| 41 | static void InitializeVM() { |
| 42 | if (env.IsEmpty()) env = v8::Context::New(); |
| 43 | v8::HandleScope scope; |
| 44 | env->Enter(); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | TEST(MarkingStack) { |
| 49 | int mem_size = 20 * kPointerSize; |
| 50 | byte* mem = NewArray<byte>(20*kPointerSize); |
| 51 | Address low = reinterpret_cast<Address>(mem); |
| 52 | Address high = low + mem_size; |
| 53 | MarkingStack s; |
| 54 | s.Initialize(low, high); |
| 55 | |
| 56 | Address address = NULL; |
| 57 | while (!s.is_full()) { |
| 58 | s.Push(HeapObject::FromAddress(address)); |
| 59 | address += kPointerSize; |
| 60 | } |
| 61 | |
| 62 | while (!s.is_empty()) { |
| 63 | Address value = s.Pop()->address(); |
| 64 | address -= kPointerSize; |
| 65 | CHECK_EQ(address, value); |
| 66 | } |
| 67 | |
| 68 | CHECK_EQ(NULL, address); |
| 69 | DeleteArray(mem); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | TEST(Promotion) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 74 | // This test requires compaction. If compaction is turned off, we |
| 75 | // skip the entire test. |
| 76 | if (FLAG_never_compact) return; |
| 77 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 78 | // Ensure that we get a compacting collection so that objects are promoted |
| 79 | // from new space. |
| 80 | FLAG_gc_global = true; |
| 81 | FLAG_always_compact = true; |
Russell Brenner | 90bac25 | 2010-11-18 13:33:46 -0800 | [diff] [blame] | 82 | Heap::ConfigureHeap(2*256*KB, 4*MB, 4*MB); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 83 | |
| 84 | InitializeVM(); |
| 85 | |
| 86 | v8::HandleScope sc; |
| 87 | |
| 88 | // Allocate a fixed array in the new space. |
| 89 | int array_size = |
| 90 | (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / |
| 91 | (kPointerSize * 4); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 92 | Object* obj = Heap::AllocateFixedArray(array_size)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 93 | |
| 94 | Handle<FixedArray> array(FixedArray::cast(obj)); |
| 95 | |
| 96 | // Array should be in the new space. |
| 97 | CHECK(Heap::InSpace(*array, NEW_SPACE)); |
| 98 | |
| 99 | // Call the m-c collector, so array becomes an old object. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 100 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 101 | |
| 102 | // Array now sits in the old space |
| 103 | CHECK(Heap::InSpace(*array, OLD_POINTER_SPACE)); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | TEST(NoPromotion) { |
Russell Brenner | 90bac25 | 2010-11-18 13:33:46 -0800 | [diff] [blame] | 108 | Heap::ConfigureHeap(2*256*KB, 4*MB, 4*MB); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 109 | |
| 110 | // Test the situation that some objects in new space are promoted to |
| 111 | // the old space |
| 112 | InitializeVM(); |
| 113 | |
| 114 | v8::HandleScope sc; |
| 115 | |
| 116 | // Do a mark compact GC to shrink the heap. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 117 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 118 | |
| 119 | // Allocate a big Fixed array in the new space. |
| 120 | int size = (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / |
| 121 | kPointerSize; |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 122 | Object* obj = Heap::AllocateFixedArray(size)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 123 | |
| 124 | Handle<FixedArray> array(FixedArray::cast(obj)); |
| 125 | |
| 126 | // Array still stays in the new space. |
| 127 | CHECK(Heap::InSpace(*array, NEW_SPACE)); |
| 128 | |
| 129 | // Allocate objects in the old space until out of memory. |
| 130 | FixedArray* host = *array; |
| 131 | while (true) { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 132 | Object* obj; |
| 133 | { MaybeObject* maybe_obj = Heap::AllocateFixedArray(100, TENURED); |
| 134 | if (!maybe_obj->ToObject(&obj)) break; |
| 135 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 136 | |
| 137 | host->set(0, obj); |
| 138 | host = FixedArray::cast(obj); |
| 139 | } |
| 140 | |
| 141 | // Call mark compact GC, and it should pass. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 142 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 143 | |
| 144 | // array should not be promoted because the old space is full. |
| 145 | CHECK(Heap::InSpace(*array, NEW_SPACE)); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | TEST(MarkCompactCollector) { |
| 150 | InitializeVM(); |
| 151 | |
| 152 | v8::HandleScope sc; |
| 153 | // call mark-compact when heap is empty |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 154 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 155 | |
| 156 | // keep allocating garbage in new space until it fails |
| 157 | const int ARRAY_SIZE = 100; |
| 158 | Object* array; |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 159 | MaybeObject* maybe_array; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 160 | do { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 161 | maybe_array = Heap::AllocateFixedArray(ARRAY_SIZE); |
| 162 | } while (maybe_array->ToObject(&array)); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 163 | Heap::CollectGarbage(NEW_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 164 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 165 | array = Heap::AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 166 | |
| 167 | // keep allocating maps until it fails |
| 168 | Object* mapp; |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 169 | MaybeObject* maybe_mapp; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 170 | do { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 171 | maybe_mapp = Heap::AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 172 | } while (maybe_mapp->ToObject(&mapp)); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 173 | Heap::CollectGarbage(MAP_SPACE); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 174 | mapp = Heap::AllocateMap(JS_OBJECT_TYPE, |
| 175 | JSObject::kHeaderSize)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 176 | |
| 177 | // allocate a garbage |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 178 | String* func_name = |
| 179 | String::cast(Heap::LookupAsciiSymbol("theFunction")->ToObjectChecked()); |
| 180 | SharedFunctionInfo* function_share = SharedFunctionInfo::cast( |
| 181 | Heap::AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); |
| 182 | JSFunction* function = JSFunction::cast( |
| 183 | Heap::AllocateFunction(*Top::function_map(), |
| 184 | function_share, |
| 185 | Heap::undefined_value())->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 186 | Map* initial_map = |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 187 | Map::cast(Heap::AllocateMap(JS_OBJECT_TYPE, |
| 188 | JSObject::kHeaderSize)->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 189 | function->set_initial_map(initial_map); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 190 | Top::context()->global()->SetProperty(func_name, |
| 191 | function, |
| 192 | NONE)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 193 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 194 | JSObject* obj = |
| 195 | JSObject::cast(Heap::AllocateJSObject(function)->ToObjectChecked()); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 196 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 198 | func_name = |
| 199 | String::cast(Heap::LookupAsciiSymbol("theFunction")->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 200 | CHECK(Top::context()->global()->HasLocalProperty(func_name)); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 201 | Object* func_value = |
| 202 | Top::context()->global()->GetProperty(func_name)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 203 | CHECK(func_value->IsJSFunction()); |
| 204 | function = JSFunction::cast(func_value); |
| 205 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 206 | obj = JSObject::cast(Heap::AllocateJSObject(function)->ToObjectChecked()); |
| 207 | String* obj_name = |
| 208 | String::cast(Heap::LookupAsciiSymbol("theObject")->ToObjectChecked()); |
| 209 | Top::context()->global()->SetProperty(obj_name, |
| 210 | obj, |
| 211 | NONE)->ToObjectChecked(); |
| 212 | String* prop_name = |
| 213 | String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); |
| 214 | obj->SetProperty(prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 215 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 216 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 217 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 218 | obj_name = |
| 219 | String::cast(Heap::LookupAsciiSymbol("theObject")->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 220 | CHECK(Top::context()->global()->HasLocalProperty(obj_name)); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 221 | CHECK(Top::context()->global()-> |
| 222 | GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); |
| 223 | obj = JSObject::cast( |
| 224 | Top::context()->global()->GetProperty(obj_name)->ToObjectChecked()); |
| 225 | prop_name = |
| 226 | String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); |
| 227 | CHECK(obj->GetProperty(prop_name)->ToObjectChecked() == Smi::FromInt(23)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 231 | static Handle<Map> CreateMap() { |
| 232 | return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | TEST(MapCompact) { |
| 237 | FLAG_max_map_space_pages = 16; |
| 238 | InitializeVM(); |
| 239 | |
| 240 | { |
| 241 | v8::HandleScope sc; |
| 242 | // keep allocating maps while pointers are still encodable and thus |
| 243 | // mark compact is permitted. |
| 244 | Handle<JSObject> root = Factory::NewJSObjectFromMap(CreateMap()); |
| 245 | do { |
| 246 | Handle<Map> map = CreateMap(); |
| 247 | map->set_prototype(*root); |
| 248 | root = Factory::NewJSObjectFromMap(map); |
| 249 | } while (Heap::map_space()->MapPointersEncodable()); |
| 250 | } |
| 251 | // Now, as we don't have any handles to just allocated maps, we should |
| 252 | // be able to trigger map compaction. |
| 253 | // To give an additional chance to fail, try to force compaction which |
| 254 | // should be impossible right now. |
| 255 | Heap::CollectAllGarbage(true); |
| 256 | // And now map pointers should be encodable again. |
| 257 | CHECK(Heap::map_space()->MapPointersEncodable()); |
| 258 | } |
| 259 | |
| 260 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 261 | static int gc_starts = 0; |
| 262 | static int gc_ends = 0; |
| 263 | |
| 264 | static void GCPrologueCallbackFunc() { |
| 265 | CHECK(gc_starts == gc_ends); |
| 266 | gc_starts++; |
| 267 | } |
| 268 | |
| 269 | |
| 270 | static void GCEpilogueCallbackFunc() { |
| 271 | CHECK(gc_starts == gc_ends + 1); |
| 272 | gc_ends++; |
| 273 | } |
| 274 | |
| 275 | |
| 276 | TEST(GCCallback) { |
| 277 | InitializeVM(); |
| 278 | |
| 279 | Heap::SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc); |
| 280 | Heap::SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc); |
| 281 | |
| 282 | // Scavenge does not call GC callback functions. |
| 283 | Heap::PerformScavenge(); |
| 284 | |
| 285 | CHECK_EQ(0, gc_starts); |
| 286 | CHECK_EQ(gc_ends, gc_starts); |
| 287 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 288 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 289 | CHECK_EQ(1, gc_starts); |
| 290 | CHECK_EQ(gc_ends, gc_starts); |
| 291 | } |
| 292 | |
| 293 | |
| 294 | static int NumberOfWeakCalls = 0; |
| 295 | static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) { |
| 296 | NumberOfWeakCalls++; |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 297 | handle.Dispose(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | TEST(ObjectGroups) { |
| 301 | InitializeVM(); |
| 302 | |
| 303 | NumberOfWeakCalls = 0; |
| 304 | v8::HandleScope handle_scope; |
| 305 | |
| 306 | Handle<Object> g1s1 = |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 307 | GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 308 | Handle<Object> g1s2 = |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 309 | GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 310 | GlobalHandles::MakeWeak(g1s1.location(), |
| 311 | reinterpret_cast<void*>(1234), |
| 312 | &WeakPointerCallback); |
| 313 | GlobalHandles::MakeWeak(g1s2.location(), |
| 314 | reinterpret_cast<void*>(1234), |
| 315 | &WeakPointerCallback); |
| 316 | |
| 317 | Handle<Object> g2s1 = |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 318 | GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 319 | Handle<Object> g2s2 = |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 320 | GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 321 | GlobalHandles::MakeWeak(g2s1.location(), |
| 322 | reinterpret_cast<void*>(1234), |
| 323 | &WeakPointerCallback); |
| 324 | GlobalHandles::MakeWeak(g2s2.location(), |
| 325 | reinterpret_cast<void*>(1234), |
| 326 | &WeakPointerCallback); |
| 327 | |
| 328 | Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. |
| 329 | |
| 330 | // Connect group 1 and 2, make a cycle. |
| 331 | Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); |
| 332 | Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); |
| 333 | |
| 334 | { |
| 335 | Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
| 336 | Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 337 | GlobalHandles::AddGroup(g1_objects, 2); |
| 338 | GlobalHandles::AddGroup(g2_objects, 2); |
| 339 | } |
| 340 | // Do a full GC |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 341 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 342 | |
| 343 | // All object should be alive. |
| 344 | CHECK_EQ(0, NumberOfWeakCalls); |
| 345 | |
| 346 | // Weaken the root. |
| 347 | GlobalHandles::MakeWeak(root.location(), |
| 348 | reinterpret_cast<void*>(1234), |
| 349 | &WeakPointerCallback); |
| 350 | |
| 351 | // Groups are deleted, rebuild groups. |
| 352 | { |
| 353 | Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
| 354 | Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 355 | GlobalHandles::AddGroup(g1_objects, 2); |
| 356 | GlobalHandles::AddGroup(g2_objects, 2); |
| 357 | } |
| 358 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 359 | Heap::CollectGarbage(OLD_POINTER_SPACE); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 360 | |
| 361 | // All objects should be gone. 5 global handles in total. |
| 362 | CHECK_EQ(5, NumberOfWeakCalls); |
| 363 | } |