| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION) | 1706 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION) |
| 1707 #undef VISITOR_ID_COUNT_FUNCTION | 1707 #undef VISITOR_ID_COUNT_FUNCTION |
| 1708 } | 1708 } |
| 1709 } | 1709 } |
| 1710 | 1710 |
| 1711 | 1711 |
| 1712 VisitorDispatchTable<MarkCompactMarkingVisitor::Callback> | 1712 VisitorDispatchTable<MarkCompactMarkingVisitor::Callback> |
| 1713 MarkCompactMarkingVisitor::non_count_table_; | 1713 MarkCompactMarkingVisitor::non_count_table_; |
| 1714 | 1714 |
| 1715 | 1715 |
| 1716 class MarkingVisitor : public ObjectVisitor { | |
| 1717 public: | |
| 1718 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } | |
| 1719 | |
| 1720 void VisitPointer(Object** p) { | |
| 1721 MarkCompactMarkingVisitor::VisitPointer(heap_, p); | |
| 1722 } | |
| 1723 | |
| 1724 void VisitPointers(Object** start, Object** end) { | |
| 1725 MarkCompactMarkingVisitor::VisitPointers(heap_, start, end); | |
| 1726 } | |
| 1727 | |
| 1728 private: | |
| 1729 Heap* heap_; | |
| 1730 }; | |
| 1731 | |
| 1732 | |
| 1733 class CodeMarkingVisitor : public ThreadVisitor { | 1716 class CodeMarkingVisitor : public ThreadVisitor { |
| 1734 public: | 1717 public: |
| 1735 explicit CodeMarkingVisitor(MarkCompactCollector* collector) | 1718 explicit CodeMarkingVisitor(MarkCompactCollector* collector) |
| 1736 : collector_(collector) {} | 1719 : collector_(collector) {} |
| 1737 | 1720 |
| 1738 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { | 1721 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { |
| 1739 collector_->PrepareThreadForCodeFlushing(isolate, top); | 1722 collector_->PrepareThreadForCodeFlushing(isolate, top); |
| 1740 } | 1723 } |
| 1741 | 1724 |
| 1742 private: | 1725 private: |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 bool MarkCompactCollector::IsUnmarkedHeapObjectWithHeap(Heap* heap, | 2014 bool MarkCompactCollector::IsUnmarkedHeapObjectWithHeap(Heap* heap, |
| 2032 Object** p) { | 2015 Object** p) { |
| 2033 Object* o = *p; | 2016 Object* o = *p; |
| 2034 ASSERT(o->IsHeapObject()); | 2017 ASSERT(o->IsHeapObject()); |
| 2035 HeapObject* heap_object = HeapObject::cast(o); | 2018 HeapObject* heap_object = HeapObject::cast(o); |
| 2036 MarkBit mark = Marking::MarkBitFrom(heap_object); | 2019 MarkBit mark = Marking::MarkBitFrom(heap_object); |
| 2037 return !mark.Get(); | 2020 return !mark.Get(); |
| 2038 } | 2021 } |
| 2039 | 2022 |
| 2040 | 2023 |
| 2041 void MarkCompactCollector::MarkStringTable() { | 2024 void MarkCompactCollector::MarkStringTable(RootMarkingVisitor* visitor) { |
| 2042 StringTable* string_table = heap()->string_table(); | 2025 StringTable* string_table = heap()->string_table(); |
| 2043 // Mark the string table itself. | 2026 // Mark the string table itself. |
| 2044 MarkBit string_table_mark = Marking::MarkBitFrom(string_table); | 2027 MarkBit string_table_mark = Marking::MarkBitFrom(string_table); |
| 2045 SetMark(string_table, string_table_mark); | 2028 SetMark(string_table, string_table_mark); |
| 2046 // Explicitly mark the prefix. | 2029 // Explicitly mark the prefix. |
| 2047 MarkingVisitor marker(heap()); | 2030 string_table->IteratePrefix(visitor); |
| 2048 string_table->IteratePrefix(&marker); | |
| 2049 ProcessMarkingDeque(); | 2031 ProcessMarkingDeque(); |
| 2050 } | 2032 } |
| 2051 | 2033 |
| 2052 | 2034 |
| 2053 void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { | 2035 void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { |
| 2054 // Mark the heap roots including global variables, stack variables, | 2036 // Mark the heap roots including global variables, stack variables, |
| 2055 // etc., and all objects reachable from them. | 2037 // etc., and all objects reachable from them. |
| 2056 heap()->IterateStrongRoots(visitor, VISIT_ONLY_STRONG); | 2038 heap()->IterateStrongRoots(visitor, VISIT_ONLY_STRONG); |
| 2057 | 2039 |
| 2058 // Handle the string table specially. | 2040 // Handle the string table specially. |
| 2059 MarkStringTable(); | 2041 MarkStringTable(visitor); |
| 2060 | 2042 |
| 2061 // There may be overflowed objects in the heap. Visit them now. | 2043 // There may be overflowed objects in the heap. Visit them now. |
| 2062 while (marking_deque_.overflowed()) { | 2044 while (marking_deque_.overflowed()) { |
| 2063 RefillMarkingDeque(); | 2045 RefillMarkingDeque(); |
| 2064 EmptyMarkingDeque(); | 2046 EmptyMarkingDeque(); |
| 2065 } | 2047 } |
| 2066 } | 2048 } |
| 2067 | 2049 |
| 2068 | 2050 |
| 2069 void MarkCompactCollector::MarkImplicitRefGroups() { | 2051 void MarkCompactCollector::MarkImplicitRefGroups() { |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3284 invalidated_code_.Rewind(0); | 3266 invalidated_code_.Rewind(0); |
| 3285 } | 3267 } |
| 3286 | 3268 |
| 3287 | 3269 |
| 3288 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { | 3270 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
| 3289 Heap::RelocationLock relocation_lock(heap()); | 3271 Heap::RelocationLock relocation_lock(heap()); |
| 3290 | 3272 |
| 3291 bool code_slots_filtering_required; | 3273 bool code_slots_filtering_required; |
| 3292 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); | 3274 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); |
| 3293 code_slots_filtering_required = MarkInvalidatedCode(); | 3275 code_slots_filtering_required = MarkInvalidatedCode(); |
| 3294 | |
| 3295 EvacuateNewSpace(); | 3276 EvacuateNewSpace(); |
| 3296 } | 3277 } |
| 3297 | 3278 |
| 3298 | |
| 3299 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_EVACUATE_PAGES); | 3279 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_EVACUATE_PAGES); |
| 3300 EvacuatePages(); | 3280 EvacuatePages(); |
| 3301 } | 3281 } |
| 3302 | 3282 |
| 3303 // Second pass: find pointers to new space and update them. | 3283 // Second pass: find pointers to new space and update them. |
| 3304 PointersUpdatingVisitor updating_visitor(heap()); | 3284 PointersUpdatingVisitor updating_visitor(heap()); |
| 3305 | 3285 |
| 3306 { GCTracer::Scope gc_scope(tracer_, | 3286 { GCTracer::Scope gc_scope(tracer_, |
| 3307 GCTracer::Scope::MC_UPDATE_NEW_TO_NEW_POINTERS); | 3287 GCTracer::Scope::MC_UPDATE_NEW_TO_NEW_POINTERS); |
| 3308 // Update pointers in to space. | 3288 // Update pointers in to space. |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 while (buffer != NULL) { | 4295 while (buffer != NULL) { |
| 4316 SlotsBuffer* next_buffer = buffer->next(); | 4296 SlotsBuffer* next_buffer = buffer->next(); |
| 4317 DeallocateBuffer(buffer); | 4297 DeallocateBuffer(buffer); |
| 4318 buffer = next_buffer; | 4298 buffer = next_buffer; |
| 4319 } | 4299 } |
| 4320 *buffer_address = NULL; | 4300 *buffer_address = NULL; |
| 4321 } | 4301 } |
| 4322 | 4302 |
| 4323 | 4303 |
| 4324 } } // namespace v8::internal | 4304 } } // namespace v8::internal |
| OLD | NEW |