OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/concurrent-marking.h" | 5 #include "src/heap/concurrent-marking.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "src/heap/heap-inl.h" | 10 #include "src/heap/heap-inl.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void FreeBitmap(Bitmap* bitmap) { free(bitmap); } | 47 void FreeBitmap(Bitmap* bitmap) { free(bitmap); } |
48 | 48 |
49 private: | 49 private: |
50 std::unordered_map<MemoryChunk*, Bitmap*> bitmap_; | 50 std::unordered_map<MemoryChunk*, Bitmap*> bitmap_; |
51 }; | 51 }; |
52 | 52 |
53 class ConcurrentMarkingVisitor : public ObjectVisitor { | 53 class ConcurrentMarkingVisitor : public ObjectVisitor { |
54 public: | 54 public: |
55 ConcurrentMarkingVisitor() : bytes_marked_(0) {} | 55 ConcurrentMarkingVisitor() : bytes_marked_(0) {} |
56 | 56 |
57 void VisitPointers(Object** start, Object** end) override { | 57 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
58 for (Object** p = start; p < end; p++) { | 58 for (Object** p = start; p < end; p++) { |
59 if (!(*p)->IsHeapObject()) continue; | 59 if (!(*p)->IsHeapObject()) continue; |
60 MarkObject(HeapObject::cast(*p)); | 60 MarkObject(HeapObject::cast(*p)); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void MarkObject(HeapObject* obj) { | 64 void MarkObject(HeapObject* obj) { |
65 if (markbits_.Mark(obj)) { | 65 if (markbits_.Mark(obj)) { |
66 bytes_marked_ += obj->Size(); | 66 bytes_marked_ += obj->Size(); |
67 marking_stack_.push(obj); | 67 marking_stack_.push(obj); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 void ConcurrentMarking::EnsureTaskCompleted() { | 154 void ConcurrentMarking::EnsureTaskCompleted() { |
155 if (IsTaskPending()) { | 155 if (IsTaskPending()) { |
156 WaitForTaskToComplete(); | 156 WaitForTaskToComplete(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 } // namespace internal | 160 } // namespace internal |
161 } // namespace v8 | 161 } // namespace v8 |
OLD | NEW |