OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 CHECK_EQ(0, NumberOfWeakCalls); | 107 CHECK_EQ(0, NumberOfWeakCalls); |
108 CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); | 108 CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); |
109 CHECK_EQ( | 109 CHECK_EQ( |
110 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); | 110 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); |
111 | 111 |
112 // Make the global reference to the key weak. | 112 // Make the global reference to the key weak. |
113 { | 113 { |
114 HandleScope scope(isolate); | 114 HandleScope scope(isolate); |
115 global_handles->MakeWeak(key.location(), | 115 global_handles->MakeWeak(key.location(), |
116 reinterpret_cast<void*>(1234), | 116 reinterpret_cast<void*>(1234), |
117 &WeakPointerCallback, | 117 &WeakPointerCallback); |
118 NULL); | |
119 } | 118 } |
120 CHECK(global_handles->IsWeak(key.location())); | 119 CHECK(global_handles->IsWeak(key.location())); |
121 | 120 |
122 // Force a full GC. | 121 // Force a full GC. |
123 // Perform two consecutive GCs because the first one will only clear | 122 // Perform two consecutive GCs because the first one will only clear |
124 // weak references whereas the second one will also clear weak maps. | 123 // weak references whereas the second one will also clear weak maps. |
125 heap->CollectAllGarbage(false); | 124 heap->CollectAllGarbage(false); |
126 CHECK_EQ(1, NumberOfWeakCalls); | 125 CHECK_EQ(1, NumberOfWeakCalls); |
127 CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); | 126 CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); |
128 CHECK_EQ( | 127 CHECK_EQ( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 Handle<Smi>(Smi::FromInt(i), isolate)); | 241 Handle<Smi>(Smi::FromInt(i), isolate)); |
243 } | 242 } |
244 | 243 |
245 // Force compacting garbage collection. The subsequent collections are used | 244 // Force compacting garbage collection. The subsequent collections are used |
246 // to verify that key references were actually updated. | 245 // to verify that key references were actually updated. |
247 CHECK(FLAG_always_compact); | 246 CHECK(FLAG_always_compact); |
248 heap->CollectAllGarbage(Heap::kNoGCFlags); | 247 heap->CollectAllGarbage(Heap::kNoGCFlags); |
249 heap->CollectAllGarbage(Heap::kNoGCFlags); | 248 heap->CollectAllGarbage(Heap::kNoGCFlags); |
250 heap->CollectAllGarbage(Heap::kNoGCFlags); | 249 heap->CollectAllGarbage(Heap::kNoGCFlags); |
251 } | 250 } |
OLD | NEW |