Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 // allow at least a few allocations after a collection. The reason | 466 // allow at least a few allocations after a collection. The reason |
| 467 // for this is that we have a lot of allocation sequences and we | 467 // for this is that we have a lot of allocation sequences and we |
| 468 // assume that a garbage collection will allow the subsequent | 468 // assume that a garbage collection will allow the subsequent |
| 469 // allocation attempts to go through. | 469 // allocation attempts to go through. |
| 470 allocation_timeout_ = Max(6, FLAG_gc_interval); | 470 allocation_timeout_ = Max(6, FLAG_gc_interval); |
| 471 #endif | 471 #endif |
| 472 | 472 |
| 473 if (collector == SCAVENGER && | 473 if (collector == SCAVENGER && |
| 474 IncrementalMarking::state() != IncrementalMarking::STOPPED) { | 474 IncrementalMarking::state() != IncrementalMarking::STOPPED) { |
| 475 if (FLAG_trace_incremental_marking) { | 475 if (FLAG_trace_incremental_marking) { |
| 476 PrintF("[IncrementalMarking] SCAVENGE -> MARK-SWEEP\n"); | 476 PrintF("[IncrementalMarking] SURVIVING SCAVENGE\n"); |
|
Erik Corry
2011/03/23 12:04:32
This is a message that makes sense in terms of the
| |
| 477 } | 477 } |
| 478 collector = MARK_COMPACTOR; | |
| 479 } | 478 } |
| 480 | 479 |
| 481 bool next_gc_likely_to_collect_more = false; | 480 bool next_gc_likely_to_collect_more = false; |
| 482 | 481 |
| 483 { GCTracer tracer; | 482 { GCTracer tracer; |
| 484 GarbageCollectionPrologue(); | 483 GarbageCollectionPrologue(); |
| 485 // The GC count was incremented in the prologue. Tell the tracer about | 484 // The GC count was incremented in the prologue. Tell the tracer about |
| 486 // it. | 485 // it. |
| 487 tracer.set_gc_count(gc_count_); | 486 tracer.set_gc_count(gc_count_); |
| 488 | 487 |
| 489 // Tell the tracer which collector we've selected. | 488 // Tell the tracer which collector we've selected. |
| 490 tracer.set_collector(collector); | 489 tracer.set_collector(collector); |
| 491 | 490 |
| 492 HistogramTimer* rate = (collector == SCAVENGER) | 491 HistogramTimer* rate = (collector == SCAVENGER) |
| 493 ? &Counters::gc_scavenger | 492 ? &Counters::gc_scavenger |
| 494 : &Counters::gc_compactor; | 493 : &Counters::gc_compactor; |
| 495 rate->Start(); | 494 rate->Start(); |
| 496 next_gc_likely_to_collect_more = | 495 next_gc_likely_to_collect_more = |
| 497 PerformGarbageCollection(collector, &tracer); | 496 PerformGarbageCollection(collector, &tracer); |
| 498 rate->Stop(); | 497 rate->Stop(); |
| 499 | 498 |
| 500 GarbageCollectionEpilogue(); | 499 GarbageCollectionEpilogue(); |
| 501 } | 500 } |
| 502 | 501 |
| 503 ASSERT(IncrementalMarking::state() == IncrementalMarking::STOPPED); | 502 |
| 504 if (IncrementalMarking::WorthActivating() && NextGCIsLikelyToBeFull()) { | 503 ASSERT(collector == SCAVENGER || IncrementalMarking::IsStopped()); |
| 505 IncrementalMarking::Start(); | 504 if (IncrementalMarking::IsStopped()) { |
| 505 if (IncrementalMarking::WorthActivating() && NextGCIsLikelyToBeFull()) { | |
| 506 IncrementalMarking::Start(); | |
| 507 } | |
| 506 } | 508 } |
| 507 | 509 |
| 508 #ifdef ENABLE_LOGGING_AND_PROFILING | 510 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 509 if (FLAG_log_gc) HeapProfiler::WriteSample(); | 511 if (FLAG_log_gc) HeapProfiler::WriteSample(); |
| 510 #endif | 512 #endif |
| 511 | 513 |
| 512 return next_gc_likely_to_collect_more; | 514 return next_gc_likely_to_collect_more; |
| 513 } | 515 } |
| 514 | 516 |
| 515 | 517 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 LOG(ResourceEvent("scavenge", "begin")); | 952 LOG(ResourceEvent("scavenge", "begin")); |
| 951 | 953 |
| 952 // Clear descriptor cache. | 954 // Clear descriptor cache. |
| 953 DescriptorLookupCache::Clear(); | 955 DescriptorLookupCache::Clear(); |
| 954 | 956 |
| 955 // Used for updating survived_since_last_expansion_ at function end. | 957 // Used for updating survived_since_last_expansion_ at function end. |
| 956 intptr_t survived_watermark = PromotedSpaceSize(); | 958 intptr_t survived_watermark = PromotedSpaceSize(); |
| 957 | 959 |
| 958 CheckNewSpaceExpansionCriteria(); | 960 CheckNewSpaceExpansionCriteria(); |
| 959 | 961 |
| 962 SelectScavengingVisitorsTable(); | |
| 963 | |
| 964 IncrementalMarking::PrepareForScavenge(); | |
| 965 | |
| 960 // Flip the semispaces. After flipping, to space is empty, from space has | 966 // Flip the semispaces. After flipping, to space is empty, from space has |
| 961 // live objects. | 967 // live objects. |
| 962 new_space_.Flip(); | 968 new_space_.Flip(); |
| 963 new_space_.ResetAllocationInfo(); | 969 new_space_.ResetAllocationInfo(); |
| 964 | 970 |
| 965 // We need to sweep newly copied objects which can be either in the | 971 // We need to sweep newly copied objects which can be either in the |
| 966 // to space or promoted to the old generation. For to-space | 972 // to space or promoted to the old generation. For to-space |
| 967 // objects, we treat the bottom of the to space as a queue. Newly | 973 // objects, we treat the bottom of the to space as a queue. Newly |
| 968 // copied and unswept objects lie between a 'front' mark and the | 974 // copied and unswept objects lie between a 'front' mark and the |
| 969 // allocation pointer. | 975 // allocation pointer. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 // Scavenge object reachable from the global contexts list directly. | 1017 // Scavenge object reachable from the global contexts list directly. |
| 1012 scavenge_visitor.VisitPointer(BitCast<Object**>(&global_contexts_list_)); | 1018 scavenge_visitor.VisitPointer(BitCast<Object**>(&global_contexts_list_)); |
| 1013 | 1019 |
| 1014 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1020 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| 1015 | 1021 |
| 1016 UpdateNewSpaceReferencesInExternalStringTable( | 1022 UpdateNewSpaceReferencesInExternalStringTable( |
| 1017 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1023 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
| 1018 | 1024 |
| 1019 LiveObjectList::UpdateReferencesForScavengeGC(); | 1025 LiveObjectList::UpdateReferencesForScavengeGC(); |
| 1020 RuntimeProfiler::UpdateSamplesAfterScavenge(); | 1026 RuntimeProfiler::UpdateSamplesAfterScavenge(); |
| 1027 IncrementalMarking::UpdateMarkingStackAfterScavenge(); | |
| 1021 | 1028 |
| 1022 ASSERT(new_space_front == new_space_.top()); | 1029 ASSERT(new_space_front == new_space_.top()); |
| 1023 | 1030 |
| 1024 // Set age mark. | 1031 // Set age mark. |
| 1025 new_space_.set_age_mark(new_space_.top()); | 1032 new_space_.set_age_mark(new_space_.top()); |
| 1026 | 1033 |
| 1027 // Update how much has survived scavenge. | 1034 // Update how much has survived scavenge. |
| 1028 IncrementYoungSurvivorsCounter(static_cast<int>( | 1035 IncrementYoungSurvivorsCounter(static_cast<int>( |
| 1029 (PromotedSpaceSize() - survived_watermark) + new_space_.Size())); | 1036 (PromotedSpaceSize() - survived_watermark) + new_space_.Size())); |
| 1030 | 1037 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1206 } | 1213 } |
| 1207 | 1214 |
| 1208 // Take another spin if there are now unswept objects in new space | 1215 // Take another spin if there are now unswept objects in new space |
| 1209 // (there are currently no more unswept promoted objects). | 1216 // (there are currently no more unswept promoted objects). |
| 1210 } while (new_space_front < new_space_.top()); | 1217 } while (new_space_front < new_space_.top()); |
| 1211 | 1218 |
| 1212 return new_space_front; | 1219 return new_space_front; |
| 1213 } | 1220 } |
| 1214 | 1221 |
| 1215 | 1222 |
| 1223 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; | |
| 1224 | |
| 1225 typedef void (*ScavengingCallback)(Map* map, | |
| 1226 HeapObject** slot, | |
| 1227 HeapObject* object); | |
| 1228 | |
| 1229 static VisitorDispatchTable<ScavengingCallback> scavening_visitors_table_; | |
| 1230 | |
| 1231 static inline void DoScavengeObject(Map* map, | |
| 1232 HeapObject** slot, | |
| 1233 HeapObject* obj) { | |
| 1234 scavening_visitors_table_.GetVisitor(map)(map, slot, obj); | |
| 1235 } | |
| 1236 | |
| 1237 | |
| 1238 template<MarksHandling marks_handling> | |
| 1216 class ScavengingVisitor : public StaticVisitorBase { | 1239 class ScavengingVisitor : public StaticVisitorBase { |
| 1217 public: | 1240 public: |
| 1218 static void Initialize() { | 1241 static void Initialize() { |
| 1219 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString); | 1242 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString); |
| 1220 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); | 1243 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); |
| 1221 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); | 1244 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); |
| 1222 table_.Register(kVisitByteArray, &EvacuateByteArray); | 1245 table_.Register(kVisitByteArray, &EvacuateByteArray); |
| 1223 table_.Register(kVisitFixedArray, &EvacuateFixedArray); | 1246 table_.Register(kVisitFixedArray, &EvacuateFixedArray); |
| 1247 | |
| 1248 | |
| 1249 typedef ObjectEvacuationStrategy<POINTER_OBJECT> PtrObj; | |
|
Erik Corry
2011/03/23 12:04:32
Is this an object or a strategy? Perhaps it shoul
| |
| 1250 | |
| 1224 table_.Register(kVisitGlobalContext, | 1251 table_.Register(kVisitGlobalContext, |
| 1225 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1252 &PtrObj::template VisitSpecialized<Context::kSize>); |
| 1226 VisitSpecialized<Context::kSize>); | |
| 1227 | |
| 1228 typedef ObjectEvacuationStrategy<POINTER_OBJECT> PointerObject; | |
| 1229 | 1253 |
| 1230 table_.Register(kVisitConsString, | 1254 table_.Register(kVisitConsString, |
| 1231 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1255 &PtrObj::template VisitSpecialized<ConsString::kSize>); |
| 1232 VisitSpecialized<ConsString::kSize>); | |
| 1233 | 1256 |
| 1234 table_.Register(kVisitSharedFunctionInfo, | 1257 table_.Register(kVisitSharedFunctionInfo, |
| 1235 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1258 &PtrObj:: |
| 1236 VisitSpecialized<SharedFunctionInfo::kSize>); | 1259 template VisitSpecialized<SharedFunctionInfo::kSize>); |
| 1237 | 1260 |
| 1238 table_.Register(kVisitJSFunction, | 1261 table_.Register(kVisitJSFunction, |
| 1239 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1262 &PtrObj::template VisitSpecialized<JSFunction::kSize>); |
| 1240 VisitSpecialized<JSFunction::kSize>); | |
| 1241 | 1263 |
| 1242 table_.RegisterSpecializations<ObjectEvacuationStrategy<DATA_OBJECT>, | 1264 table_.RegisterSpecializations<ObjectEvacuationStrategy<DATA_OBJECT>, |
| 1243 kVisitDataObject, | 1265 kVisitDataObject, |
| 1244 kVisitDataObjectGeneric>(); | 1266 kVisitDataObjectGeneric>(); |
| 1245 | 1267 |
| 1246 table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, | 1268 table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, |
| 1247 kVisitJSObject, | 1269 kVisitJSObject, |
| 1248 kVisitJSObjectGeneric>(); | 1270 kVisitJSObjectGeneric>(); |
| 1249 | 1271 |
| 1250 table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, | 1272 table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, |
| 1251 kVisitStruct, | 1273 kVisitStruct, |
| 1252 kVisitStructGeneric>(); | 1274 kVisitStructGeneric>(); |
| 1253 } | 1275 } |
| 1254 | 1276 |
| 1255 | 1277 static VisitorDispatchTable<ScavengingCallback>* GetTable() { |
| 1256 static inline void Scavenge(Map* map, HeapObject** slot, HeapObject* obj) { | 1278 return &table_; |
| 1257 table_.GetVisitor(map)(map, slot, obj); | |
| 1258 } | 1279 } |
| 1259 | 1280 |
| 1260 | |
| 1261 private: | 1281 private: |
| 1262 enum ObjectContents { DATA_OBJECT, POINTER_OBJECT }; | 1282 enum ObjectContents { DATA_OBJECT, POINTER_OBJECT }; |
| 1263 enum SizeRestriction { SMALL, UNKNOWN_SIZE }; | 1283 enum SizeRestriction { SMALL, UNKNOWN_SIZE }; |
| 1264 | 1284 |
| 1265 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 1285 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
| 1266 static void RecordCopiedObject(HeapObject* obj) { | 1286 static void RecordCopiedObject(HeapObject* obj) { |
| 1267 bool should_record = false; | 1287 bool should_record = false; |
| 1268 #ifdef DEBUG | 1288 #ifdef DEBUG |
| 1269 should_record = FLAG_heap_stats; | 1289 should_record = FLAG_heap_stats; |
| 1270 #endif | 1290 #endif |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1299 #endif | 1319 #endif |
| 1300 HEAP_PROFILE(ObjectMoveEvent(source->address(), target->address())); | 1320 HEAP_PROFILE(ObjectMoveEvent(source->address(), target->address())); |
| 1301 #if defined(ENABLE_LOGGING_AND_PROFILING) | 1321 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 1302 if (Logger::is_logging() || CpuProfiler::is_profiling()) { | 1322 if (Logger::is_logging() || CpuProfiler::is_profiling()) { |
| 1303 if (target->IsSharedFunctionInfo()) { | 1323 if (target->IsSharedFunctionInfo()) { |
| 1304 PROFILE(SharedFunctionInfoMoveEvent( | 1324 PROFILE(SharedFunctionInfoMoveEvent( |
| 1305 source->address(), target->address())); | 1325 source->address(), target->address())); |
| 1306 } | 1326 } |
| 1307 } | 1327 } |
| 1308 #endif | 1328 #endif |
| 1329 | |
| 1330 if (marks_handling == TRANSFER_MARKS) TransferMark(source, target); | |
| 1331 | |
| 1309 return target; | 1332 return target; |
| 1310 } | 1333 } |
| 1311 | 1334 |
| 1312 | 1335 |
| 1336 INLINE(static void TransferMark(HeapObject* from, HeapObject* to)) { | |
| 1337 MarkBit from_mark_bit = Marking::MarkBitFrom(from); | |
| 1338 if (IncrementalMarking::IsBlack(from_mark_bit)) { | |
| 1339 IncrementalMarking::MarkBlack(Marking::MarkBitFrom(to)); | |
| 1340 } | |
| 1341 } | |
| 1342 | |
| 1313 template<ObjectContents object_contents, SizeRestriction size_restriction> | 1343 template<ObjectContents object_contents, SizeRestriction size_restriction> |
| 1314 static inline void EvacuateObject(Map* map, | 1344 static inline void EvacuateObject(Map* map, |
| 1315 HeapObject** slot, | 1345 HeapObject** slot, |
| 1316 HeapObject* object, | 1346 HeapObject* object, |
| 1317 int object_size) { | 1347 int object_size) { |
| 1318 ASSERT((size_restriction != SMALL) || | 1348 ASSERT((size_restriction != SMALL) || |
| 1319 (object_size <= Page::kMaxHeapObjectSize)); | 1349 (object_size <= Page::kMaxHeapObjectSize)); |
| 1320 ASSERT(object->Size() == object_size); | 1350 ASSERT(object->Size() == object_size); |
| 1321 | 1351 |
| 1322 if (Heap::ShouldBePromoted(object->address(), object_size)) { | 1352 if (Heap::ShouldBePromoted(object->address(), object_size)) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1396 | 1426 |
| 1397 static inline bool IsShortcutCandidate(int type) { | 1427 static inline bool IsShortcutCandidate(int type) { |
| 1398 return ((type & kShortcutTypeMask) == kShortcutTypeTag); | 1428 return ((type & kShortcutTypeMask) == kShortcutTypeTag); |
| 1399 } | 1429 } |
| 1400 | 1430 |
| 1401 static inline void EvacuateShortcutCandidate(Map* map, | 1431 static inline void EvacuateShortcutCandidate(Map* map, |
| 1402 HeapObject** slot, | 1432 HeapObject** slot, |
| 1403 HeapObject* object) { | 1433 HeapObject* object) { |
| 1404 ASSERT(IsShortcutCandidate(map->instance_type())); | 1434 ASSERT(IsShortcutCandidate(map->instance_type())); |
| 1405 | 1435 |
| 1406 if (ConsString::cast(object)->unchecked_second() == Heap::empty_string()) { | 1436 if (marks_handling == IGNORE_MARKS && |
| 1437 ConsString::cast(object)->unchecked_second() == Heap::empty_string()) { | |
| 1407 HeapObject* first = | 1438 HeapObject* first = |
| 1408 HeapObject::cast(ConsString::cast(object)->unchecked_first()); | 1439 HeapObject::cast(ConsString::cast(object)->unchecked_first()); |
| 1409 | 1440 |
| 1410 *slot = first; | 1441 *slot = first; |
| 1411 | 1442 |
| 1412 if (!Heap::InNewSpace(first)) { | 1443 if (!Heap::InNewSpace(first)) { |
| 1413 object->set_map_word(MapWord::FromForwardingAddress(first)); | 1444 object->set_map_word(MapWord::FromForwardingAddress(first)); |
| 1414 return; | 1445 return; |
| 1415 } | 1446 } |
| 1416 | 1447 |
| 1417 MapWord first_word = first->map_word(); | 1448 MapWord first_word = first->map_word(); |
| 1418 if (first_word.IsForwardingAddress()) { | 1449 if (first_word.IsForwardingAddress()) { |
| 1419 HeapObject* target = first_word.ToForwardingAddress(); | 1450 HeapObject* target = first_word.ToForwardingAddress(); |
| 1420 | 1451 |
| 1421 *slot = target; | 1452 *slot = target; |
| 1422 object->set_map_word(MapWord::FromForwardingAddress(target)); | 1453 object->set_map_word(MapWord::FromForwardingAddress(target)); |
| 1423 return; | 1454 return; |
| 1424 } | 1455 } |
| 1425 | 1456 |
| 1426 Scavenge(first->map(), slot, first); | 1457 DoScavengeObject(first->map(), slot, first); |
| 1427 object->set_map_word(MapWord::FromForwardingAddress(*slot)); | 1458 object->set_map_word(MapWord::FromForwardingAddress(*slot)); |
| 1428 return; | 1459 return; |
| 1429 } | 1460 } |
| 1430 | 1461 |
| 1431 int object_size = ConsString::kSize; | 1462 int object_size = ConsString::kSize; |
| 1432 EvacuateObject<POINTER_OBJECT, SMALL>(map, slot, object, object_size); | 1463 EvacuateObject<POINTER_OBJECT, SMALL>(map, slot, object, object_size); |
| 1433 } | 1464 } |
| 1434 | 1465 |
| 1435 template<ObjectContents object_contents> | 1466 template<ObjectContents object_contents> |
| 1436 class ObjectEvacuationStrategy { | 1467 class ObjectEvacuationStrategy { |
| 1437 public: | 1468 public: |
| 1438 template<int object_size> | 1469 template<int object_size> |
| 1439 static inline void VisitSpecialized(Map* map, | 1470 static inline void VisitSpecialized(Map* map, |
| 1440 HeapObject** slot, | 1471 HeapObject** slot, |
| 1441 HeapObject* object) { | 1472 HeapObject* object) { |
| 1442 EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); | 1473 EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); |
| 1443 } | 1474 } |
| 1444 | 1475 |
| 1445 static inline void Visit(Map* map, | 1476 static inline void Visit(Map* map, |
| 1446 HeapObject** slot, | 1477 HeapObject** slot, |
| 1447 HeapObject* object) { | 1478 HeapObject* object) { |
| 1448 int object_size = map->instance_size(); | 1479 int object_size = map->instance_size(); |
| 1449 EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); | 1480 EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); |
| 1450 } | 1481 } |
| 1451 }; | 1482 }; |
| 1452 | 1483 |
| 1453 typedef void (*Callback)(Map* map, HeapObject** slot, HeapObject* object); | 1484 static VisitorDispatchTable<ScavengingCallback> table_; |
| 1454 | |
| 1455 static VisitorDispatchTable<Callback> table_; | |
| 1456 }; | 1485 }; |
| 1457 | 1486 |
| 1458 | 1487 |
| 1459 VisitorDispatchTable<ScavengingVisitor::Callback> ScavengingVisitor::table_; | 1488 template<MarksHandling marks_handling> |
| 1489 VisitorDispatchTable<ScavengingCallback> | |
| 1490 ScavengingVisitor<marks_handling>::table_; | |
| 1491 | |
| 1492 | |
| 1493 void Heap::SelectScavengingVisitorsTable() { | |
| 1494 if (IncrementalMarking::IsStopped()) { | |
| 1495 scavening_visitors_table_.CopyFrom( | |
| 1496 ScavengingVisitor<IGNORE_MARKS>::GetTable()); | |
| 1497 } else { | |
| 1498 scavening_visitors_table_.CopyFrom( | |
| 1499 ScavengingVisitor<TRANSFER_MARKS>::GetTable()); | |
| 1500 } | |
| 1501 } | |
| 1460 | 1502 |
| 1461 | 1503 |
| 1462 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { | 1504 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { |
| 1463 ASSERT(InFromSpace(object)); | 1505 ASSERT(InFromSpace(object)); |
| 1464 MapWord first_word = object->map_word(); | 1506 MapWord first_word = object->map_word(); |
| 1465 ASSERT(!first_word.IsForwardingAddress()); | 1507 ASSERT(!first_word.IsForwardingAddress()); |
| 1466 Map* map = first_word.ToMap(); | 1508 Map* map = first_word.ToMap(); |
| 1467 ScavengingVisitor::Scavenge(map, p, object); | 1509 DoScavengeObject(map, p, object); |
| 1468 } | 1510 } |
| 1469 | 1511 |
| 1470 | 1512 |
| 1471 void Heap::ScavengePointer(HeapObject** p) { | 1513 void Heap::ScavengePointer(HeapObject** p) { |
| 1472 ScavengeObject(p, *p); | 1514 ScavengeObject(p, *p); |
| 1473 } | 1515 } |
| 1474 | 1516 |
| 1475 | 1517 |
| 1476 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, | 1518 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, |
| 1477 int instance_size) { | 1519 int instance_size) { |
| (...skipping 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4596 // call Heap::TearDown() to release allocated memory. | 4638 // call Heap::TearDown() to release allocated memory. |
| 4597 // | 4639 // |
| 4598 // If the heap is not yet configured (eg, through the API), configure it. | 4640 // If the heap is not yet configured (eg, through the API), configure it. |
| 4599 // Configuration is based on the flags new-space-size (really the semispace | 4641 // Configuration is based on the flags new-space-size (really the semispace |
| 4600 // size) and old-space-size if set or the initial values of semispace_size_ | 4642 // size) and old-space-size if set or the initial values of semispace_size_ |
| 4601 // and old_generation_size_ otherwise. | 4643 // and old_generation_size_ otherwise. |
| 4602 if (!heap_configured) { | 4644 if (!heap_configured) { |
| 4603 if (!ConfigureHeapDefault()) return false; | 4645 if (!ConfigureHeapDefault()) return false; |
| 4604 } | 4646 } |
| 4605 | 4647 |
| 4606 ScavengingVisitor::Initialize(); | 4648 ScavengingVisitor<TRANSFER_MARKS>::Initialize(); |
| 4649 ScavengingVisitor<IGNORE_MARKS>::Initialize(); | |
| 4607 NewSpaceScavenger::Initialize(); | 4650 NewSpaceScavenger::Initialize(); |
| 4608 MarkCompactCollector::Initialize(); | 4651 MarkCompactCollector::Initialize(); |
| 4609 | 4652 |
| 4610 MarkMapPointersAsEncoded(false); | 4653 MarkMapPointersAsEncoded(false); |
| 4611 | 4654 |
| 4612 // Setup memory allocator. | 4655 // Setup memory allocator. |
| 4613 if (!MemoryAllocator::Setup(MaxReserved(), MaxExecutableSize())) return false; | 4656 if (!MemoryAllocator::Setup(MaxReserved(), MaxExecutableSize())) return false; |
| 4614 | 4657 |
| 4615 // Setup new space. | 4658 // Setup new space. |
| 4616 if (!new_space_.Setup(reserved_semispace_size_)) { | 4659 if (!new_space_.Setup(reserved_semispace_size_)) { |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5537 void ExternalStringTable::TearDown() { | 5580 void ExternalStringTable::TearDown() { |
| 5538 new_space_strings_.Free(); | 5581 new_space_strings_.Free(); |
| 5539 old_space_strings_.Free(); | 5582 old_space_strings_.Free(); |
| 5540 } | 5583 } |
| 5541 | 5584 |
| 5542 | 5585 |
| 5543 List<Object*> ExternalStringTable::new_space_strings_; | 5586 List<Object*> ExternalStringTable::new_space_strings_; |
| 5544 List<Object*> ExternalStringTable::old_space_strings_; | 5587 List<Object*> ExternalStringTable::old_space_strings_; |
| 5545 | 5588 |
| 5546 } } // namespace v8::internal | 5589 } } // namespace v8::internal |
| OLD | NEW |