Commit 9565ae13 authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: More compilation fixes for Oilpan library

Bug: 1056170
Change-Id: I2382ff5f7489346e591e3f5466352ff6190e16c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626445Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843464}
parent 2e7009c0
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
namespace blink { namespace blink {
class Visitor;
namespace bindings { namespace bindings {
// This class is the base class for all IDL dictionary implementations. This is // This class is the base class for all IDL dictionary implementations. This is
......
...@@ -10,18 +10,17 @@ ...@@ -10,18 +10,17 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "third_party/blink/renderer/platform/heap/unified_heap_marking_visitor.h" #include "third_party/blink/renderer/platform/heap/unified_heap_marking_visitor.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/buildflags.h" #include "third_party/blink/renderer/platform/wtf/buildflags.h"
#include "third_party/blink/renderer/platform/wtf/hash_traits.h" #include "third_party/blink/renderer/platform/wtf/hash_traits.h"
#include "third_party/blink/renderer/platform/wtf/vector_traits.h" #include "third_party/blink/renderer/platform/wtf/vector_traits.h"
#include "v8/include/v8-cppgc.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace cppgc { #if BUILDFLAG(USE_V8_OILPAN)
#include "v8/include/cppgc/trace-trait.h"
template <typename T> #endif // USE_V8_OILPAN
struct TraceTrait;
} // namespace cppgc
namespace blink { namespace blink {
......
...@@ -126,7 +126,6 @@ blink_platform_sources("heap") { ...@@ -126,7 +126,6 @@ blink_platform_sources("heap") {
"impl/blink_gc.h", "impl/blink_gc.h",
"impl/blink_gc_memory_dump_provider.cc", "impl/blink_gc_memory_dump_provider.cc",
"impl/blink_gc_memory_dump_provider.h", "impl/blink_gc_memory_dump_provider.h",
"impl/disallow_new_wrapper.h",
"impl/finalizer_traits.h", "impl/finalizer_traits.h",
"impl/garbage_collected.h", "impl/garbage_collected.h",
"impl/gc_info.cc", "impl/gc_info.cc",
...@@ -142,7 +141,6 @@ blink_platform_sources("heap") { ...@@ -142,7 +141,6 @@ blink_platform_sources("heap") {
"impl/heap_page.h", "impl/heap_page.h",
"impl/heap_stats_collector.cc", "impl/heap_stats_collector.cc",
"impl/heap_stats_collector.h", "impl/heap_stats_collector.h",
"impl/heap_traits.h",
"impl/marking_scheduling_oracle.cc", "impl/marking_scheduling_oracle.cc",
"impl/marking_scheduling_oracle.h", "impl/marking_scheduling_oracle.h",
"impl/marking_verifier.cc", "impl/marking_verifier.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved. // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_
#include "third_party/blink/renderer/platform/wtf/buildflags.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#if BUILDFLAG(USE_V8_OILPAN) namespace blink {
#include "third_party/blink/renderer/platform/heap/v8_wrapper/disallow_new_wrapper.h"
#else // !USE_V8_OILPAN // DisallowNewWrapper wraps a disallow new type in a GarbageCollected class.
#include "third_party/blink/renderer/platform/heap/impl/disallow_new_wrapper.h" template <typename T>
#endif // !USE_V8_OILPAN class DisallowNewWrapper final
: public GarbageCollected<DisallowNewWrapper<T>> {
public:
explicit DisallowNewWrapper(const T& value) : value_(value) {
static_assert(WTF::IsDisallowNew<T>::value,
"T needs to be a disallow new type");
static_assert(WTF::IsTraceable<T>::value, "T needs to be traceable");
}
explicit DisallowNewWrapper(T&& value) : value_(std::forward<T>(value)) {
static_assert(WTF::IsDisallowNew<T>::value,
"T needs to be a disallow new type");
static_assert(WTF::IsTraceable<T>::value, "T needs to be traceable");
}
const T& Value() const { return value_; }
T&& TakeValue() { return std::move(value_); }
void Trace(Visitor* visitor) const { visitor->Trace(value_); }
private:
T value_;
};
// Wraps a disallow new type in a GarbageCollected class, making it possible to
// be referenced off heap from a Persistent.
template <typename T>
DisallowNewWrapper<T>* WrapDisallowNew(const T& value) {
return MakeGarbageCollected<DisallowNewWrapper<T>>(value);
}
template <typename T>
DisallowNewWrapper<T>* WrapDisallowNew(T&& value) {
return MakeGarbageCollected<DisallowNewWrapper<T>>(std::forward<T>(value));
}
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_DISALLOW_NEW_WRAPPER_H_
// Copyright 2020 The Chromium Authors. All rights reserved. // Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_
#include "third_party/blink/renderer/platform/wtf/buildflags.h" #include <type_traits>
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"
#if BUILDFLAG(USE_V8_OILPAN) namespace blink {
#include "third_party/blink/renderer/platform/heap/v8_wrapper/heap_traits.h"
#else // !USE_V8_OILPAN // Given a type T, returns a type that is either Member<T> or just T depending
#include "third_party/blink/renderer/platform/heap/impl/heap_traits.h" // on whether T is a garbage-collected type.
#endif // !USE_V8_OILPAN template <typename T>
using AddMemberIfNeeded =
std::conditional_t<WTF::IsGarbageCollectedType<T>::value, Member<T>, T>;
// Given a type T, returns a type that is either HeapVector<T>,
// HeapVector<Member<T>> or Vector<T> depending on T.
template <typename T>
using VectorOf = std::conditional_t<WTF::IsTraceable<T>::value,
HeapVector<AddMemberIfNeeded<T>>,
Vector<T>>;
// Given types T and U, returns a type that is one of the following:
// - HeapVector<std::pair<V, X>>
// (where V is either T or Member<T> and X is either U or Member<U>)
// - Vector<std::pair<T, U>>
template <typename T, typename U>
using VectorOfPairs = std::conditional_t<
WTF::IsTraceable<T>::value || WTF::IsTraceable<U>::value,
HeapVector<std::pair<AddMemberIfNeeded<T>, AddMemberIfNeeded<U>>>,
Vector<std::pair<T, U>>>;
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_HEAP_TRAITS_H_
// Copyright 2019 The Chromium 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_DISALLOW_NEW_WRAPPER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_DISALLOW_NEW_WRAPPER_H_
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
namespace blink {
// DisallowNewWrapper wraps a disallow new type in a GarbageCollected class.
template <typename T>
class DisallowNewWrapper final
: public GarbageCollected<DisallowNewWrapper<T>> {
public:
explicit DisallowNewWrapper(const T& value) : value_(value) {
static_assert(WTF::IsDisallowNew<T>::value,
"T needs to be a disallow new type");
static_assert(WTF::IsTraceable<T>::value, "T needs to be traceable");
}
explicit DisallowNewWrapper(T&& value) : value_(std::forward<T>(value)) {
static_assert(WTF::IsDisallowNew<T>::value,
"T needs to be a disallow new type");
static_assert(WTF::IsTraceable<T>::value, "T needs to be traceable");
}
const T& Value() const { return value_; }
T&& TakeValue() { return std::move(value_); }
void Trace(Visitor* visitor) const { visitor->Trace(value_); }
private:
T value_;
};
// Wraps a disallow new type in a GarbageCollected class, making it possible to
// be referenced off heap from a Persistent.
template <typename T>
DisallowNewWrapper<T>* WrapDisallowNew(const T& value) {
return MakeGarbageCollected<DisallowNewWrapper<T>>(value);
}
template <typename T>
DisallowNewWrapper<T>* WrapDisallowNew(T&& value) {
return MakeGarbageCollected<DisallowNewWrapper<T>>(std::forward<T>(value));
}
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_DISALLOW_NEW_WRAPPER_H_
// Copyright (c) 2018 The Chromium 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_HEAP_TRAITS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_HEAP_TRAITS_H_
#include <type_traits>
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"
namespace blink {
// Given a type T, returns a type that is either Member<T> or just T depending
// on whether T is a garbage-collected type.
template <typename T>
using AddMemberIfNeeded =
std::conditional_t<WTF::IsGarbageCollectedType<T>::value, Member<T>, T>;
// Given a type T, returns a type that is either HeapVector<T>,
// HeapVector<Member<T>> or Vector<T> depending on T.
template <typename T>
using VectorOf = std::conditional_t<WTF::IsTraceable<T>::value,
HeapVector<AddMemberIfNeeded<T>>,
Vector<T>>;
// Given types T and U, returns a type that is one of the following:
// - HeapVector<std::pair<V, X>>
// (where V is either T or Member<T> and X is either U or Member<U>)
// - Vector<std::pair<T, U>>
template <typename T, typename U>
using VectorOfPairs = std::conditional_t<
WTF::IsTraceable<T>::value || WTF::IsTraceable<U>::value,
HeapVector<std::pair<AddMemberIfNeeded<T>, AddMemberIfNeeded<U>>>,
Vector<std::pair<T, U>>>;
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_IMPL_HEAP_TRAITS_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_VISITOR_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_VISITOR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_VISITOR_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_VISITOR_H_
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "v8/include/cppgc/visitor.h" #include "v8/include/cppgc/visitor.h"
namespace blink { namespace blink {
......
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