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

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

Issue 1393833002: [heap] Reland 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-spaces.cc ('k') | test/cctest/test-weaksets.cc » ('j') | 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 Factory* factory = isolate->factory(); 181 Factory* factory = isolate->factory();
182 Heap* heap = isolate->heap(); 182 Heap* heap = isolate->heap();
183 HandleScope scope(isolate); 183 HandleScope scope(isolate);
184 Handle<JSFunction> function = factory->NewFunction( 184 Handle<JSFunction> function = factory->NewFunction(
185 factory->function_string()); 185 factory->function_string());
186 Handle<JSObject> key = factory->NewJSObject(function); 186 Handle<JSObject> key = factory->NewJSObject(function);
187 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); 187 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
188 188
189 // Start second old-space page so that values land on evacuation candidate. 189 // Start second old-space page so that values land on evacuation candidate.
190 Page* first_page = heap->old_space()->anchor()->next_page(); 190 Page* first_page = heap->old_space()->anchor()->next_page();
191 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; 191 SimulateFullSpace(heap->old_space());
192 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);
193 192
194 // Fill up weak map with values on an evacuation candidate. 193 // Fill up weak map with values on an evacuation candidate.
195 { 194 {
196 HandleScope scope(isolate); 195 HandleScope scope(isolate);
197 for (int i = 0; i < 32; i++) { 196 for (int i = 0; i < 32; i++) {
198 Handle<JSObject> object = factory->NewJSObject(function, TENURED); 197 Handle<JSObject> object = factory->NewJSObject(function, TENURED);
199 CHECK(!heap->InNewSpace(object->address())); 198 CHECK(!heap->InNewSpace(object->address()));
200 CHECK(!first_page->Contains(object->address())); 199 CHECK(!first_page->Contains(object->address()));
201 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 200 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
202 JSWeakCollection::Set(weakmap, key, object, hash); 201 JSWeakCollection::Set(weakmap, key, object, hash);
(...skipping 18 matching lines...) Expand all
221 LocalContext context; 220 LocalContext context;
222 Isolate* isolate = GetIsolateFrom(&context); 221 Isolate* isolate = GetIsolateFrom(&context);
223 Factory* factory = isolate->factory(); 222 Factory* factory = isolate->factory();
224 Heap* heap = isolate->heap(); 223 Heap* heap = isolate->heap();
225 HandleScope scope(isolate); 224 HandleScope scope(isolate);
226 Handle<JSFunction> function = factory->NewFunction( 225 Handle<JSFunction> function = factory->NewFunction(
227 factory->function_string()); 226 factory->function_string());
228 227
229 // Start second old-space page so that keys land on evacuation candidate. 228 // Start second old-space page so that keys land on evacuation candidate.
230 Page* first_page = heap->old_space()->anchor()->next_page(); 229 Page* first_page = heap->old_space()->anchor()->next_page();
231 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; 230 SimulateFullSpace(heap->old_space());
232 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);
233 231
234 // Fill up weak map with keys on an evacuation candidate. 232 // Fill up weak map with keys on an evacuation candidate.
235 Handle<JSObject> keys[32]; 233 Handle<JSObject> keys[32];
236 for (int i = 0; i < 32; i++) { 234 for (int i = 0; i < 32; i++) {
237 keys[i] = factory->NewJSObject(function, TENURED); 235 keys[i] = factory->NewJSObject(function, TENURED);
238 CHECK(!heap->InNewSpace(keys[i]->address())); 236 CHECK(!heap->InNewSpace(keys[i]->address()));
239 CHECK(!first_page->Contains(keys[i]->address())); 237 CHECK(!first_page->Contains(keys[i]->address()));
240 } 238 }
241 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); 239 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
242 for (int i = 0; i < 32; i++) { 240 for (int i = 0; i < 32; i++) {
(...skipping 19 matching lines...) Expand all
262 { 260 {
263 HandleScope scope(isolate); 261 HandleScope scope(isolate);
264 AllocateJSWeakMap(isolate); 262 AllocateJSWeakMap(isolate);
265 SimulateIncrementalMarking(heap); 263 SimulateIncrementalMarking(heap);
266 } 264 }
267 // The weak map is marked black here but leaving the handle scope will make 265 // The weak map is marked black here but leaving the handle scope will make
268 // the object unreachable. Aborting incremental marking will clear all the 266 // the object unreachable. Aborting incremental marking will clear all the
269 // marking bits which makes the weak map garbage. 267 // marking bits which makes the weak map garbage.
270 heap->CollectAllGarbage(); 268 heap->CollectAllGarbage();
271 } 269 }
OLDNEW
« no previous file with comments | « test/cctest/test-spaces.cc ('k') | test/cctest/test-weaksets.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698