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

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

Issue 1361853005: [heap] Prepare code for smaller large object allocation limit than max allocatable memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 Factory* factory = isolate->factory(); 180 Factory* factory = isolate->factory();
181 Heap* heap = isolate->heap(); 181 Heap* heap = isolate->heap();
182 HandleScope scope(isolate); 182 HandleScope scope(isolate);
183 Handle<JSFunction> function = factory->NewFunction( 183 Handle<JSFunction> function = factory->NewFunction(
184 factory->function_string()); 184 factory->function_string());
185 Handle<JSObject> key = factory->NewJSObject(function); 185 Handle<JSObject> key = factory->NewJSObject(function);
186 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); 186 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
187 187
188 // Start second old-space page so that values land on evacuation candidate. 188 // Start second old-space page so that values land on evacuation candidate.
189 Page* first_page = heap->old_space()->anchor()->next_page(); 189 Page* first_page = heap->old_space()->anchor()->next_page();
190 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; 190 SimulateFullSpace(heap->old_space());
191 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);
192 191
193 // Fill up weak set with values on an evacuation candidate. 192 // Fill up weak set with values on an evacuation candidate.
194 { 193 {
195 HandleScope scope(isolate); 194 HandleScope scope(isolate);
196 for (int i = 0; i < 32; i++) { 195 for (int i = 0; i < 32; i++) {
197 Handle<JSObject> object = factory->NewJSObject(function, TENURED); 196 Handle<JSObject> object = factory->NewJSObject(function, TENURED);
198 CHECK(!heap->InNewSpace(object->address())); 197 CHECK(!heap->InNewSpace(object->address()));
199 CHECK(!first_page->Contains(object->address())); 198 CHECK(!first_page->Contains(object->address()));
200 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 199 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
201 JSWeakCollection::Set(weakset, key, object, hash); 200 JSWeakCollection::Set(weakset, key, object, hash);
(...skipping 18 matching lines...) Expand all
220 LocalContext context; 219 LocalContext context;
221 Isolate* isolate = GetIsolateFrom(&context); 220 Isolate* isolate = GetIsolateFrom(&context);
222 Factory* factory = isolate->factory(); 221 Factory* factory = isolate->factory();
223 Heap* heap = isolate->heap(); 222 Heap* heap = isolate->heap();
224 HandleScope scope(isolate); 223 HandleScope scope(isolate);
225 Handle<JSFunction> function = factory->NewFunction( 224 Handle<JSFunction> function = factory->NewFunction(
226 factory->function_string()); 225 factory->function_string());
227 226
228 // Start second old-space page so that keys land on evacuation candidate. 227 // Start second old-space page so that keys land on evacuation candidate.
229 Page* first_page = heap->old_space()->anchor()->next_page(); 228 Page* first_page = heap->old_space()->anchor()->next_page();
230 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; 229 SimulateFullSpace(heap->old_space());
231 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);
232 230
233 // Fill up weak set with keys on an evacuation candidate. 231 // Fill up weak set with keys on an evacuation candidate.
234 Handle<JSObject> keys[32]; 232 Handle<JSObject> keys[32];
235 for (int i = 0; i < 32; i++) { 233 for (int i = 0; i < 32; i++) {
236 keys[i] = factory->NewJSObject(function, TENURED); 234 keys[i] = factory->NewJSObject(function, TENURED);
237 CHECK(!heap->InNewSpace(keys[i]->address())); 235 CHECK(!heap->InNewSpace(keys[i]->address()));
238 CHECK(!first_page->Contains(keys[i]->address())); 236 CHECK(!first_page->Contains(keys[i]->address()));
239 } 237 }
240 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); 238 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
241 for (int i = 0; i < 32; i++) { 239 for (int i = 0; i < 32; i++) {
242 Handle<Smi> smi(Smi::FromInt(i), isolate); 240 Handle<Smi> smi(Smi::FromInt(i), isolate);
243 int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value(); 241 int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value();
244 JSWeakCollection::Set(weakset, keys[i], smi, hash); 242 JSWeakCollection::Set(weakset, keys[i], smi, hash);
245 } 243 }
246 244
247 // Force compacting garbage collection. The subsequent collections are used 245 // Force compacting garbage collection. The subsequent collections are used
248 // to verify that key references were actually updated. 246 // to verify that key references were actually updated.
249 CHECK(FLAG_always_compact); 247 CHECK(FLAG_always_compact);
250 heap->CollectAllGarbage(); 248 heap->CollectAllGarbage();
251 heap->CollectAllGarbage(); 249 heap->CollectAllGarbage();
252 heap->CollectAllGarbage(); 250 heap->CollectAllGarbage();
253 } 251 }
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