9a0e6bd5c0
This moves concurrent and incremental sweeping from Blink. This also adds TestPlatform that makes it easier to test concurrent and incremental sweeping. Drive-by: fix unmarking of large pages. Bug: chromium:1056170 Change-Id: Ifd50ff67b9df17ff117a5f4d4eb5a2937d3023be Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2207132 Commit-Queue: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#67969}
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
// Copyright 2020 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.
|
|
|
|
#ifndef V8_UNITTESTS_HEAP_CPPGC_TESTS_H_
|
|
#define V8_UNITTESTS_HEAP_CPPGC_TESTS_H_
|
|
|
|
#include "include/cppgc/heap.h"
|
|
#include "include/cppgc/platform.h"
|
|
#include "src/heap/cppgc/heap.h"
|
|
#include "test/unittests/heap/cppgc/test-platform.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace cppgc {
|
|
namespace internal {
|
|
namespace testing {
|
|
|
|
class TestWithPlatform : public ::testing::Test {
|
|
protected:
|
|
static void SetUpTestSuite();
|
|
static void TearDownTestSuite();
|
|
|
|
TestPlatform& GetPlatform() const { return *platform_; }
|
|
|
|
private:
|
|
static std::unique_ptr<TestPlatform> platform_;
|
|
};
|
|
|
|
class TestWithHeap : public TestWithPlatform {
|
|
protected:
|
|
TestWithHeap();
|
|
|
|
void PreciseGC() {
|
|
heap_->ForceGarbageCollectionSlow(
|
|
"TestWithHeap", "Testing", Heap::GCConfig::StackState::kNoHeapPointers);
|
|
}
|
|
|
|
cppgc::Heap* GetHeap() const { return heap_.get(); }
|
|
|
|
private:
|
|
std::unique_ptr<cppgc::Heap> heap_;
|
|
};
|
|
|
|
// Restrictive test fixture that supports allocation but will make sure no
|
|
// garbage collection is triggered. This is useful for writing idiomatic
|
|
// tests where object are allocated on the managed heap while still avoiding
|
|
// far reaching test consquences of full garbage collection calls.
|
|
class TestSupportingAllocationOnly : public TestWithHeap {
|
|
protected:
|
|
TestSupportingAllocationOnly();
|
|
|
|
private:
|
|
Heap::NoGCScope no_gc_scope_;
|
|
};
|
|
|
|
} // namespace testing
|
|
} // namespace internal
|
|
} // namespace cppgc
|
|
|
|
#endif // V8_UNITTESTS_HEAP_CPPGC_TESTS_H_
|