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

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

Issue 1314053003: Move runtime helper for JSWeakCollection onto objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-runtime-helpers-1
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Handle<JSObject> object = factory->NewJSObjectFromMap(map); 83 Handle<JSObject> object = factory->NewJSObjectFromMap(map);
84 key = global_handles->Create(*object); 84 key = global_handles->Create(*object);
85 } 85 }
86 CHECK(!global_handles->IsWeak(key.location())); 86 CHECK(!global_handles->IsWeak(key.location()));
87 87
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 Runtime::WeakCollectionSet(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(false); 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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->Capacity()); 139 CHECK_EQ(32, ObjectHashTable::cast(weakset->table())->Capacity());
140 140
141 // Fill up weak set to trigger capacity change. 141 // Fill up weak set to trigger capacity change.
142 { 142 {
143 HandleScope scope(isolate); 143 HandleScope scope(isolate);
144 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 144 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
145 for (int i = 0; i < 32; i++) { 145 for (int i = 0; i < 32; i++) {
146 Handle<JSObject> object = factory->NewJSObjectFromMap(map); 146 Handle<JSObject> object = factory->NewJSObjectFromMap(map);
147 Handle<Smi> smi(Smi::FromInt(i), isolate); 147 Handle<Smi> smi(Smi::FromInt(i), isolate);
148 int32_t hash = Object::GetOrCreateHash(isolate, object)->value(); 148 int32_t hash = Object::GetOrCreateHash(isolate, object)->value();
149 Runtime::WeakCollectionSet(weakset, object, smi, hash); 149 JSWeakCollection::Set(weakset, object, smi, hash);
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());
(...skipping 28 matching lines...) Expand all
188 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); 188 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);
189 189
190 // Fill up weak set with values on an evacuation candidate. 190 // Fill up weak set with values on an evacuation candidate.
191 { 191 {
192 HandleScope scope(isolate); 192 HandleScope scope(isolate);
193 for (int i = 0; i < 32; i++) { 193 for (int i = 0; i < 32; i++) {
194 Handle<JSObject> object = factory->NewJSObject(function, TENURED); 194 Handle<JSObject> object = factory->NewJSObject(function, TENURED);
195 CHECK(!heap->InNewSpace(object->address())); 195 CHECK(!heap->InNewSpace(object->address()));
196 CHECK(!first_page->Contains(object->address())); 196 CHECK(!first_page->Contains(object->address()));
197 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 197 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
198 Runtime::WeakCollectionSet(weakset, key, object, hash); 198 JSWeakCollection::Set(weakset, key, object, hash);
199 } 199 }
200 } 200 }
201 201
202 // Force compacting garbage collection. 202 // Force compacting garbage collection.
203 CHECK(FLAG_always_compact); 203 CHECK(FLAG_always_compact);
204 heap->CollectAllGarbage(); 204 heap->CollectAllGarbage();
205 } 205 }
206 206
207 207
208 // Test that weak set keys on an evacuation candidate which are reachable by 208 // Test that weak set keys on an evacuation candidate which are reachable by
(...skipping 22 matching lines...) Expand all
231 Handle<JSObject> keys[32]; 231 Handle<JSObject> keys[32];
232 for (int i = 0; i < 32; i++) { 232 for (int i = 0; i < 32; i++) {
233 keys[i] = factory->NewJSObject(function, TENURED); 233 keys[i] = factory->NewJSObject(function, TENURED);
234 CHECK(!heap->InNewSpace(keys[i]->address())); 234 CHECK(!heap->InNewSpace(keys[i]->address()));
235 CHECK(!first_page->Contains(keys[i]->address())); 235 CHECK(!first_page->Contains(keys[i]->address()));
236 } 236 }
237 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); 237 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
238 for (int i = 0; i < 32; i++) { 238 for (int i = 0; i < 32; i++) {
239 Handle<Smi> smi(Smi::FromInt(i), isolate); 239 Handle<Smi> smi(Smi::FromInt(i), isolate);
240 int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value(); 240 int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value();
241 Runtime::WeakCollectionSet(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