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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 548136: Merge r3643 and r3659 from bleeding_edge to trunk to... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 obj_name = String::cast(Heap::LookupAsciiSymbol("theObject")); 201 obj_name = String::cast(Heap::LookupAsciiSymbol("theObject"));
202 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); 202 CHECK(Top::context()->global()->HasLocalProperty(obj_name));
203 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); 203 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject());
204 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); 204 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name));
205 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")); 205 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot"));
206 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); 206 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23));
207 } 207 }
208 208
209 209
210 static Handle<Map> CreateMap() {
211 return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
212 }
213
214
215 TEST(MapCompact) {
216 FLAG_max_map_space_pages = 16;
217 InitializeVM();
218
219 {
220 v8::HandleScope sc;
221 // keep allocating maps while pointers are still encodable and thus
222 // mark compact is permitted.
223 Handle<JSObject> root = Factory::NewJSObjectFromMap(CreateMap());
224 do {
225 Handle<Map> map = CreateMap();
226 map->set_prototype(*root);
227 root = Factory::NewJSObjectFromMap(map);
228 } while (Heap::map_space()->MapPointersEncodable());
229 }
230 // Now, as we don't have any handles to just allocated maps, we should
231 // be able to trigger map compaction.
232 // To give an additional chance to fail, try to force compaction which
233 // should be impossible right now.
234 Heap::CollectAllGarbage(true);
235 // And now map pointers should be encodable again.
236 CHECK(Heap::map_space()->MapPointersEncodable());
237 }
238
239
210 static int gc_starts = 0; 240 static int gc_starts = 0;
211 static int gc_ends = 0; 241 static int gc_ends = 0;
212 242
213 static void GCPrologueCallbackFunc() { 243 static void GCPrologueCallbackFunc() {
214 CHECK(gc_starts == gc_ends); 244 CHECK(gc_starts == gc_ends);
215 gc_starts++; 245 gc_starts++;
216 } 246 }
217 247
218 248
219 static void GCEpilogueCallbackFunc() { 249 static void GCEpilogueCallbackFunc() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 332 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
303 GlobalHandles::AddGroup(g1_objects, 2); 333 GlobalHandles::AddGroup(g1_objects, 2);
304 GlobalHandles::AddGroup(g2_objects, 2); 334 GlobalHandles::AddGroup(g2_objects, 2);
305 } 335 }
306 336
307 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 337 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
308 338
309 // All objects should be gone. 5 global handles in total. 339 // All objects should be gone. 5 global handles in total.
310 CHECK_EQ(5, NumberOfWeakCalls); 340 CHECK_EQ(5, NumberOfWeakCalls);
311 } 341 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698