2017-06-23 10:44:53 +00:00
|
|
|
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "src/heap/worklist.h"
|
|
|
|
|
|
|
|
#include "test/unittests/test-utils.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
class SomeObject {};
|
2017-07-04 08:50:55 +00:00
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
using TestWorklist = Worklist<SomeObject*, 64>;
|
2017-06-23 10:44:53 +00:00
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentCreate) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.IsEmpty());
|
|
|
|
EXPECT_EQ(0u, segment.Size());
|
|
|
|
EXPECT_FALSE(segment.IsFull());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentPush) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_EQ(0u, segment.Size());
|
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
EXPECT_EQ(1u, segment.Size());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentPushPop) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
EXPECT_EQ(1u, segment.Size());
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy;
|
|
|
|
SomeObject* object = &dummy;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Pop(&object));
|
|
|
|
EXPECT_EQ(0u, segment.Size());
|
|
|
|
EXPECT_EQ(nullptr, object);
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentIsEmpty) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.IsEmpty());
|
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
EXPECT_FALSE(segment.IsEmpty());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentIsFull) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_FALSE(segment.IsFull());
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::Segment::kCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(segment.IsFull());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentClear) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
EXPECT_FALSE(segment.IsEmpty());
|
|
|
|
segment.Clear();
|
|
|
|
EXPECT_TRUE(segment.IsEmpty());
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::Segment::kCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentFullPushFails) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_FALSE(segment.IsFull());
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::Segment::kCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.Push(nullptr));
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(segment.IsFull());
|
|
|
|
EXPECT_FALSE(segment.Push(nullptr));
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentEmptyPopFails) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(segment.IsEmpty());
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_FALSE(segment.Pop(&object));
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentUpdateFalse) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object;
|
|
|
|
object = reinterpret_cast<SomeObject*>(&object);
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(segment.Push(object));
|
2017-07-05 09:38:29 +00:00
|
|
|
segment.Update([](SomeObject* object, SomeObject** out) { return false; });
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(segment.IsEmpty());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SegmentUpdate) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::Segment segment;
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* objectA;
|
|
|
|
objectA = reinterpret_cast<SomeObject*>(&objectA);
|
|
|
|
SomeObject* objectB;
|
|
|
|
objectB = reinterpret_cast<SomeObject*>(&objectB);
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(segment.Push(objectA));
|
2017-07-05 09:38:29 +00:00
|
|
|
segment.Update([objectB](SomeObject* object, SomeObject** out) {
|
|
|
|
*out = objectB;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
SomeObject* object;
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(segment.Pop(&object));
|
|
|
|
EXPECT_EQ(object, objectB);
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, CreateEmpty) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view(&worklist, 0);
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view.IsLocalEmpty());
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, LocalPushPop) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view(&worklist, 0);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy;
|
|
|
|
SomeObject* retrieved = nullptr;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(&dummy));
|
|
|
|
EXPECT_FALSE(worklist_view.IsLocalEmpty());
|
|
|
|
EXPECT_TRUE(worklist_view.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy, retrieved);
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, LocalIsBasedOnId) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
2017-06-23 10:44:53 +00:00
|
|
|
// Use the same id.
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist::View worklist_view1(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view2(&worklist, 0);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy;
|
|
|
|
SomeObject* retrieved = nullptr;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy));
|
|
|
|
EXPECT_FALSE(worklist_view1.IsLocalEmpty());
|
|
|
|
EXPECT_FALSE(worklist_view2.IsLocalEmpty());
|
|
|
|
EXPECT_TRUE(worklist_view2.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy, retrieved);
|
|
|
|
EXPECT_TRUE(worklist_view1.IsLocalEmpty());
|
|
|
|
EXPECT_TRUE(worklist_view2.IsLocalEmpty());
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, LocalPushStaysPrivate) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view1(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view2(&worklist, 1);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy;
|
|
|
|
SomeObject* retrieved = nullptr;
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy));
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_FALSE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_FALSE(worklist_view2.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(nullptr, retrieved);
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy, retrieved);
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, GlobalUpdateNull) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view(&worklist, 0);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object;
|
|
|
|
object = reinterpret_cast<SomeObject*>(&object);
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(object));
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(worklist_view.Push(object));
|
2017-07-05 09:38:29 +00:00
|
|
|
worklist.Update([](SomeObject* object, SomeObject** out) { return false; });
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 15:06:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, GlobalUpdate) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view(&worklist, 0);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* objectA = nullptr;
|
|
|
|
objectA = reinterpret_cast<SomeObject*>(&objectA);
|
|
|
|
SomeObject* objectB = nullptr;
|
|
|
|
objectB = reinterpret_cast<SomeObject*>(&objectB);
|
|
|
|
SomeObject* objectC = nullptr;
|
|
|
|
objectC = reinterpret_cast<SomeObject*>(&objectC);
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(objectA));
|
|
|
|
}
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-26 14:47:36 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(objectB));
|
|
|
|
}
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(objectA));
|
2017-07-05 09:38:29 +00:00
|
|
|
worklist.Update([objectA, objectC](SomeObject* object, SomeObject** out) {
|
|
|
|
if (object != objectA) {
|
|
|
|
*out = objectC;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-06-26 14:47:36 +00:00
|
|
|
});
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object;
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Pop(&object));
|
2017-06-26 14:47:36 +00:00
|
|
|
EXPECT_EQ(object, objectC);
|
2017-06-23 15:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, FlushToGlobalPushSegment) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view0(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view1(&worklist, 1);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object = nullptr;
|
|
|
|
SomeObject* objectA = nullptr;
|
|
|
|
objectA = reinterpret_cast<SomeObject*>(&objectA);
|
2017-06-27 15:35:57 +00:00
|
|
|
EXPECT_TRUE(worklist_view0.Push(objectA));
|
|
|
|
worklist.FlushToGlobal(0);
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&object));
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, FlushToGlobalPopSegment) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view0(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view1(&worklist, 1);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object = nullptr;
|
|
|
|
SomeObject* objectA = nullptr;
|
|
|
|
objectA = reinterpret_cast<SomeObject*>(&objectA);
|
2017-06-27 15:35:57 +00:00
|
|
|
EXPECT_TRUE(worklist_view0.Push(objectA));
|
|
|
|
EXPECT_TRUE(worklist_view0.Push(objectA));
|
|
|
|
EXPECT_TRUE(worklist_view0.Pop(&object));
|
|
|
|
worklist.FlushToGlobal(0);
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&object));
|
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, Clear) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view(&worklist, 0);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* object;
|
|
|
|
object = reinterpret_cast<SomeObject*>(&object);
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 15:06:03 +00:00
|
|
|
EXPECT_TRUE(worklist_view.Push(object));
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(worklist_view.Push(object));
|
|
|
|
worklist.Clear();
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 15:06:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, SingleSegmentSteal) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view1(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view2(&worklist, 1);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy;
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy));
|
|
|
|
}
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* retrieved = nullptr;
|
2017-06-23 10:44:53 +00:00
|
|
|
// One more push/pop to publish the full segment.
|
|
|
|
EXPECT_TRUE(worklist_view1.Push(nullptr));
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(nullptr, retrieved);
|
|
|
|
// Stealing.
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view2.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy, retrieved);
|
|
|
|
EXPECT_FALSE(worklist_view1.Pop(&retrieved));
|
|
|
|
}
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 09:38:29 +00:00
|
|
|
TEST(WorkListTest, MultipleSegmentsStolen) {
|
2017-07-04 08:50:55 +00:00
|
|
|
TestWorklist worklist;
|
|
|
|
TestWorklist::View worklist_view1(&worklist, 0);
|
|
|
|
TestWorklist::View worklist_view2(&worklist, 1);
|
|
|
|
TestWorklist::View worklist_view3(&worklist, 2);
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject dummy1;
|
|
|
|
SomeObject dummy2;
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy1));
|
|
|
|
}
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy2));
|
|
|
|
}
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* retrieved = nullptr;
|
|
|
|
SomeObject dummy3;
|
2017-06-23 10:44:53 +00:00
|
|
|
// One more push/pop to publish the full segment.
|
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy3));
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy3, retrieved);
|
|
|
|
// Stealing.
|
|
|
|
EXPECT_TRUE(worklist_view2.Pop(&retrieved));
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* const expect_bag2 = retrieved;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view3.Pop(&retrieved));
|
2017-07-05 09:38:29 +00:00
|
|
|
SomeObject* const expect_bag3 = retrieved;
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_NE(expect_bag2, expect_bag3);
|
|
|
|
EXPECT_TRUE(expect_bag2 == &dummy1 || expect_bag2 == &dummy2);
|
|
|
|
EXPECT_TRUE(expect_bag3 == &dummy1 || expect_bag3 == &dummy2);
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 1; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view2.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(expect_bag2, retrieved);
|
|
|
|
EXPECT_FALSE(worklist_view1.Pop(&retrieved));
|
|
|
|
}
|
2017-07-04 08:50:55 +00:00
|
|
|
for (size_t i = 1; i < TestWorklist::kSegmentCapacity; i++) {
|
2017-06-23 10:44:53 +00:00
|
|
|
EXPECT_TRUE(worklist_view3.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(expect_bag3, retrieved);
|
|
|
|
EXPECT_FALSE(worklist_view1.Pop(&retrieved));
|
|
|
|
}
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist.IsEmpty());
|
2017-06-23 10:44:53 +00:00
|
|
|
}
|
|
|
|
|
2017-10-10 10:45:54 +00:00
|
|
|
TEST(WorkListTest, MergeGlobalPool) {
|
|
|
|
TestWorklist worklist1;
|
|
|
|
TestWorklist::View worklist_view1(&worklist1, 0);
|
|
|
|
SomeObject dummy;
|
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
|
|
|
EXPECT_TRUE(worklist_view1.Push(&dummy));
|
|
|
|
}
|
|
|
|
SomeObject* retrieved = nullptr;
|
|
|
|
// One more push/pop to publish the full segment.
|
|
|
|
EXPECT_TRUE(worklist_view1.Push(nullptr));
|
|
|
|
EXPECT_TRUE(worklist_view1.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(nullptr, retrieved);
|
|
|
|
// Merging global pool into a new Worklist.
|
|
|
|
TestWorklist worklist2;
|
|
|
|
TestWorklist::View worklist_view2(&worklist2, 0);
|
|
|
|
worklist2.MergeGlobalPool(&worklist1);
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_FALSE(worklist2.IsEmpty());
|
2017-10-10 10:45:54 +00:00
|
|
|
for (size_t i = 0; i < TestWorklist::kSegmentCapacity; i++) {
|
|
|
|
EXPECT_TRUE(worklist_view2.Pop(&retrieved));
|
|
|
|
EXPECT_EQ(&dummy, retrieved);
|
|
|
|
EXPECT_FALSE(worklist_view1.Pop(&retrieved));
|
|
|
|
}
|
2018-07-03 06:27:38 +00:00
|
|
|
EXPECT_TRUE(worklist1.IsEmpty());
|
|
|
|
EXPECT_TRUE(worklist2.IsEmpty());
|
2017-10-10 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 10:44:53 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|