Commit 5734d1c4 authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: Fix more compile-time errors

... when compiling with the Oilpan library.

- Fixes issues with include-what-you-use
- Use the right WTF trait in WebPrivatePtr
- Add stub for TraceWrapperV8Reference write barrier

Bug: chromium:1056170
Change-Id: I53421f1b3f05a9c0b553bbf22731f3dcf0eb5ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567213
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832385}
parent 822ab9b6
......@@ -73,9 +73,8 @@ enum LifetimeManagementType {
template <typename T>
struct LifetimeOf {
private:
static const bool kIsGarbageCollected =
WTF::IsSubclassOfTemplate<T, GarbageCollected>::value ||
IsGarbageCollectedMixin<T>::value;
// Covers GarbageCollected and GarbageCollectedMixin.
static const bool kIsGarbageCollected = WTF::IsGarbageCollectedType<T>::value;
public:
static const LifetimeManagementType value =
......
......@@ -7,8 +7,11 @@
#include <utility>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "third_party/blink/renderer/platform/heap/unified_heap_marking_visitor.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/vector_traits.h"
#include "v8/include/v8.h"
namespace blink {
......
......@@ -5,6 +5,8 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_GARBAGE_COLLECTED_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_GARBAGE_COLLECTED_H_
#include "v8/include/cppgc/type-traits.h"
// GC_PLUGIN_IGNORE is used to make the plugin ignore a particular class or
// field when checking for proper usage. When using GC_PLUGIN_IGNORE
// a bug-number should be provided as an argument where the bug describes
......@@ -16,4 +18,14 @@
#define GC_PLUGIN_IGNORE(bug)
#endif
namespace blink {
template <typename T>
struct IsGarbageCollectedMixin {
public:
static const bool value = cppgc::IsGarbageCollectedMixinTypeV<T>;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_GARBAGE_COLLECTED_H_
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_PERSISTENT_H_
#include "base/bind.h"
#include "third_party/blink/renderer/platform/bindings/buildflags.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"
#include "v8/include/cppgc/cross-thread-persistent.h"
#include "v8/include/cppgc/persistent.h"
......@@ -66,6 +67,12 @@ T& WrapPersistentIfNeeded(T& value) {
return value;
}
#if BUILDFLAG(RAW_HEAP_SNAPSHOTS)
#define PERSISTENT_FROM_HERE PersistentLocation::Current()
#else
#define PERSISTENT_FROM_HERE PersistentLocation()
#endif // BUILDFLAG(RAW_HEAP_SNAPSHOTS)
} // namespace blink
namespace base {
......
......@@ -13,7 +13,8 @@ base::LazyInstance<WTF::ThreadSpecific<ThreadState*>>::Leaky
ThreadState::thread_specific_ = LAZY_INSTANCE_INITIALIZER;
// static
uint8_t ThreadState::main_thread_state_storage_[sizeof(ThreadState)];
alignas(ThreadState) uint8_t
ThreadState::main_thread_state_storage_[sizeof(ThreadState)];
// static
ThreadState* ThreadState::AttachMainThread(v8::CppHeap& cpp_heap) {
......
......@@ -72,7 +72,7 @@ class ThreadState final {
private:
// Main-thread ThreadState avoids TLS completely by using a regular global.
// The object is manually managed and should not rely on global ctor/dtor.
static uint8_t main_thread_state_storage_[] alignas(ThreadState);
static uint8_t main_thread_state_storage_[];
// Storage for all ThreadState objects. This includes the main-thread
// ThreadState as well.
static base::LazyInstance<WTF::ThreadSpecific<ThreadState*>>::Leaky
......
......@@ -5,6 +5,23 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_UNIFIED_HEAP_MARKING_VISITOR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_UNIFIED_HEAP_MARKING_VISITOR_H_
// TODO(chromium:1056170): Implement wrapper.
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "v8/include/v8.h"
namespace blink {
template <typename T>
class TraceWrapperV8Reference;
class UnifiedHeapMarkingVisitor final {
STATIC_ONLY(UnifiedHeapMarkingVisitor);
public:
static void WriteBarrier(const TraceWrapperV8Reference<v8::Value>&) {
// TODO(mlippautz): Delegate to cppgc write barrier.
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_UNIFIED_HEAP_MARKING_VISITOR_H_
......@@ -91,7 +91,7 @@ void WorkerThread::ShutdownOnThread() {
}
WorkerThread::SimpleThreadImpl::SimpleThreadImpl(
const String& name_prefix,
const WTF::String& name_prefix,
const base::SimpleThread ::Options& options,
NonMainThreadSchedulerFactory factory,
bool supports_gc,
......
......@@ -70,7 +70,7 @@ class PLATFORM_EXPORT WorkerThread : public Thread {
std::unique_ptr<scheduler::NonMainThreadSchedulerImpl>(
base::sequence_manager::SequenceManager*)>;
explicit SimpleThreadImpl(const String& name_prefix,
explicit SimpleThreadImpl(const WTF::String& name_prefix,
const base::SimpleThread::Options& options,
NonMainThreadSchedulerFactory factory,
bool supports_gc,
......
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