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

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

Issue 1632913003: [heap] Move to page lookups for SemiSpace, NewSpace, and Heap containment methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips ports Created 4 years, 10 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/heap/test-heap.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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // Start second old-space page so that values land on evacuation candidate. 187 // Start second old-space page so that values land on evacuation candidate.
188 Page* first_page = heap->old_space()->anchor()->next_page(); 188 Page* first_page = heap->old_space()->anchor()->next_page();
189 SimulateFullSpace(heap->old_space()); 189 SimulateFullSpace(heap->old_space());
190 190
191 // Fill up weak map with values on an evacuation candidate. 191 // Fill up weak map with values on an evacuation candidate.
192 { 192 {
193 HandleScope scope(isolate); 193 HandleScope scope(isolate);
194 for (int i = 0; i < 32; i++) { 194 for (int i = 0; i < 32; i++) {
195 Handle<JSObject> object = factory->NewJSObject(function, TENURED); 195 Handle<JSObject> object = factory->NewJSObject(function, TENURED);
196 CHECK(!heap->InNewSpace(object->address())); 196 CHECK(!heap->InNewSpace(*object));
197 CHECK(!first_page->Contains(object->address())); 197 CHECK(!first_page->Contains(object->address()));
198 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); 198 int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
199 JSWeakCollection::Set(weakmap, key, object, hash); 199 JSWeakCollection::Set(weakmap, key, object, hash);
200 } 200 }
201 } 201 }
202 202
203 // Force compacting garbage collection. 203 // Force compacting garbage collection.
204 CHECK(FLAG_always_compact); 204 CHECK(FLAG_always_compact);
205 heap->CollectAllGarbage(); 205 heap->CollectAllGarbage();
206 } 206 }
(...skipping 17 matching lines...) Expand all
224 factory->function_string()); 224 factory->function_string());
225 225
226 // Start second old-space page so that keys land on evacuation candidate. 226 // Start second old-space page so that keys land on evacuation candidate.
227 Page* first_page = heap->old_space()->anchor()->next_page(); 227 Page* first_page = heap->old_space()->anchor()->next_page();
228 SimulateFullSpace(heap->old_space()); 228 SimulateFullSpace(heap->old_space());
229 229
230 // Fill up weak map with keys on an evacuation candidate. 230 // Fill up weak map with keys on an evacuation candidate.
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]));
235 CHECK(!first_page->Contains(keys[i]->address())); 235 CHECK(!first_page->Contains(keys[i]->address()));
236 } 236 }
237 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); 237 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(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 JSWeakCollection::Set(weakmap, keys[i], smi, hash); 241 JSWeakCollection::Set(weakmap, 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
(...skipping 13 matching lines...) Expand all
258 { 258 {
259 HandleScope scope(isolate); 259 HandleScope scope(isolate);
260 AllocateJSWeakMap(isolate); 260 AllocateJSWeakMap(isolate);
261 SimulateIncrementalMarking(heap); 261 SimulateIncrementalMarking(heap);
262 } 262 }
263 // The weak map is marked black here but leaving the handle scope will make 263 // The weak map is marked black here but leaving the handle scope will make
264 // the object unreachable. Aborting incremental marking will clear all the 264 // the object unreachable. Aborting incremental marking will clear all the
265 // marking bits which makes the weak map garbage. 265 // marking bits which makes the weak map garbage.
266 heap->CollectAllGarbage(); 266 heap->CollectAllGarbage();
267 } 267 }
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-weaksets.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698