v8/test/unittests/heap/concurrent-marking-deque-unittest.cc
ulan c6816cd87d [heap] Implement simple concurrent marking deque.
This patch adds a concurrent marking deque that exposes the same interface
for the main thread as the existing marking deque.

The matching interface makes the concurrent marking deque a drop-in
replacement for the sequential marking deque without any change in
mark-compactor and incremental marker.

BUG=chromium:694255

Review-Url: https://codereview.chromium.org/2810893002
Cr-Commit-Position: refs/heads/master@{#45042}
2017-05-02 17:03:31 +00:00

58 lines
1.7 KiB
C++

// 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 <stdlib.h>
#include "src/globals.h"
#include "src/heap/concurrent-marking-deque.h"
#include "src/heap/heap-inl.h"
#include "src/isolate.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
class ConcurrentMarkingDequeTest : public TestWithIsolate {
public:
ConcurrentMarkingDequeTest() {
marking_deque_ = new ConcurrentMarkingDeque(i_isolate()->heap());
object_ = i_isolate()->heap()->undefined_value();
}
~ConcurrentMarkingDequeTest() { delete marking_deque_; }
ConcurrentMarkingDeque* marking_deque() { return marking_deque_; }
HeapObject* object() { return object_; }
private:
ConcurrentMarkingDeque* marking_deque_;
HeapObject* object_;
DISALLOW_COPY_AND_ASSIGN(ConcurrentMarkingDequeTest);
};
TEST_F(ConcurrentMarkingDequeTest, Empty) {
EXPECT_TRUE(marking_deque()->IsEmpty());
EXPECT_EQ(0, marking_deque()->Size());
}
TEST_F(ConcurrentMarkingDequeTest, SharedDeque) {
marking_deque()->Push(object());
EXPECT_FALSE(marking_deque()->IsEmpty());
EXPECT_EQ(1, marking_deque()->Size());
EXPECT_EQ(object(), marking_deque()->Pop(MarkingThread::kConcurrent));
}
TEST_F(ConcurrentMarkingDequeTest, BailoutDeque) {
marking_deque()->Push(object(), MarkingThread::kConcurrent,
TargetDeque::kBailout);
EXPECT_FALSE(marking_deque()->IsEmpty());
EXPECT_EQ(1, marking_deque()->Size());
EXPECT_EQ(nullptr, marking_deque()->Pop(MarkingThread::kConcurrent));
}
} // namespace internal
} // namespace v8