40 const std::vector<Address>& contexts) {
42 if (contexts.empty())
return;
45 for (
Address context : contexts) {
47 {
context, std::make_unique<MarkingWorklist>()});
56 std::map<InstanceType, int>
count;
60 count[obj->map()->instance_type()]++;
62 std::vector<std::pair<int, InstanceType>> rank;
63 rank.reserve(
count.size());
64 for (
const auto&
i :
count) {
65 rank.emplace_back(
i.second,
i.
first);
67 std::map<InstanceType, std::string> instance_type_name;
68#define INSTANCE_TYPE_NAME(name) instance_type_name[name] = #name;
70#undef INSTANCE_TYPE_NAME
71 std::sort(rank.begin(), rank.end(),
72 std::greater<std::pair<int, InstanceType>>());
73 PrintF(
"Worklist %s: %d\n", worklist_name, total_count);
75 PrintF(
" [%s]: %d\n", instance_type_name[
i.second].c_str(),
i.
first);
86 std::unique_ptr<CppMarkingState> cpp_marking_state)
89 on_hold_(*global->on_hold()),
90 active_context_(kSharedContext),
91 is_per_context_mode_(!global->context_worklists().empty()),
93 cpp_marking_state_(
std::move(cpp_marking_state)) {
109 if (is_per_context_mode_) {
110 for (
auto* entry = worklist_by_context_.Start(); entry !=
nullptr;
111 entry = worklist_by_context_.Next(entry)) {
115 PublishCppHeapObjects();
125 if (!is_per_context_mode_) {
132 for (
auto* entry = worklist_by_context_.Start(); entry !=
nullptr;
133 entry = worklist_by_context_.Next(entry)) {
135 if (entry->key != active_context_ &&
136 !(worklist.IsLocalEmpty() && worklist.IsGlobalEmpty())) {
137 SwitchToContextImpl(entry->key, &worklist);
145 return !cpp_marking_state_ || cpp_marking_state_->IsLocalEmpty();
160 DCHECK(!is_per_context_mode_);
167 DCHECK(is_per_context_mode_);
169 for (
auto* entry = worklist_by_context_.Start(); entry !=
nullptr;
170 entry = worklist_by_context_.Next(entry)) {
172 if (entry->key != active_context_ && !worklist.IsLocalEmpty()) {
173 SwitchToContextImpl(entry->key, &worklist);
178 for (
auto* entry = worklist_by_context_.Start(); entry !=
nullptr;
179 entry = worklist_by_context_.Next(entry)) {
181 if (entry->key != active_context_ && worklist.Pop(
object)) {
182 SwitchToContextImpl(entry->key, &worklist);
192 auto maybe_index = worklist_by_context_.Get(context);
206 return active_context_;
void Iterate(Callback callback) const
void Merge(Worklist< EntryType, MinSegmentSize > &other)
Address SwitchToSharedForTesting()
std::vector< MarkingWorklist::Local > context_worklists_
Address SwitchToContextSlow(Address context)
bool PopContext(Tagged< HeapObject > *object)
Local(MarkingWorklists *global, std::unique_ptr< CppMarkingState > cpp_marking_state=kNoCppMarkingState)
const bool is_per_context_mode_
bool IsWrapperEmpty() const
static constexpr std::nullptr_t kNoCppMarkingState
static constexpr Address kOtherContext
AddressToIndexHashMap worklist_by_context_
static constexpr Address kSharedContext
void CreateContextWorklists(const std::vector< Address > &contexts)
void PrintWorklist(const char *worklist_name, MarkingWorklist *worklist)
const std::vector< ContextWorklistPair > & context_worklists() const
static constexpr Address kSharedContext
static constexpr Address kOtherContext
void ReleaseContextWorklists()
std::vector< ContextWorklistPair > context_worklists_
void Set(Type value, uint32_t index)
Tagged< SharedFunctionInfo > shared_
std::vector< Handle< JSObject > > other_
void PrintF(const char *format,...)
#define INSTANCE_TYPE_LIST(V)
#define DCHECK(condition)
#define V8_UNLIKELY(condition)