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

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

Issue 1303393004: Revert of [heap] More flag cleanup. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Put entry into weak set. 88 // Put entry into weak set.
89 { 89 {
90 HandleScope scope(isolate); 90 HandleScope scope(isolate);
91 Handle<Smi> smi(Smi::FromInt(23), isolate); 91 Handle<Smi> smi(Smi::FromInt(23), isolate);
92 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 92 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
93 JSWeakCollection::Set(weakset, key, smi, hash); 93 JSWeakCollection::Set(weakset, key, smi, hash);
94 } 94 }
95 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 95 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
96 96
97 // Force a full GC. 97 // Force a full GC.
98 heap->CollectAllGarbage("WeakSet_Weakness", Heap::kNoGCFlags); 98 heap->CollectAllGarbage(false);
99 CHECK_EQ(0, NumberOfWeakCalls); 99 CHECK_EQ(0, NumberOfWeakCalls);
100 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 100 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
101 CHECK_EQ( 101 CHECK_EQ(
102 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 102 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
103 103
104 // Make the global reference to the key weak. 104 // Make the global reference to the key weak.
105 { 105 {
106 HandleScope scope(isolate); 106 HandleScope scope(isolate);
107 std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); 107 std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
108 GlobalHandles::MakeWeak(key.location(), 108 GlobalHandles::MakeWeak(key.location(),
109 reinterpret_cast<void*>(&handle_and_id), 109 reinterpret_cast<void*>(&handle_and_id),
110 &WeakPointerCallback); 110 &WeakPointerCallback);
111 } 111 }
112 CHECK(global_handles->IsWeak(key.location())); 112 CHECK(global_handles->IsWeak(key.location()));
113 113
114 // Force a full GC. 114 // Force a full GC.
115 // Perform two consecutive GCs because the first one will only clear 115 // Perform two consecutive GCs because the first one will only clear
116 // weak references whereas the second one will also clear weak sets. 116 // weak references whereas the second one will also clear weak sets.
117 heap->CollectAllGarbage("WeakSet_Weakness", Heap::kNoGCFlags); 117 heap->CollectAllGarbage(false);
118 CHECK_EQ(1, NumberOfWeakCalls); 118 CHECK_EQ(1, NumberOfWeakCalls);
119 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 119 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
120 CHECK_EQ( 120 CHECK_EQ(
121 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 121 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
122 heap->CollectAllGarbage("WeakSet_Weakness", Heap::kNoGCFlags); 122 heap->CollectAllGarbage(false);
123 CHECK_EQ(1, NumberOfWeakCalls); 123 CHECK_EQ(1, NumberOfWeakCalls);
124 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 124 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements());
125 CHECK_EQ( 125 CHECK_EQ(
126 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 126 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
127 } 127 }
128 128
129 129
130 TEST(WeakSet_Shrinking) { 130 TEST(WeakSet_Shrinking) {
131 LocalContext context; 131 LocalContext context;
132 Isolate* isolate = GetIsolateFrom(&context); 132 Isolate* isolate = GetIsolateFrom(&context);
(...skipping 17 matching lines...) Expand all
150 } 150 }
151 } 151 }
152 152
153 // Check increased capacity. 153 // Check increased capacity.
154 CHECK_EQ(128, ObjectHashTable::cast(weakset->table())->Capacity()); 154 CHECK_EQ(128, ObjectHashTable::cast(weakset->table())->Capacity());
155 155
156 // Force a full GC. 156 // Force a full GC.
157 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 157 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->NumberOfElements());
158 CHECK_EQ( 158 CHECK_EQ(
159 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 159 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
160 heap->CollectAllGarbage("WeakSet_Shrinking", Heap::kNoGCFlags); 160 heap->CollectAllGarbage(false);
161 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 161 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements());
162 CHECK_EQ( 162 CHECK_EQ(
163 32, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 163 32, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
164 164
165 // Check shrunk capacity. 165 // Check shrunk capacity.
166 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->Capacity()); 166 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->Capacity());
167 } 167 }
168 168
169 169
170 // Test that weak set values on an evacuation candidate which are not reachable 170 // Test that weak set values on an evacuation candidate which are not reachable
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 JSWeakCollection::Set(weakset, keys[i], smi, hash); 241 JSWeakCollection::Set(weakset, keys[i], smi, hash);
242 } 242 }
243 243
244 // Force compacting garbage collection. The subsequent collections are used 244 // Force compacting garbage collection. The subsequent collections are used
245 // to verify that key references were actually updated. 245 // to verify that key references were actually updated.
246 CHECK(FLAG_always_compact); 246 CHECK(FLAG_always_compact);
247 heap->CollectAllGarbage(); 247 heap->CollectAllGarbage();
248 heap->CollectAllGarbage(); 248 heap->CollectAllGarbage();
249 heap->CollectAllGarbage(); 249 heap->CollectAllGarbage();
250 } 250 }
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