blob: 6d1b5ce632529c7e0bf18037262cb35e0943633d [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// 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"
Steve Blocka7e24c12009-10-30 11:49:00 +000034#include "cctest.h"
35
36using namespace v8::internal;
37
38static v8::Persistent<v8::Context> env;
39
40static void InitializeVM() {
41 if (env.IsEmpty()) env = v8::Context::New();
42 v8::HandleScope scope;
43 env->Enter();
44}
45
46
47TEST(MarkingStack) {
48 int mem_size = 20 * kPointerSize;
49 byte* mem = NewArray<byte>(20*kPointerSize);
50 Address low = reinterpret_cast<Address>(mem);
51 Address high = low + mem_size;
52 MarkingStack s;
53 s.Initialize(low, high);
54
55 Address address = NULL;
56 while (!s.is_full()) {
57 s.Push(HeapObject::FromAddress(address));
58 address += kPointerSize;
59 }
60
61 while (!s.is_empty()) {
62 Address value = s.Pop()->address();
63 address -= kPointerSize;
64 CHECK_EQ(address, value);
65 }
66
67 CHECK_EQ(NULL, address);
68 DeleteArray(mem);
69}
70
71
72TEST(Promotion) {
Ben Murdochb0fe1622011-05-05 13:52:32 +010073 // This test requires compaction. If compaction is turned off, we
74 // skip the entire test.
75 if (FLAG_never_compact) return;
76
Steve Blocka7e24c12009-10-30 11:49:00 +000077 // Ensure that we get a compacting collection so that objects are promoted
78 // from new space.
79 FLAG_gc_global = true;
80 FLAG_always_compact = true;
Steve Block44f0eee2011-05-26 01:26:41 +010081 HEAP->ConfigureHeap(2*256*KB, 4*MB, 4*MB);
Steve Blocka7e24c12009-10-30 11:49:00 +000082
83 InitializeVM();
84
85 v8::HandleScope sc;
86
87 // Allocate a fixed array in the new space.
88 int array_size =
Steve Block44f0eee2011-05-26 01:26:41 +010089 (HEAP->MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) /
Steve Blocka7e24c12009-10-30 11:49:00 +000090 (kPointerSize * 4);
Steve Block44f0eee2011-05-26 01:26:41 +010091 Object* obj = HEAP->AllocateFixedArray(array_size)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +000092
93 Handle<FixedArray> array(FixedArray::cast(obj));
94
95 // Array should be in the new space.
Steve Block44f0eee2011-05-26 01:26:41 +010096 CHECK(HEAP->InSpace(*array, NEW_SPACE));
Steve Blocka7e24c12009-10-30 11:49:00 +000097
98 // Call the m-c collector, so array becomes an old object.
Steve Block44f0eee2011-05-26 01:26:41 +010099 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000100
101 // Array now sits in the old space
Steve Block44f0eee2011-05-26 01:26:41 +0100102 CHECK(HEAP->InSpace(*array, OLD_POINTER_SPACE));
Steve Blocka7e24c12009-10-30 11:49:00 +0000103}
104
105
106TEST(NoPromotion) {
Steve Block44f0eee2011-05-26 01:26:41 +0100107 HEAP->ConfigureHeap(2*256*KB, 4*MB, 4*MB);
Steve Blocka7e24c12009-10-30 11:49:00 +0000108
109 // Test the situation that some objects in new space are promoted to
110 // the old space
111 InitializeVM();
112
113 v8::HandleScope sc;
114
115 // Do a mark compact GC to shrink the heap.
Steve Block44f0eee2011-05-26 01:26:41 +0100116 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000117
118 // Allocate a big Fixed array in the new space.
Steve Block44f0eee2011-05-26 01:26:41 +0100119 int size = (HEAP->MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) /
Steve Blocka7e24c12009-10-30 11:49:00 +0000120 kPointerSize;
Steve Block44f0eee2011-05-26 01:26:41 +0100121 Object* obj = HEAP->AllocateFixedArray(size)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000122
123 Handle<FixedArray> array(FixedArray::cast(obj));
124
125 // Array still stays in the new space.
Steve Block44f0eee2011-05-26 01:26:41 +0100126 CHECK(HEAP->InSpace(*array, NEW_SPACE));
Steve Blocka7e24c12009-10-30 11:49:00 +0000127
128 // Allocate objects in the old space until out of memory.
129 FixedArray* host = *array;
130 while (true) {
John Reck59135872010-11-02 12:39:01 -0700131 Object* obj;
Steve Block44f0eee2011-05-26 01:26:41 +0100132 { MaybeObject* maybe_obj = HEAP->AllocateFixedArray(100, TENURED);
John Reck59135872010-11-02 12:39:01 -0700133 if (!maybe_obj->ToObject(&obj)) break;
134 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000135
136 host->set(0, obj);
137 host = FixedArray::cast(obj);
138 }
139
140 // Call mark compact GC, and it should pass.
Steve Block44f0eee2011-05-26 01:26:41 +0100141 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000142
143 // array should not be promoted because the old space is full.
Steve Block44f0eee2011-05-26 01:26:41 +0100144 CHECK(HEAP->InSpace(*array, NEW_SPACE));
Steve Blocka7e24c12009-10-30 11:49:00 +0000145}
146
147
148TEST(MarkCompactCollector) {
149 InitializeVM();
150
151 v8::HandleScope sc;
152 // call mark-compact when heap is empty
Steve Block44f0eee2011-05-26 01:26:41 +0100153 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000154
155 // keep allocating garbage in new space until it fails
156 const int ARRAY_SIZE = 100;
157 Object* array;
John Reck59135872010-11-02 12:39:01 -0700158 MaybeObject* maybe_array;
Steve Blocka7e24c12009-10-30 11:49:00 +0000159 do {
Steve Block44f0eee2011-05-26 01:26:41 +0100160 maybe_array = HEAP->AllocateFixedArray(ARRAY_SIZE);
John Reck59135872010-11-02 12:39:01 -0700161 } while (maybe_array->ToObject(&array));
Steve Block44f0eee2011-05-26 01:26:41 +0100162 HEAP->CollectGarbage(NEW_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000163
Steve Block44f0eee2011-05-26 01:26:41 +0100164 array = HEAP->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000165
166 // keep allocating maps until it fails
167 Object* mapp;
John Reck59135872010-11-02 12:39:01 -0700168 MaybeObject* maybe_mapp;
Steve Blocka7e24c12009-10-30 11:49:00 +0000169 do {
Steve Block44f0eee2011-05-26 01:26:41 +0100170 maybe_mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
John Reck59135872010-11-02 12:39:01 -0700171 } while (maybe_mapp->ToObject(&mapp));
Steve Block44f0eee2011-05-26 01:26:41 +0100172 HEAP->CollectGarbage(MAP_SPACE);
173 mapp = HEAP->AllocateMap(JS_OBJECT_TYPE,
John Reck59135872010-11-02 12:39:01 -0700174 JSObject::kHeaderSize)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000175
176 // allocate a garbage
John Reck59135872010-11-02 12:39:01 -0700177 String* func_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100178 String::cast(HEAP->LookupAsciiSymbol("theFunction")->ToObjectChecked());
John Reck59135872010-11-02 12:39:01 -0700179 SharedFunctionInfo* function_share = SharedFunctionInfo::cast(
Steve Block44f0eee2011-05-26 01:26:41 +0100180 HEAP->AllocateSharedFunctionInfo(func_name)->ToObjectChecked());
John Reck59135872010-11-02 12:39:01 -0700181 JSFunction* function = JSFunction::cast(
Steve Block44f0eee2011-05-26 01:26:41 +0100182 HEAP->AllocateFunction(*Isolate::Current()->function_map(),
John Reck59135872010-11-02 12:39:01 -0700183 function_share,
Steve Block44f0eee2011-05-26 01:26:41 +0100184 HEAP->undefined_value())->ToObjectChecked());
Steve Blocka7e24c12009-10-30 11:49:00 +0000185 Map* initial_map =
Steve Block44f0eee2011-05-26 01:26:41 +0100186 Map::cast(HEAP->AllocateMap(JS_OBJECT_TYPE,
John Reck59135872010-11-02 12:39:01 -0700187 JSObject::kHeaderSize)->ToObjectChecked());
Steve Blocka7e24c12009-10-30 11:49:00 +0000188 function->set_initial_map(initial_map);
Steve Block44f0eee2011-05-26 01:26:41 +0100189 Isolate::Current()->context()->global()->SetProperty(
190 func_name, function, NONE, kNonStrictMode)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000191
Steve Block44f0eee2011-05-26 01:26:41 +0100192 JSObject* obj = JSObject::cast(
193 HEAP->AllocateJSObject(function)->ToObjectChecked());
194 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000195
John Reck59135872010-11-02 12:39:01 -0700196 func_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100197 String::cast(HEAP->LookupAsciiSymbol("theFunction")->ToObjectChecked());
198 CHECK(Isolate::Current()->context()->global()->HasLocalProperty(func_name));
199 Object* func_value = Isolate::Current()->context()->global()->
200 GetProperty(func_name)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000201 CHECK(func_value->IsJSFunction());
202 function = JSFunction::cast(func_value);
203
Steve Block44f0eee2011-05-26 01:26:41 +0100204 obj = JSObject::cast(HEAP->AllocateJSObject(function)->ToObjectChecked());
John Reck59135872010-11-02 12:39:01 -0700205 String* obj_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100206 String::cast(HEAP->LookupAsciiSymbol("theObject")->ToObjectChecked());
207 Isolate::Current()->context()->global()->SetProperty(
208 obj_name, obj, NONE, kNonStrictMode)->ToObjectChecked();
John Reck59135872010-11-02 12:39:01 -0700209 String* prop_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100210 String::cast(HEAP->LookupAsciiSymbol("theSlot")->ToObjectChecked());
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100211 obj->SetProperty(prop_name,
212 Smi::FromInt(23),
213 NONE,
214 kNonStrictMode)->ToObjectChecked();
Steve Blocka7e24c12009-10-30 11:49:00 +0000215
Steve Block44f0eee2011-05-26 01:26:41 +0100216 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000217
John Reck59135872010-11-02 12:39:01 -0700218 obj_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100219 String::cast(HEAP->LookupAsciiSymbol("theObject")->ToObjectChecked());
220 CHECK(Isolate::Current()->context()->global()->HasLocalProperty(obj_name));
221 CHECK(Isolate::Current()->context()->global()->
222 GetProperty(obj_name)->ToObjectChecked()->IsJSObject());
223 obj = JSObject::cast(Isolate::Current()->context()->global()->
224 GetProperty(obj_name)->ToObjectChecked());
John Reck59135872010-11-02 12:39:01 -0700225 prop_name =
Steve Block44f0eee2011-05-26 01:26:41 +0100226 String::cast(HEAP->LookupAsciiSymbol("theSlot")->ToObjectChecked());
227 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23));
Steve Blocka7e24c12009-10-30 11:49:00 +0000228}
229
230
Leon Clarked91b9f72010-01-27 17:25:45 +0000231static Handle<Map> CreateMap() {
Steve Block44f0eee2011-05-26 01:26:41 +0100232 return FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
Leon Clarked91b9f72010-01-27 17:25:45 +0000233}
234
235
236TEST(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.
Steve Block44f0eee2011-05-26 01:26:41 +0100244 Handle<JSObject> root = FACTORY->NewJSObjectFromMap(CreateMap());
Leon Clarked91b9f72010-01-27 17:25:45 +0000245 do {
246 Handle<Map> map = CreateMap();
247 map->set_prototype(*root);
Steve Block44f0eee2011-05-26 01:26:41 +0100248 root = FACTORY->NewJSObjectFromMap(map);
249 } while (HEAP->map_space()->MapPointersEncodable());
Leon Clarked91b9f72010-01-27 17:25:45 +0000250 }
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.
Steve Block44f0eee2011-05-26 01:26:41 +0100255 HEAP->CollectAllGarbage(true);
Leon Clarked91b9f72010-01-27 17:25:45 +0000256 // And now map pointers should be encodable again.
Steve Block44f0eee2011-05-26 01:26:41 +0100257 CHECK(HEAP->map_space()->MapPointersEncodable());
Leon Clarked91b9f72010-01-27 17:25:45 +0000258}
259
260
Steve Blocka7e24c12009-10-30 11:49:00 +0000261static int gc_starts = 0;
262static int gc_ends = 0;
263
264static void GCPrologueCallbackFunc() {
265 CHECK(gc_starts == gc_ends);
266 gc_starts++;
267}
268
269
270static void GCEpilogueCallbackFunc() {
271 CHECK(gc_starts == gc_ends + 1);
272 gc_ends++;
273}
274
275
276TEST(GCCallback) {
277 InitializeVM();
278
Steve Block44f0eee2011-05-26 01:26:41 +0100279 HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc);
280 HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc);
Steve Blocka7e24c12009-10-30 11:49:00 +0000281
282 // Scavenge does not call GC callback functions.
Steve Block44f0eee2011-05-26 01:26:41 +0100283 HEAP->PerformScavenge();
Steve Blocka7e24c12009-10-30 11:49:00 +0000284
285 CHECK_EQ(0, gc_starts);
286 CHECK_EQ(gc_ends, gc_starts);
287
Steve Block44f0eee2011-05-26 01:26:41 +0100288 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000289 CHECK_EQ(1, gc_starts);
290 CHECK_EQ(gc_ends, gc_starts);
291}
292
293
294static int NumberOfWeakCalls = 0;
295static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) {
Steve Block44f0eee2011-05-26 01:26:41 +0100296 ASSERT(id == reinterpret_cast<void*>(1234));
Steve Blocka7e24c12009-10-30 11:49:00 +0000297 NumberOfWeakCalls++;
Kristian Monsen50ef84f2010-07-29 15:18:00 +0100298 handle.Dispose();
Steve Blocka7e24c12009-10-30 11:49:00 +0000299}
300
301TEST(ObjectGroups) {
Steve Block44f0eee2011-05-26 01:26:41 +0100302 GlobalHandles* global_handles = Isolate::Current()->global_handles();
Steve Blocka7e24c12009-10-30 11:49:00 +0000303 InitializeVM();
304
305 NumberOfWeakCalls = 0;
306 v8::HandleScope handle_scope;
307
308 Handle<Object> g1s1 =
Steve Block44f0eee2011-05-26 01:26:41 +0100309 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
Steve Blocka7e24c12009-10-30 11:49:00 +0000310 Handle<Object> g1s2 =
Steve Block44f0eee2011-05-26 01:26:41 +0100311 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
312 Handle<Object> g1c1 =
313 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
314 global_handles->MakeWeak(g1s1.location(),
315 reinterpret_cast<void*>(1234),
316 &WeakPointerCallback);
317 global_handles->MakeWeak(g1s2.location(),
318 reinterpret_cast<void*>(1234),
319 &WeakPointerCallback);
320 global_handles->MakeWeak(g1c1.location(),
321 reinterpret_cast<void*>(1234),
322 &WeakPointerCallback);
Steve Blocka7e24c12009-10-30 11:49:00 +0000323
324 Handle<Object> g2s1 =
Steve Block44f0eee2011-05-26 01:26:41 +0100325 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
Steve Blocka7e24c12009-10-30 11:49:00 +0000326 Handle<Object> g2s2 =
Steve Block44f0eee2011-05-26 01:26:41 +0100327 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
328 Handle<Object> g2c1 =
329 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
330 global_handles->MakeWeak(g2s1.location(),
331 reinterpret_cast<void*>(1234),
332 &WeakPointerCallback);
333 global_handles->MakeWeak(g2s2.location(),
334 reinterpret_cast<void*>(1234),
335 &WeakPointerCallback);
336 global_handles->MakeWeak(g2c1.location(),
337 reinterpret_cast<void*>(1234),
338 &WeakPointerCallback);
Steve Blocka7e24c12009-10-30 11:49:00 +0000339
Steve Block44f0eee2011-05-26 01:26:41 +0100340 Handle<Object> root = global_handles->Create(*g1s1); // make a root.
Steve Blocka7e24c12009-10-30 11:49:00 +0000341
342 // Connect group 1 and 2, make a cycle.
343 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2);
344 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1);
345
346 {
347 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
Steve Block44f0eee2011-05-26 01:26:41 +0100348 Object** g1_children[] = { g1c1.location() };
Steve Blocka7e24c12009-10-30 11:49:00 +0000349 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
Steve Block44f0eee2011-05-26 01:26:41 +0100350 Object** g2_children[] = { g2c1.location() };
351 global_handles->AddObjectGroup(g1_objects, 2, NULL);
352 global_handles->AddImplicitReferences(HeapObject::cast(*g1s1),
353 g1_children, 1);
354 global_handles->AddObjectGroup(g2_objects, 2, NULL);
355 global_handles->AddImplicitReferences(HeapObject::cast(*g2s2),
356 g2_children, 1);
Steve Blocka7e24c12009-10-30 11:49:00 +0000357 }
358 // Do a full GC
Steve Block44f0eee2011-05-26 01:26:41 +0100359 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000360
361 // All object should be alive.
362 CHECK_EQ(0, NumberOfWeakCalls);
363
364 // Weaken the root.
Steve Block44f0eee2011-05-26 01:26:41 +0100365 global_handles->MakeWeak(root.location(),
366 reinterpret_cast<void*>(1234),
367 &WeakPointerCallback);
368 // But make children strong roots---all the objects (except for children)
369 // should be collectable now.
370 global_handles->ClearWeakness(g1c1.location());
371 global_handles->ClearWeakness(g2c1.location());
Steve Blocka7e24c12009-10-30 11:49:00 +0000372
373 // Groups are deleted, rebuild groups.
374 {
375 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
Steve Block44f0eee2011-05-26 01:26:41 +0100376 Object** g1_children[] = { g1c1.location() };
Steve Blocka7e24c12009-10-30 11:49:00 +0000377 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
Steve Block44f0eee2011-05-26 01:26:41 +0100378 Object** g2_children[] = { g2c1.location() };
379 global_handles->AddObjectGroup(g1_objects, 2, NULL);
380 global_handles->AddImplicitReferences(HeapObject::cast(*g1s1),
381 g1_children, 1);
382 global_handles->AddObjectGroup(g2_objects, 2, NULL);
383 global_handles->AddImplicitReferences(HeapObject::cast(*g2s2),
384 g2_children, 1);
Steve Blocka7e24c12009-10-30 11:49:00 +0000385 }
386
Steve Block44f0eee2011-05-26 01:26:41 +0100387 HEAP->CollectGarbage(OLD_POINTER_SPACE);
Steve Blocka7e24c12009-10-30 11:49:00 +0000388
389 // All objects should be gone. 5 global handles in total.
390 CHECK_EQ(5, NumberOfWeakCalls);
Steve Block44f0eee2011-05-26 01:26:41 +0100391
392 // And now make children weak again and collect them.
393 global_handles->MakeWeak(g1c1.location(),
394 reinterpret_cast<void*>(1234),
395 &WeakPointerCallback);
396 global_handles->MakeWeak(g2c1.location(),
397 reinterpret_cast<void*>(1234),
398 &WeakPointerCallback);
399
400 HEAP->CollectGarbage(OLD_POINTER_SPACE);
401 CHECK_EQ(7, NumberOfWeakCalls);
Steve Blocka7e24c12009-10-30 11:49:00 +0000402}