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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void FreeBitmap(Bitmap* bitmap) { free(bitmap); } | 45 void FreeBitmap(Bitmap* bitmap) { free(bitmap); } |
46 | 46 |
47 private: | 47 private: |
48 std::unordered_map<MemoryChunk*, Bitmap*> bitmap_; | 48 std::unordered_map<MemoryChunk*, Bitmap*> bitmap_; |
49 }; | 49 }; |
50 | 50 |
51 class ConcurrentMarkingVisitor : public ObjectVisitor { | 51 class ConcurrentMarkingVisitor : public ObjectVisitor { |
52 public: | 52 public: |
53 ConcurrentMarkingVisitor() {} | 53 ConcurrentMarkingVisitor() {} |
54 | 54 |
55 void VisitPointers(Object** start, Object** end) override { | 55 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
56 for (Object** p = start; p < end; p++) { | 56 for (Object** p = start; p < end; p++) { |
57 if (!(*p)->IsHeapObject()) continue; | 57 if (!(*p)->IsHeapObject()) continue; |
58 MarkObject(HeapObject::cast(*p)); | 58 MarkObject(HeapObject::cast(*p)); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void MarkObject(HeapObject* obj) { | 62 void MarkObject(HeapObject* obj) { |
63 if (markbits_.Mark(obj)) { | 63 if (markbits_.Mark(obj)) { |
64 marking_stack_.push(obj); | 64 marking_stack_.push(obj); |
65 } | 65 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 v8::Platform::kShortRunningTask); | 124 v8::Platform::kShortRunningTask); |
125 } | 125 } |
126 | 126 |
127 void ConcurrentMarking::WaitForTaskToComplete() { | 127 void ConcurrentMarking::WaitForTaskToComplete() { |
128 if (!FLAG_concurrent_marking) return; | 128 if (!FLAG_concurrent_marking) return; |
129 pending_task_.Wait(); | 129 pending_task_.Wait(); |
130 } | 130 } |
131 | 131 |
132 } // namespace internal | 132 } // namespace internal |
133 } // namespace v8 | 133 } // namespace v8 |
OLD | NEW |