Commit 6cfba48b authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

[heap] Align v8 and oilpan worklists

This CL makes the following changes:
1) Size of allocated buffer is set by a template parameter
   (with a default value instead of hardcoded size)
2) Remove dynamic parameter for initializing number of
   tasks (see comment in scavenger.cc)

This CL aligns the v8 and oilpan heaps so that they provide
the same interface and functionality.

Change-Id: I77d63793f0a54ea29198ddd6bd298eae2c15cf42
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030920Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66158}
parent e9d8b990
......@@ -253,9 +253,9 @@ void ScavengerCollector::CollectGarbage() {
const int num_scavenge_tasks = NumberOfScavengeTasks();
OneshotBarrier barrier(base::TimeDelta::FromMilliseconds(kMaxWaitTimeMs));
Worklist<MemoryChunk*, 64> empty_chunks;
Scavenger::CopiedList copied_list(num_scavenge_tasks);
Scavenger::PromotionList promotion_list(num_scavenge_tasks);
EphemeronTableList ephemeron_table_list(num_scavenge_tasks);
Scavenger::CopiedList copied_list;
Scavenger::PromotionList promotion_list;
EphemeronTableList ephemeron_table_list;
for (int i = 0; i < num_scavenge_tasks; i++) {
scavengers[i] =
new Scavenger(this, heap_, is_logging, &empty_chunks, &copied_list,
......
......@@ -89,10 +89,6 @@ class Scavenger {
int task_id_;
};
explicit PromotionList(int num_tasks)
: regular_object_promotion_list_(num_tasks),
large_object_promotion_list_(num_tasks) {}
inline void PushRegularObject(int task_id, HeapObject object, int size);
inline void PushLargeObject(int task_id, HeapObject object, Map map,
int size);
......
......@@ -24,7 +24,7 @@ namespace internal {
//
// Work stealing is best effort, i.e., there is no way to inform other tasks
// of the need of items.
template <typename EntryType, int SEGMENT_SIZE>
template <typename EntryType, int SEGMENT_SIZE, int MAX_NUM_TASKS = 8>
class Worklist {
public:
class View {
......@@ -58,14 +58,11 @@ class Worklist {
int task_id_;
};
static const int kMaxNumTasks = 8;
static const int kMaxNumTasks = MAX_NUM_TASKS;
static const size_t kSegmentCapacity = SEGMENT_SIZE;
Worklist() : Worklist(kMaxNumTasks) {}
explicit Worklist(int num_tasks) : num_tasks_(num_tasks) {
DCHECK_LE(num_tasks, kMaxNumTasks);
for (int i = 0; i < num_tasks_; i++) {
Worklist() {
for (int i = 0; i < kMaxNumTasks; i++) {
private_push_segment(i) = NewSegment();
private_pop_segment(i) = NewSegment();
}
......@@ -73,7 +70,7 @@ class Worklist {
~Worklist() {
CHECK(IsEmpty());
for (int i = 0; i < num_tasks_; i++) {
for (int i = 0; i < kMaxNumTasks; i++) {
DCHECK_NOT_NULL(private_push_segment(i));
DCHECK_NOT_NULL(private_pop_segment(i));
delete private_push_segment(i);
......@@ -91,7 +88,7 @@ class Worklist {
}
bool Push(int task_id, EntryType entry) {
DCHECK_LT(task_id, num_tasks_);
DCHECK_LT(task_id, kMaxNumTasks);
DCHECK_NOT_NULL(private_push_segment(task_id));
if (!private_push_segment(task_id)->Push(entry)) {
PublishPushSegmentToGlobal(task_id);
......@@ -103,7 +100,7 @@ class Worklist {
}
bool Pop(int task_id, EntryType* entry) {
DCHECK_LT(task_id, num_tasks_);
DCHECK_LT(task_id, kMaxNumTasks);
DCHECK_NOT_NULL(private_pop_segment(task_id));
if (!private_pop_segment(task_id)->Pop(entry)) {
if (!private_push_segment(task_id)->IsEmpty()) {
......@@ -137,7 +134,7 @@ class Worklist {
}
bool AreLocalsEmpty() {
for (int i = 0; i < num_tasks_; i++) {
for (int i = 0; i < kMaxNumTasks; i++) {
if (!IsLocalEmpty(i)) return false;
}
return true;
......@@ -152,7 +149,7 @@ class Worklist {
//
// Assumes that no other tasks are running.
void Clear() {
for (int i = 0; i < num_tasks_; i++) {
for (int i = 0; i < kMaxNumTasks; i++) {
private_pop_segment(i)->Clear();
private_push_segment(i)->Clear();
}
......@@ -169,7 +166,7 @@ class Worklist {
// Assumes that no other tasks are running.
template <typename Callback>
void Update(Callback callback) {
for (int i = 0; i < num_tasks_; i++) {
for (int i = 0; i < kMaxNumTasks; i++) {
private_pop_segment(i)->Update(callback);
private_push_segment(i)->Update(callback);
}
......@@ -183,7 +180,7 @@ class Worklist {
// Assumes that no other tasks are running.
template <typename Callback>
void Iterate(Callback callback) {
for (int i = 0; i < num_tasks_; i++) {
for (int i = 0; i < kMaxNumTasks; i++) {
private_pop_segment(i)->Iterate(callback);
private_push_segment(i)->Iterate(callback);
}
......@@ -420,7 +417,6 @@ class Worklist {
PrivateSegmentHolder private_segments_[kMaxNumTasks];
GlobalPool global_pool_;
int num_tasks_;
};
} // namespace internal
......
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