Commit 8d57da02 authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap,bindings: More Oilpan library compilation fixes

Bug: 1056170
Change-Id: Ib9f1b70a8ccb2dd8a026981f4be6751b97cbd528
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617922
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841676}
parent 57cebabc
...@@ -24,6 +24,14 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { ...@@ -24,6 +24,14 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
virtual bool IsContextDestroyed() const = 0; virtual bool IsContextDestroyed() const = 0;
virtual bool DispatchHasPendingActivity() const = 0; virtual bool DispatchHasPendingActivity() const = 0;
// See trait below.
//
// Registering the ActiveScriptWrappableBase after construction means that
// the garbage collector does not need to deal with objects that are
// currently under construction. This is important as checking whether ASW
// should be treated as active involves calling virtual functions which may
// not work during construction. The objects in construction are kept alive
// via conservative stack scanning.
void ActiveScriptWrappableBaseConstructed(); void ActiveScriptWrappableBaseConstructed();
protected: protected:
...@@ -33,6 +41,31 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { ...@@ -33,6 +41,31 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
DISALLOW_COPY_AND_ASSIGN(ActiveScriptWrappableBase); DISALLOW_COPY_AND_ASSIGN(ActiveScriptWrappableBase);
}; };
} // namespace blink
#if BUILDFLAG(USE_V8_OILPAN)
namespace cppgc {
template <typename T, typename = void>
struct PostConstructionCallbackTrait;
template <typename T>
struct PostConstructionCallbackTrait<
T,
base::void_t<decltype(
std::declval<T>().ActiveScriptWrappableBaseConstructed())>> {
static void Call(T* object) {
static_assert(std::is_base_of<blink::ActiveScriptWrappableBase, T>::value,
"Only ActiveScriptWrappableBase should use the "
"post-construction hook.");
object->ActiveScriptWrappableBaseConstructed();
}
};
} // namespace cppgc
#else // !USE_V8_OILPAN
namespace blink {
template <typename T> template <typename T>
struct PostConstructionHookTrait< struct PostConstructionHookTrait<
T, T,
...@@ -42,16 +75,12 @@ struct PostConstructionHookTrait< ...@@ -42,16 +75,12 @@ struct PostConstructionHookTrait<
static_assert(std::is_base_of<ActiveScriptWrappableBase, T>::value, static_assert(std::is_base_of<ActiveScriptWrappableBase, T>::value,
"Only ActiveScriptWrappableBase should use the " "Only ActiveScriptWrappableBase should use the "
"post-construction hook."); "post-construction hook.");
// Registering the ActiveScriptWrappableBase after construction means that
// the garbage collector does not need to deal with objects that are
// currently under construction. This is imnportant as checking whether ASW
// should be treated as active involves calling virtual functions which may
// not work during construction. The objects in construction are kept alive
// via conservative stack scanning.
object->ActiveScriptWrappableBaseConstructed(); object->ActiveScriptWrappableBaseConstructed();
} }
}; };
} // namespace blink } // namespace blink
#endif // !USE_V8_OILPAN
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_ACTIVE_SCRIPT_WRAPPABLE_BASE_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_ACTIVE_SCRIPT_WRAPPABLE_BASE_H_
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#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/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/vector_traits.h" #include "third_party/blink/renderer/platform/wtf/vector_traits.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -78,7 +79,8 @@ class TraceWrapperV8Reference { ...@@ -78,7 +79,8 @@ class TraceWrapperV8Reference {
} }
template <class S> template <class S>
TraceWrapperV8Reference(TraceWrapperV8Reference<S>&& other) noexcept { TraceWrapperV8Reference( // NOLINT
TraceWrapperV8Reference<S>&& other) noexcept {
*this = std::move(other); *this = std::move(other);
} }
...@@ -140,17 +142,17 @@ class TraceWrapperV8Reference { ...@@ -140,17 +142,17 @@ class TraceWrapperV8Reference {
namespace cppgc { namespace cppgc {
template <typename T> template <typename T>
struct TraceTrait<TraceWrapperV8Reference<T>> { struct TraceTrait<blink::TraceWrapperV8Reference<T>> {
STATIC_ONLY(TraceTrait); STATIC_ONLY(TraceTrait);
static cppgc::TraceDescriptor GetTraceDescriptor( static cppgc::TraceDescriptor GetTraceDescriptor(
const TraceWrapperV8Reference<T>* ref) { const blink::TraceWrapperV8Reference<T>* ref) {
return {ref, Trace}; return {ref, Trace};
} }
static void Trace(Visitor* visitor, const void* self) { static void Trace(Visitor* visitor, const void* self) {
visitor->Trace( visitor->Trace(
static_cast<const TraceWrapperV8Reference<T>*>(self)->handle_); static_cast<const blink::TraceWrapperV8Reference<T>*>(self)->handle_);
} }
}; };
} // namespace cppgc } // namespace cppgc
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "gin/public/wrapper_info.h" #include "gin/public/wrapper_info.h"
#include "third_party/blink/renderer/platform/bindings/v8_interface_bridge_base.h" #include "third_party/blink/renderer/platform/bindings/v8_interface_bridge_base.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.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/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
...@@ -43,7 +44,6 @@ namespace blink { ...@@ -43,7 +44,6 @@ namespace blink {
class CustomWrappable; class CustomWrappable;
class DOMWrapperWorld; class DOMWrapperWorld;
class ScriptWrappable; class ScriptWrappable;
class Visitor;
static const int kV8DOMWrapperTypeIndex = static const int kV8DOMWrapperTypeIndex =
static_cast<int>(gin::kWrapperInfoIndex); static_cast<int>(gin::kWrapperInfoIndex);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_GARBAGE_COLLECTED_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_GARBAGE_COLLECTED_H_
#define 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/garbage-collected.h"
#include "v8/include/cppgc/type-traits.h" #include "v8/include/cppgc/type-traits.h"
// GC_PLUGIN_IGNORE is used to make the plugin ignore a particular class or // GC_PLUGIN_IGNORE is used to make the plugin ignore a particular class or
...@@ -20,6 +21,8 @@ ...@@ -20,6 +21,8 @@
namespace blink { namespace blink {
using GarbageCollectedMixin = cppgc::GarbageCollectedMixin;
template <typename T> template <typename T>
struct IsGarbageCollectedMixin { struct IsGarbageCollectedMixin {
public: public:
......
...@@ -14,8 +14,6 @@ namespace blink { ...@@ -14,8 +14,6 @@ namespace blink {
template <typename T> template <typename T>
using GarbageCollected = cppgc::GarbageCollected<T>; using GarbageCollected = cppgc::GarbageCollected<T>;
using GarbageCollectedMixin = cppgc::GarbageCollectedMixin;
// Default MakeGarbageCollected: Constructs an instance of T, which is a garbage // Default MakeGarbageCollected: Constructs an instance of T, which is a garbage
// collected type. // collected type.
template <typename T, typename... Args> template <typename T, typename... Args>
......
...@@ -70,6 +70,11 @@ class ThreadState final { ...@@ -70,6 +70,11 @@ class ThreadState final {
return allocation_handle_; return allocation_handle_;
} }
ALWAYS_INLINE v8::CppHeap& cpp_heap() const { return cpp_heap_; } ALWAYS_INLINE v8::CppHeap& cpp_heap() const { return cpp_heap_; }
ALWAYS_INLINE v8::Isolate* GetIsolate() const {
// TODO(1056170): Refer to cpp_heap_ once getter for v8::Isolate is
// implemented.
return nullptr;
}
private: private:
// Main-thread ThreadState avoids TLS completely by using a regular global. // Main-thread ThreadState avoids TLS completely by using a regular global.
......
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