Commit 110fa66e authored by Leon Bettscheider's avatar Leon Bettscheider Committed by V8 LUCI CQ

[heap] Use MarkingWorklists in MinorMC

This CL is part of an effort to enable concurrent marking in MinorMC.

For this purpose we plan to reuse the IncrementalMarking class which
already implements a part of the concurrent marking code for MajorMC.
IncrementalMarking internally uses the MarkingWorklists class.

This CL adapts the stop-the-world marking implementation of
MinorMC to use the MarkingWorklists class.

Bug: v8:13012
Change-Id: I3c4eb33142f2630e89aa3771b6065b9f82dc0847
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3747862Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Leon Bettscheider <bettscheider@google.com>
Cr-Commit-Position: refs/heads/main@{#81646}
parent 8ab9821b
...@@ -43,7 +43,7 @@ void MarkCompactCollector::MarkRootObject(Root root, HeapObject obj) { ...@@ -43,7 +43,7 @@ void MarkCompactCollector::MarkRootObject(Root root, HeapObject obj) {
void MinorMarkCompactCollector::MarkRootObject(HeapObject obj) { void MinorMarkCompactCollector::MarkRootObject(HeapObject obj) {
if (Heap::InYoungGeneration(obj) && if (Heap::InYoungGeneration(obj) &&
non_atomic_marking_state_.WhiteToBlack(obj)) { non_atomic_marking_state_.WhiteToBlack(obj)) {
main_thread_worklist_local_.Push(obj); main_thread_worklists_local_->Push(obj);
} }
} }
......
This diff is collapsed.
...@@ -777,17 +777,17 @@ class MinorMarkCompactCollector final { ...@@ -777,17 +777,17 @@ class MinorMarkCompactCollector final {
std::unique_ptr<UpdatingItem> CreateRememberedSetUpdatingItem( std::unique_ptr<UpdatingItem> CreateRememberedSetUpdatingItem(
MemoryChunk* chunk, RememberedSetUpdatingMode updating_mode); MemoryChunk* chunk, RememberedSetUpdatingMode updating_mode);
MarkingWorklists::Local* main_thread_worklists_local() {
return main_thread_worklists_local_.get();
}
private: private:
class RootMarkingVisitor; class RootMarkingVisitor;
static const int kNumMarkers = 8; static const int kNumMarkers = 8;
static const int kMainMarker = 0; static const int kMainMarker = 0;
inline MarkingWorklist* worklist() { return worklist_; } inline MarkingWorklists* worklists() { return &worklists_; }
inline YoungGenerationMarkingVisitor* main_marking_visitor() {
return main_marking_visitor_;
}
void MarkLiveObjects(); void MarkLiveObjects();
void MarkRootSetInParallel(RootMarkingVisitor* root_visitor); void MarkRootSetInParallel(RootMarkingVisitor* root_visitor);
...@@ -813,13 +813,13 @@ class MinorMarkCompactCollector final { ...@@ -813,13 +813,13 @@ class MinorMarkCompactCollector final {
Heap* heap_; Heap* heap_;
MarkingWorklist* worklist_; MarkingWorklists worklists_;
MarkingWorklist::Local main_thread_worklist_local_; std::unique_ptr<MarkingWorklists::Local> main_thread_worklists_local_;
std::unique_ptr<YoungGenerationMarkingVisitor> main_marking_visitor_;
MarkingState marking_state_; MarkingState marking_state_;
NonAtomicMarkingState non_atomic_marking_state_; NonAtomicMarkingState non_atomic_marking_state_;
YoungGenerationMarkingVisitor* main_marking_visitor_;
base::Semaphore page_parallel_job_semaphore_; base::Semaphore page_parallel_job_semaphore_;
std::vector<Page*> new_space_evacuation_pages_; std::vector<Page*> new_space_evacuation_pages_;
std::vector<Page*> promoted_pages_; std::vector<Page*> promoted_pages_;
......
...@@ -21,14 +21,6 @@ ...@@ -21,14 +21,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
MarkingWorklists::~MarkingWorklists() {
DCHECK(shared_.IsEmpty());
DCHECK(on_hold_.IsEmpty());
DCHECK(other_.IsEmpty());
DCHECK(worklists_.empty());
DCHECK(context_worklists_.empty());
}
void MarkingWorklists::Clear() { void MarkingWorklists::Clear() {
shared_.Clear(); shared_.Clear();
on_hold_.Clear(); on_hold_.Clear();
...@@ -106,7 +98,6 @@ MarkingWorklists::Local::Local( ...@@ -106,7 +98,6 @@ MarkingWorklists::Local::Local(
std::unique_ptr<CppMarkingState> cpp_marking_state) std::unique_ptr<CppMarkingState> cpp_marking_state)
: on_hold_(global->on_hold()), : on_hold_(global->on_hold()),
wrapper_(global->wrapper()), wrapper_(global->wrapper()),
is_per_context_mode_(false),
cpp_marking_state_(std::move(cpp_marking_state)) { cpp_marking_state_(std::move(cpp_marking_state)) {
if (global->context_worklists().empty()) { if (global->context_worklists().empty()) {
MarkingWorklist::Local shared(global->shared()); MarkingWorklist::Local shared(global->shared());
...@@ -126,17 +117,6 @@ MarkingWorklists::Local::Local( ...@@ -126,17 +117,6 @@ MarkingWorklists::Local::Local(
} }
} }
MarkingWorklists::Local::~Local() {
DCHECK(active_.IsLocalEmpty());
if (is_per_context_mode_) {
for (auto& cw : worklist_by_context_) {
if (cw.first != active_context_) {
DCHECK(cw.second->IsLocalEmpty());
}
}
}
}
void MarkingWorklists::Local::Publish() { void MarkingWorklists::Local::Publish() {
active_.Publish(); active_.Publish();
on_hold_.Publish(); on_hold_.Publish();
......
...@@ -66,7 +66,7 @@ struct ContextWorklistPair { ...@@ -66,7 +66,7 @@ struct ContextWorklistPair {
}; };
// A helper class that owns all global marking worklists. // A helper class that owns all global marking worklists.
class V8_EXPORT_PRIVATE MarkingWorklists { class V8_EXPORT_PRIVATE MarkingWorklists final {
public: public:
class Local; class Local;
// Fake addresses of special contexts used for per-context accounting. // Fake addresses of special contexts used for per-context accounting.
...@@ -77,7 +77,9 @@ class V8_EXPORT_PRIVATE MarkingWorklists { ...@@ -77,7 +77,9 @@ class V8_EXPORT_PRIVATE MarkingWorklists {
static const Address kOtherContext = 8; static const Address kOtherContext = 8;
MarkingWorklists() = default; MarkingWorklists() = default;
~MarkingWorklists();
// Worklists implicitly check for emptiness on destruction.
~MarkingWorklists() = default;
// Calls the specified callback on each element of the deques and replaces // Calls the specified callback on each element of the deques and replaces
// the element with the result of the callback. If the callback returns // the element with the result of the callback. If the callback returns
...@@ -141,16 +143,18 @@ class V8_EXPORT_PRIVATE MarkingWorklists { ...@@ -141,16 +143,18 @@ class V8_EXPORT_PRIVATE MarkingWorklists {
// - active_owner == worlist_by_context[active_context_].get() // - active_owner == worlist_by_context[active_context_].get()
// - *active_owner is empty (all fields are null) because its content has // - *active_owner is empty (all fields are null) because its content has
// been moved to active_. // been moved to active_.
class V8_EXPORT_PRIVATE MarkingWorklists::Local { class V8_EXPORT_PRIVATE MarkingWorklists::Local final {
public: public:
static constexpr Address kSharedContext = MarkingWorklists::kSharedContext; static constexpr Address kSharedContext = MarkingWorklists::kSharedContext;
static constexpr Address kOtherContext = MarkingWorklists::kOtherContext; static constexpr Address kOtherContext = MarkingWorklists::kOtherContext;
static constexpr std::nullptr_t kNoCppMarkingState = nullptr; static constexpr std::nullptr_t kNoCppMarkingState = nullptr;
Local( explicit Local(
MarkingWorklists* global, MarkingWorklists* global,
std::unique_ptr<CppMarkingState> cpp_marking_state = kNoCppMarkingState); std::unique_ptr<CppMarkingState> cpp_marking_state = kNoCppMarkingState);
~Local();
// Local worklists implicitly check for emptiness on destruction.
~Local() = default;
inline void Push(HeapObject object); inline void Push(HeapObject object);
inline bool Pop(HeapObject* object); inline bool Pop(HeapObject* object);
...@@ -200,7 +204,7 @@ class V8_EXPORT_PRIVATE MarkingWorklists::Local { ...@@ -200,7 +204,7 @@ class V8_EXPORT_PRIVATE MarkingWorklists::Local {
MarkingWorklist::Local active_; MarkingWorklist::Local active_;
Address active_context_; Address active_context_;
MarkingWorklist::Local* active_owner_; MarkingWorklist::Local* active_owner_;
bool is_per_context_mode_; bool is_per_context_mode_ = false;
std::unordered_map<Address, std::unique_ptr<MarkingWorklist::Local>> std::unordered_map<Address, std::unique_ptr<MarkingWorklist::Local>>
worklist_by_context_; worklist_by_context_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment