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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Perform two consecutive GCs because the first one will only clear | 116 // Perform two consecutive GCs because the first one will only clear |
117 // weak references whereas the second one will also clear weak sets. | 117 // weak references whereas the second one will also clear weak sets. |
118 heap->CollectAllGarbage(false); | 118 heap->CollectAllGarbage(false); |
119 CHECK_EQ(1, NumberOfWeakCalls); | 119 CHECK_EQ(1, NumberOfWeakCalls); |
120 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); | 120 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); |
121 CHECK_EQ( | 121 CHECK_EQ( |
122 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); | 122 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); |
123 heap->CollectAllGarbage(false); | 123 heap->CollectAllGarbage(false); |
124 CHECK_EQ(1, NumberOfWeakCalls); | 124 CHECK_EQ(1, NumberOfWeakCalls); |
125 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); | 125 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); |
126 CHECK_EQ( | 126 CHECK_EQ(0, |
127 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); | 127 ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); |
128 } | 128 } |
129 | 129 |
130 | 130 |
131 TEST(WeakSet_Shrinking) { | 131 TEST(WeakSet_Shrinking) { |
132 LocalContext context; | 132 LocalContext context; |
133 Isolate* isolate = GetIsolateFrom(&context); | 133 Isolate* isolate = GetIsolateFrom(&context); |
134 Factory* factory = isolate->factory(); | 134 Factory* factory = isolate->factory(); |
135 Heap* heap = isolate->heap(); | 135 Heap* heap = isolate->heap(); |
136 HandleScope scope(isolate); | 136 HandleScope scope(isolate); |
137 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); | 137 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 JSWeakCollection::Set(weakset, keys[i], smi, hash); | 240 JSWeakCollection::Set(weakset, keys[i], smi, hash); |
241 } | 241 } |
242 | 242 |
243 // Force compacting garbage collection. The subsequent collections are used | 243 // Force compacting garbage collection. The subsequent collections are used |
244 // to verify that key references were actually updated. | 244 // to verify that key references were actually updated. |
245 CHECK(FLAG_always_compact); | 245 CHECK(FLAG_always_compact); |
246 heap->CollectAllGarbage(); | 246 heap->CollectAllGarbage(); |
247 heap->CollectAllGarbage(); | 247 heap->CollectAllGarbage(); |
248 heap->CollectAllGarbage(); | 248 heap->CollectAllGarbage(); |
249 } | 249 } |
OLD | NEW |