Index: src/heap/concurrent-marking.cc |
diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc |
index d47eea01153ae0610c43323e038a25e24810da98..42c3fe51331f7a7843647950a3512b7746c75d13 100644 |
--- a/src/heap/concurrent-marking.cc |
+++ b/src/heap/concurrent-marking.cc |
@@ -50,7 +50,7 @@ class ConcurrentMarkingMarkbits { |
class ConcurrentMarkingVisitor : public ObjectVisitor { |
public: |
- ConcurrentMarkingVisitor() {} |
+ ConcurrentMarkingVisitor() : bytes_marked_(0) {} |
void VisitPointers(Object** start, Object** end) override { |
for (Object** p = start; p < end; p++) { |
@@ -61,6 +61,7 @@ class ConcurrentMarkingVisitor : public ObjectVisitor { |
void MarkObject(HeapObject* obj) { |
if (markbits_.Mark(obj)) { |
+ bytes_marked_ += obj->Size(); |
marking_stack_.push(obj); |
} |
} |
@@ -73,7 +74,10 @@ class ConcurrentMarkingVisitor : public ObjectVisitor { |
} |
} |
+ size_t bytes_marked() { return bytes_marked_; } |
+ |
private: |
+ size_t bytes_marked_; |
std::stack<HeapObject*> marking_stack_; |
ConcurrentMarkingMarkbits markbits_; |
}; |
@@ -92,11 +96,18 @@ class ConcurrentMarking::Task : public CancelableTask { |
private: |
// v8::internal::CancelableTask overrides. |
void RunInternal() override { |
- USE(heap_); |
+ double start_time_ms = heap_->MonotonicallyIncreasingTimeInMs(); |
Michael Lippautz
2017/03/08 19:14:34
nit: There's TimedScope in utils-inl.h
e.g.
doub
ulan
2017/03/10 16:45:26
Done.
|
for (HeapObject* obj : *root_set_) { |
marking_visitor_.MarkObject(obj); |
} |
marking_visitor_.MarkTransitively(); |
+ double end_time_ms = heap_->MonotonicallyIncreasingTimeInMs(); |
+ if (FLAG_trace_concurrent_marking) { |
+ heap_->isolate()->PrintWithTimestamp( |
+ "concurrently marked %dKB in %.2fms\n", |
+ static_cast<int>(marking_visitor_.bytes_marked() / KB), |
+ end_time_ms - start_time_ms); |
+ } |
on_finish_->Signal(); |
} |
@@ -108,7 +119,12 @@ class ConcurrentMarking::Task : public CancelableTask { |
}; |
ConcurrentMarking::ConcurrentMarking(Heap* heap) |
- : heap_(heap), pending_task_(0) {} |
+ : heap_(heap), pending_task_semaphore_(0), is_task_pending_(false) { |
+ // Concurrent marking does not work with double unboxing. |
+ STATIC_ASSERT(!(V8_CONCURRENT_MARKING && V8_DOUBLE_FIELDS_UNBOXING)); |
+ // The runtime flag should be set only if the compile time flag was set. |
+ CHECK(!FLAG_concurrent_marking || V8_CONCURRENT_MARKING); |
+} |
ConcurrentMarking::~ConcurrentMarking() {} |
@@ -118,15 +134,18 @@ void ConcurrentMarking::AddRoot(HeapObject* object) { |
void ConcurrentMarking::StartMarkingTask() { |
if (!FLAG_concurrent_marking) return; |
+ is_task_pending_ = true; |
V8::GetCurrentPlatform()->CallOnBackgroundThread( |
- new Task(heap_, &root_set_, &pending_task_), |
+ new Task(heap_, &root_set_, &pending_task_semaphore_), |
v8::Platform::kShortRunningTask); |
} |
void ConcurrentMarking::WaitForTaskToComplete() { |
if (!FLAG_concurrent_marking) return; |
- pending_task_.Wait(); |
+ pending_task_semaphore_.Wait(); |
+ is_task_pending_ = false; |
+ root_set_.clear(); |
} |
} // namespace internal |