| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Tell the tracer. | 71 // Tell the tracer. |
| 72 if (IsCompacting()) tracer_->set_is_compacting(); | 72 if (IsCompacting()) tracer_->set_is_compacting(); |
| 73 | 73 |
| 74 MarkLiveObjects(); | 74 MarkLiveObjects(); |
| 75 | 75 |
| 76 if (FLAG_collect_maps) ClearNonLiveTransitions(); | 76 if (FLAG_collect_maps) ClearNonLiveTransitions(); |
| 77 | 77 |
| 78 SweepLargeObjectSpace(); | 78 SweepLargeObjectSpace(); |
| 79 | 79 |
| 80 if (IsCompacting()) { | 80 if (IsCompacting()) { |
| 81 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_COMPACT); |
| 81 EncodeForwardingAddresses(); | 82 EncodeForwardingAddresses(); |
| 82 | 83 |
| 83 UpdatePointers(); | 84 UpdatePointers(); |
| 84 | 85 |
| 85 RelocateObjects(); | 86 RelocateObjects(); |
| 86 | 87 |
| 87 RebuildRSets(); | 88 RebuildRSets(); |
| 88 | 89 |
| 89 } else { | 90 } else { |
| 90 SweepSpaces(); | 91 SweepSpaces(); |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 ASSERT(marking_stack.is_empty()); | 672 ASSERT(marking_stack.is_empty()); |
| 672 while (work_to_do) { | 673 while (work_to_do) { |
| 673 MarkObjectGroups(); | 674 MarkObjectGroups(); |
| 674 work_to_do = !marking_stack.is_empty(); | 675 work_to_do = !marking_stack.is_empty(); |
| 675 ProcessMarkingStack(visitor); | 676 ProcessMarkingStack(visitor); |
| 676 } | 677 } |
| 677 } | 678 } |
| 678 | 679 |
| 679 | 680 |
| 680 void MarkCompactCollector::MarkLiveObjects() { | 681 void MarkCompactCollector::MarkLiveObjects() { |
| 682 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_MARK); |
| 681 #ifdef DEBUG | 683 #ifdef DEBUG |
| 682 ASSERT(state_ == PREPARE_GC); | 684 ASSERT(state_ == PREPARE_GC); |
| 683 state_ = MARK_LIVE_OBJECTS; | 685 state_ = MARK_LIVE_OBJECTS; |
| 684 #endif | 686 #endif |
| 685 // The to space contains live objects, the from space is used as a marking | 687 // The to space contains live objects, the from space is used as a marking |
| 686 // stack. | 688 // stack. |
| 687 marking_stack.Initialize(Heap::new_space()->FromSpaceLow(), | 689 marking_stack.Initialize(Heap::new_space()->FromSpaceLow(), |
| 688 Heap::new_space()->FromSpaceHigh()); | 690 Heap::new_space()->FromSpaceHigh()); |
| 689 | 691 |
| 690 ASSERT(!marking_stack.overflowed()); | 692 ASSERT(!marking_stack.overflowed()); |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 | 1158 |
| 1157 static bool TryPromoteObject(HeapObject* object, int object_size) { | 1159 static bool TryPromoteObject(HeapObject* object, int object_size) { |
| 1158 Object* result; | 1160 Object* result; |
| 1159 | 1161 |
| 1160 if (object_size > Heap::MaxObjectSizeInPagedSpace()) { | 1162 if (object_size > Heap::MaxObjectSizeInPagedSpace()) { |
| 1161 result = Heap::lo_space()->AllocateRawFixedArray(object_size); | 1163 result = Heap::lo_space()->AllocateRawFixedArray(object_size); |
| 1162 if (!result->IsFailure()) { | 1164 if (!result->IsFailure()) { |
| 1163 HeapObject* target = HeapObject::cast(result); | 1165 HeapObject* target = HeapObject::cast(result); |
| 1164 MigrateObject(target->address(), object->address(), object_size); | 1166 MigrateObject(target->address(), object->address(), object_size); |
| 1165 Heap::UpdateRSet(target); | 1167 Heap::UpdateRSet(target); |
| 1168 MarkCompactCollector::tracer()-> |
| 1169 increment_promoted_objects_size(object_size); |
| 1166 return true; | 1170 return true; |
| 1167 } | 1171 } |
| 1168 } else { | 1172 } else { |
| 1169 OldSpace* target_space = Heap::TargetSpace(object); | 1173 OldSpace* target_space = Heap::TargetSpace(object); |
| 1170 | 1174 |
| 1171 ASSERT(target_space == Heap::old_pointer_space() || | 1175 ASSERT(target_space == Heap::old_pointer_space() || |
| 1172 target_space == Heap::old_data_space()); | 1176 target_space == Heap::old_data_space()); |
| 1173 result = target_space->AllocateRaw(object_size); | 1177 result = target_space->AllocateRaw(object_size); |
| 1174 if (!result->IsFailure()) { | 1178 if (!result->IsFailure()) { |
| 1175 HeapObject* target = HeapObject::cast(result); | 1179 HeapObject* target = HeapObject::cast(result); |
| 1176 MigrateObject(target->address(), object->address(), object_size); | 1180 MigrateObject(target->address(), object->address(), object_size); |
| 1177 if (target_space == Heap::old_pointer_space()) { | 1181 if (target_space == Heap::old_pointer_space()) { |
| 1178 Heap::UpdateRSet(target); | 1182 Heap::UpdateRSet(target); |
| 1179 } | 1183 } |
| 1184 MarkCompactCollector::tracer()-> |
| 1185 increment_promoted_objects_size(object_size); |
| 1180 return true; | 1186 return true; |
| 1181 } | 1187 } |
| 1182 } | 1188 } |
| 1183 | 1189 |
| 1184 return false; | 1190 return false; |
| 1185 } | 1191 } |
| 1186 | 1192 |
| 1187 | 1193 |
| 1188 static void SweepNewSpace(NewSpace* space) { | 1194 static void SweepNewSpace(NewSpace* space) { |
| 1189 Heap::CheckNewSpaceExpansionCriteria(); | 1195 Heap::CheckNewSpaceExpansionCriteria(); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 obj != NULL; obj = map_to_evacuate_it_.next()) | 1734 obj != NULL; obj = map_to_evacuate_it_.next()) |
| 1729 ASSERT(FreeListNode::IsFreeListNode(obj)); | 1735 ASSERT(FreeListNode::IsFreeListNode(obj)); |
| 1730 } | 1736 } |
| 1731 #endif | 1737 #endif |
| 1732 }; | 1738 }; |
| 1733 | 1739 |
| 1734 MapCompact::MapUpdatingVisitor MapCompact::map_updating_visitor_; | 1740 MapCompact::MapUpdatingVisitor MapCompact::map_updating_visitor_; |
| 1735 | 1741 |
| 1736 | 1742 |
| 1737 void MarkCompactCollector::SweepSpaces() { | 1743 void MarkCompactCollector::SweepSpaces() { |
| 1744 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); |
| 1745 |
| 1738 ASSERT(state_ == SWEEP_SPACES); | 1746 ASSERT(state_ == SWEEP_SPACES); |
| 1739 ASSERT(!IsCompacting()); | 1747 ASSERT(!IsCompacting()); |
| 1740 // Noncompacting collections simply sweep the spaces to clear the mark | 1748 // Noncompacting collections simply sweep the spaces to clear the mark |
| 1741 // bits and free the nonlive blocks (for old and map spaces). We sweep | 1749 // bits and free the nonlive blocks (for old and map spaces). We sweep |
| 1742 // the map space last because freeing non-live maps overwrites them and | 1750 // the map space last because freeing non-live maps overwrites them and |
| 1743 // the other spaces rely on possibly non-live maps to get the sizes for | 1751 // the other spaces rely on possibly non-live maps to get the sizes for |
| 1744 // non-live objects. | 1752 // non-live objects. |
| 1745 SweepSpace(Heap::old_pointer_space(), &DeallocateOldPointerBlock); | 1753 SweepSpace(Heap::old_pointer_space(), &DeallocateOldPointerBlock); |
| 1746 SweepSpace(Heap::old_data_space(), &DeallocateOldDataBlock); | 1754 SweepSpace(Heap::old_data_space(), &DeallocateOldDataBlock); |
| 1747 SweepSpace(Heap::code_space(), &DeallocateCodeBlock); | 1755 SweepSpace(Heap::code_space(), &DeallocateCodeBlock); |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2310 #ifdef ENABLE_LOGGING_AND_PROFILING | 2318 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 2311 if (obj->IsCode()) { | 2319 if (obj->IsCode()) { |
| 2312 PROFILE(CodeDeleteEvent(obj->address())); | 2320 PROFILE(CodeDeleteEvent(obj->address())); |
| 2313 } else if (obj->IsJSFunction()) { | 2321 } else if (obj->IsJSFunction()) { |
| 2314 PROFILE(FunctionDeleteEvent(obj->address())); | 2322 PROFILE(FunctionDeleteEvent(obj->address())); |
| 2315 } | 2323 } |
| 2316 #endif | 2324 #endif |
| 2317 } | 2325 } |
| 2318 | 2326 |
| 2319 } } // namespace v8::internal | 2327 } } // namespace v8::internal |
| OLD | NEW |