| OLD | NEW |
| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 CHECK(Top::context()->global()-> | 221 CHECK(Top::context()->global()-> |
| 222 GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); | 222 GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); |
| 223 obj = JSObject::cast( | 223 obj = JSObject::cast( |
| 224 Top::context()->global()->GetProperty(obj_name)->ToObjectChecked()); | 224 Top::context()->global()->GetProperty(obj_name)->ToObjectChecked()); |
| 225 prop_name = | 225 prop_name = |
| 226 String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); | 226 String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); |
| 227 CHECK(obj->GetProperty(prop_name)->ToObjectChecked() == Smi::FromInt(23)); | 227 CHECK(obj->GetProperty(prop_name)->ToObjectChecked() == Smi::FromInt(23)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 | 230 |
| 231 // TODO(gc): compaction of map space is temporary removed from GC. |
| 232 #if 0 |
| 231 static Handle<Map> CreateMap() { | 233 static Handle<Map> CreateMap() { |
| 232 return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 234 return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 233 } | 235 } |
| 234 | 236 |
| 235 | 237 |
| 236 TEST(MapCompact) { | 238 TEST(MapCompact) { |
| 237 FLAG_max_map_space_pages = 16; | 239 FLAG_max_map_space_pages = 16; |
| 238 InitializeVM(); | 240 InitializeVM(); |
| 239 | 241 |
| 240 { | 242 { |
| 241 v8::HandleScope sc; | 243 v8::HandleScope sc; |
| 242 // keep allocating maps while pointers are still encodable and thus | 244 // keep allocating maps while pointers are still encodable and thus |
| 243 // mark compact is permitted. | 245 // mark compact is permitted. |
| 244 Handle<JSObject> root = Factory::NewJSObjectFromMap(CreateMap()); | 246 Handle<JSObject> root = Factory::NewJSObjectFromMap(CreateMap()); |
| 245 do { | 247 do { |
| 246 Handle<Map> map = CreateMap(); | 248 Handle<Map> map = CreateMap(); |
| 247 map->set_prototype(*root); | 249 map->set_prototype(*root); |
| 248 root = Factory::NewJSObjectFromMap(map); | 250 root = Factory::NewJSObjectFromMap(map); |
| 249 } while (Heap::map_space()->MapPointersEncodable()); | 251 } while (Heap::map_space()->MapPointersEncodable()); |
| 250 } | 252 } |
| 251 // Now, as we don't have any handles to just allocated maps, we should | 253 // Now, as we don't have any handles to just allocated maps, we should |
| 252 // be able to trigger map compaction. | 254 // be able to trigger map compaction. |
| 253 // To give an additional chance to fail, try to force compaction which | 255 // To give an additional chance to fail, try to force compaction which |
| 254 // should be impossible right now. | 256 // should be impossible right now. |
| 255 Heap::CollectAllGarbage(true); | 257 Heap::CollectAllGarbage(true); |
| 256 // And now map pointers should be encodable again. | 258 // And now map pointers should be encodable again. |
| 257 CHECK(Heap::map_space()->MapPointersEncodable()); | 259 CHECK(Heap::map_space()->MapPointersEncodable()); |
| 258 } | 260 } |
| 259 | 261 #endif |
| 260 | 262 |
| 261 static int gc_starts = 0; | 263 static int gc_starts = 0; |
| 262 static int gc_ends = 0; | 264 static int gc_ends = 0; |
| 263 | 265 |
| 264 static void GCPrologueCallbackFunc() { | 266 static void GCPrologueCallbackFunc() { |
| 265 CHECK(gc_starts == gc_ends); | 267 CHECK(gc_starts == gc_ends); |
| 266 gc_starts++; | 268 gc_starts++; |
| 267 } | 269 } |
| 268 | 270 |
| 269 | 271 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 356 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 355 GlobalHandles::AddGroup(g1_objects, 2); | 357 GlobalHandles::AddGroup(g1_objects, 2); |
| 356 GlobalHandles::AddGroup(g2_objects, 2); | 358 GlobalHandles::AddGroup(g2_objects, 2); |
| 357 } | 359 } |
| 358 | 360 |
| 359 Heap::CollectGarbage(OLD_POINTER_SPACE); | 361 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 360 | 362 |
| 361 // All objects should be gone. 5 global handles in total. | 363 // All objects should be gone. 5 global handles in total. |
| 362 CHECK_EQ(5, NumberOfWeakCalls); | 364 CHECK_EQ(5, NumberOfWeakCalls); |
| 363 } | 365 } |
| OLD | NEW |