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

heap: Various fixes for compiling with Oilpan library

- Fix cppgc traits for TraceWrapperV8Reference
- Fix ThreadState compilation
- Fix String resolution

Bug: 1056170
Change-Id: I95f6ce324b632465e936a0b6d00aab082e28507c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616199Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841415}
parent 65f45e8a
...@@ -1658,6 +1658,7 @@ component("platform") { ...@@ -1658,6 +1658,7 @@ component("platform") {
"//third_party/blink/public/common", "//third_party/blink/public/common",
"//third_party/blink/public/strings", "//third_party/blink/public/strings",
"//third_party/blink/renderer/platform/wtf", "//third_party/blink/renderer/platform/wtf",
"//third_party/blink/renderer/platform/wtf:buildflags",
"//third_party/ced", "//third_party/ced",
"//third_party/emoji-segmenter", "//third_party/emoji-segmenter",
"//third_party/harfbuzz-ng:hb_scoped_util", "//third_party/harfbuzz-ng:hb_scoped_util",
......
...@@ -11,9 +11,17 @@ ...@@ -11,9 +11,17 @@
#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/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/vector_traits.h" #include "third_party/blink/renderer/platform/wtf/vector_traits.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace cppgc {
template <typename T>
struct TraceTrait;
} // namespace cppgc
namespace blink { namespace blink {
template <typename T> template <typename T>
...@@ -123,13 +131,37 @@ class TraceWrapperV8Reference { ...@@ -123,13 +131,37 @@ class TraceWrapperV8Reference {
} }
v8::TracedReference<T> handle_; v8::TracedReference<T> handle_;
friend struct cppgc::TraceTrait<TraceWrapperV8Reference<T>>;
}; };
} // namespace blink
#if BUILDFLAG(USE_V8_OILPAN)
namespace cppgc {
template <typename T>
struct TraceTrait<TraceWrapperV8Reference<T>> {
STATIC_ONLY(TraceTrait);
static cppgc::TraceDescriptor GetTraceDescriptor(
const TraceWrapperV8Reference<T>* ref) {
return {ref, Trace};
}
static void Trace(Visitor* visitor, const void* self) {
visitor->Trace(
static_cast<const TraceWrapperV8Reference<T>*>(self)->handle_);
}
};
} // namespace cppgc
#else // !USE_V8_OILPAN
namespace blink {
template <typename T> template <typename T>
struct TraceTrait<TraceWrapperV8Reference<T>> { struct TraceTrait<TraceWrapperV8Reference<T>> {
STATIC_ONLY(TraceTrait); STATIC_ONLY(TraceTrait);
public:
static TraceDescriptor GetTraceDescriptor( static TraceDescriptor GetTraceDescriptor(
const TraceWrapperV8Reference<T>* ref) { const TraceWrapperV8Reference<T>* ref) {
return {ref, TraceTrait<TraceWrapperV8Reference<T>>::Trace}; return {ref, TraceTrait<TraceWrapperV8Reference<T>>::Trace};
...@@ -139,9 +171,10 @@ struct TraceTrait<TraceWrapperV8Reference<T>> { ...@@ -139,9 +171,10 @@ struct TraceTrait<TraceWrapperV8Reference<T>> {
visitor->Trace(*static_cast<const TraceWrapperV8Reference<T>*>(ref)); visitor->Trace(*static_cast<const TraceWrapperV8Reference<T>*>(ref));
} }
}; };
} // namespace blink } // namespace blink
#endif // !USE_V8_OILPAN
namespace WTF { namespace WTF {
template <typename T> template <typename T>
......
...@@ -34,9 +34,9 @@ void ThreadState::DetachCurrentThread() { ...@@ -34,9 +34,9 @@ void ThreadState::DetachCurrentThread() {
} }
ThreadState::ThreadState(v8::CppHeap& cpp_heap) ThreadState::ThreadState(v8::CppHeap& cpp_heap)
: cpp_heap_(cpp_heap), : allocation_handle_(cpp_heap.GetAllocationHandle()),
allocation_handle_(cpp_heap.GetAllocationHandle()) cpp_heap_(cpp_heap),
thread_id_(CurrentThread()) {} thread_id_(CurrentThread()) {}
ThreadState::~ThreadState() { ThreadState::~ThreadState() {
DCHECK(!IsMainThread()); DCHECK(!IsMainThread());
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_THREAD_STATE_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_THREAD_STATE_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_THREAD_STATE_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_V8_WRAPPER_THREAD_STATE_H_
#include "base/compiler_specific.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.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/thread_specific.h" #include "third_party/blink/renderer/platform/wtf/thread_specific.h"
...@@ -68,6 +69,7 @@ class ThreadState final { ...@@ -68,6 +69,7 @@ class ThreadState final {
ALWAYS_INLINE cppgc::AllocationHandle& allocation_handle() const { ALWAYS_INLINE cppgc::AllocationHandle& allocation_handle() const {
return allocation_handle_; return allocation_handle_;
} }
ALWAYS_INLINE v8::CppHeap& cpp_heap() const { return cpp_heap_; }
private: private:
// Main-thread ThreadState avoids TLS completely by using a regular global. // Main-thread ThreadState avoids TLS completely by using a regular global.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "third_party/blink/public/platform/web_private_ptr.h" #include "third_party/blink/public/platform/web_private_ptr.h"
#include "third_party/blink/renderer/platform/heap/gc_task_runner.h" #include "third_party/blink/renderer/platform/heap/gc_task_runner.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink { namespace blink {
class BlinkGCMemoryDumpProvider; class BlinkGCMemoryDumpProvider;
......
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