Commit f3e2ad99 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Separate shared objects from objects of untracked contexts

Currently objects that belong to the untracked contexts (i.e. contexts
for which measurement was not requested) are accounted in the shared
context. This CL introduces a dummy kOtherContext and attributes such
objects to that context.

Bug: chromium:973627
Change-Id: I9801ab317d95b944336b79a5e17721511d4897c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2025370Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66019}
parent 19f23ae9
......@@ -41,8 +41,11 @@ void MarkingWorklistsHolder::CreateContextWorklists(
const std::vector<Address>& contexts) {
DCHECK(worklists_.empty());
DCHECK(context_worklists_.empty());
if (contexts.empty()) return;
worklists_.reserve(contexts.size());
context_worklists_.reserve(contexts.size());
context_worklists_.reserve(contexts.size() + 2);
context_worklists_.push_back({kSharedContext, &shared_});
context_worklists_.push_back({kOtherContext, &other_});
for (Address context : contexts) {
MarkingWorklist* worklist = new MarkingWorklist();
worklists_.push_back(std::unique_ptr<MarkingWorklist>(worklist));
......@@ -93,7 +96,6 @@ MarkingWorklists::MarkingWorklists(int task_id, MarkingWorklistsHolder* holder)
context_worklists_(holder->context_worklists()) {
if (!context_worklists_.empty()) {
is_per_context_mode_ = true;
context_worklists_.push_back({kSharedContext, shared_});
worklist_by_context_.reserve(context_worklists_.size());
for (auto& cw : context_worklists_) {
worklist_by_context_[cw.context] = cw.worklist;
......@@ -181,10 +183,10 @@ bool MarkingWorklists::PopContext(HeapObject* object) {
Address MarkingWorklists::SwitchToContextSlow(Address context) {
const auto& it = worklist_by_context_.find(context);
if (V8_UNLIKELY(it == worklist_by_context_.end())) {
// This context was created during marking, so we don't have a worklist
// for it. Use the shared worklist.
active_ = shared_;
active_context_ = kSharedContext;
// This context was created during marking or is not being measured,
// so we don't have a specific worklist for it.
active_context_ = kOtherContext;
active_ = worklist_by_context_[active_context_];
} else {
active_ = it->second;
active_context_ = context;
......
......@@ -62,6 +62,13 @@ struct ContextWorklistPair {
// A helper class that owns all marking worklists.
class V8_EXPORT_PRIVATE MarkingWorklistsHolder {
public:
// Fake addresses of special contexts used for per-context accounting.
// - kSharedContext is for objects that are not attributed to any context.
// - kOtherContext is for objects that are attributed to contexts that are
// not being measured.
static const Address kSharedContext = 0;
static const Address kOtherContext = 8;
~MarkingWorklistsHolder();
// Calls the specified callback on each element of the deques and replaces
......@@ -119,12 +126,17 @@ class V8_EXPORT_PRIVATE MarkingWorklistsHolder {
std::vector<ContextWorklistPair> context_worklists_;
// This is used only for lifetime management of the per-context worklists.
std::vector<std::unique_ptr<MarkingWorklist>> worklists_;
// Worklist used for objects that are attributed to contexts that are
// not being measured.
MarkingWorklist other_;
};
// A thread-local view of the marking worklists.
class V8_EXPORT_PRIVATE MarkingWorklists {
public:
static const Address kSharedContext = 0;
static const Address kSharedContext = MarkingWorklistsHolder::kSharedContext;
static const Address kOtherContext = MarkingWorklistsHolder::kOtherContext;
MarkingWorklists(int task_id, MarkingWorklistsHolder* holder);
......
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