Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: test/cctest/test-weaksets.cc

Issue 1877233005: Rehash and clear deleted entries in weak collections during GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698