Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1543)

Unified Diff: third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp

Issue 2908463002: Enable heap compaction on all 'container' arenas. (Closed)
Patch Set: add checks for compaction being activated. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp b/third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp
index b3aa7117a4c8985d0fe63b0ced4d92c92506afeb..bb522d9908b1ed75839ad630d86f54a6466c51d3 100644
--- a/third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapCompactTest.cpp
@@ -16,13 +16,38 @@
namespace {
+enum VerifyArenaCompaction {
+ NoVerify,
+ VectorsAreCompacted,
+ HashTablesAreCompacted,
+};
+
class IntWrapper : public blink::GarbageCollectedFinalized<IntWrapper> {
public:
- static IntWrapper* Create(int x) { return new IntWrapper(x); }
+ static IntWrapper* Create(int x, VerifyArenaCompaction verify = NoVerify) {
+ return new IntWrapper(x, verify);
+ }
virtual ~IntWrapper() {}
- DEFINE_INLINE_TRACE() {}
+ DEFINE_INLINE_TRACE() {
+ // Verify if compaction is indeed activated.
+ //
+ // What arenas end up being compacted is dependent on residency,
+ // so approximate the arena checks to fit.
+ blink::HeapCompact* compaction = visitor->Heap().Compaction();
+ switch (verify_) {
+ case NoVerify:
+ return;
+ case HashTablesAreCompacted:
+ CHECK(compaction->IsCompactingArena(
+ blink::BlinkGC::kHashTableArenaIndex));
+ return;
+ case VectorsAreCompacted:
+ CHECK(compaction->IsCompactingVectorArenas());
+ return;
+ }
+ }
int Value() const { return x_; }
@@ -32,11 +57,13 @@ class IntWrapper : public blink::GarbageCollectedFinalized<IntWrapper> {
unsigned GetHash() { return IntHash<int>::GetHash(x_); }
- IntWrapper(int x) : x_(x) {}
+ IntWrapper(int x, VerifyArenaCompaction verify) : x_(x), verify_(verify) {}
private:
IntWrapper();
+
int x_;
+ VerifyArenaCompaction verify_;
};
static_assert(WTF::IsTraceable<IntWrapper>::value,
"IsTraceable<> template failed to recognize trace method.");
@@ -217,7 +244,7 @@ static void ClearOutOldGarbage() {
TEST(HeapCompactTest, CompactVector) {
ClearOutOldGarbage();
- IntWrapper* val = IntWrapper::Create(1);
+ IntWrapper* val = IntWrapper::Create(1, VectorsAreCompacted);
Persistent<IntVector> vector = new IntVector(10, val);
EXPECT_EQ(10u, vector->size());
@@ -235,7 +262,7 @@ TEST(HeapCompactTest, CompactHashMap) {
Persistent<IntMap> int_map = new IntMap();
for (size_t i = 0; i < 100; ++i) {
- IntWrapper* val = IntWrapper::Create(i);
+ IntWrapper* val = IntWrapper::Create(i, HashTablesAreCompacted);
int_map->insert(val, 100 - i);
}
@@ -258,7 +285,7 @@ TEST(HeapCompactTest, CompactVectorPartHashMap) {
for (size_t i = 0; i < 10; ++i) {
IntMap map;
for (size_t j = 0; j < 10; ++j) {
- IntWrapper* val = IntWrapper::Create(j);
+ IntWrapper* val = IntWrapper::Create(j, VectorsAreCompacted);
map.insert(val, 10 - j);
}
int_map_vector->push_back(map);
@@ -292,7 +319,7 @@ TEST(HeapCompactTest, CompactHashPartVector) {
for (size_t i = 0; i < 10; ++i) {
IntVector vector;
for (size_t j = 0; j < 10; ++j) {
- vector.push_back(IntWrapper::Create(j));
+ vector.push_back(IntWrapper::Create(j, HashTablesAreCompacted));
}
int_vector_map->insert(1 + i, vector);
}
@@ -319,7 +346,7 @@ TEST(HeapCompactTest, CompactHashPartVector) {
TEST(HeapCompactTest, CompactDeques) {
Persistent<IntDeque> deque = new IntDeque;
for (int i = 0; i < 8; ++i) {
- deque->push_front(IntWrapper::Create(i));
+ deque->push_front(IntWrapper::Create(i, VectorsAreCompacted));
}
EXPECT_EQ(8u, deque->size());
@@ -335,7 +362,7 @@ TEST(HeapCompactTest, CompactDeques) {
TEST(HeapCompactTest, CompactDequeVectors) {
Persistent<HeapDeque<IntVector>> deque = new HeapDeque<IntVector>;
for (int i = 0; i < 8; ++i) {
- IntWrapper* value = IntWrapper::Create(i);
+ IntWrapper* value = IntWrapper::Create(i, VectorsAreCompacted);
IntVector vector = IntVector(8, value);
deque->push_front(vector);
}
@@ -354,7 +381,7 @@ TEST(HeapCompactTest, CompactLinkedHashSet) {
using OrderedHashSet = HeapLinkedHashSet<Member<IntWrapper>>;
Persistent<OrderedHashSet> set = new OrderedHashSet;
for (int i = 0; i < 13; ++i) {
- IntWrapper* value = IntWrapper::Create(i);
+ IntWrapper* value = IntWrapper::Create(i, HashTablesAreCompacted);
set->insert(value);
}
EXPECT_EQ(13u, set->size());
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapCompact.cpp ('k') | third_party/WebKit/Source/platform/heap/HeapPage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698