Commit 457c305c authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[oilpan] Move name callbacks into GCInfo

This moves the NameCallback from the fast path (trace descriptor) to a
slow path in GCInfo. It also allows for implementing naming for the rest
of the DOM.

Bug: chromium:841830
Change-Id: I61e8043855eb673ea173b92627e78df3e7eff0ab
Reviewed-on: https://chromium-review.googlesource.com/1069964
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561040}
parent 085ec0d9
......@@ -242,7 +242,7 @@ namespace {
class HandleContainer
: public blink::GarbageCollectedFinalized<HandleContainer>,
blink::TraceWrapperBase {
public blink::TraceWrapperBase {
public:
static HandleContainer* Create() { return new HandleContainer(); }
virtual ~HandleContainer() = default;
......
......@@ -140,9 +140,13 @@ void V8EmbedderGraphBuilder::Visit(
// Add an edge from the current parent to this object.
// Also push the object to the worklist in order to process its members.
const void* traceable = wrapper_descriptor.base_object_payload;
const char* name =
GCInfoTable::Get()
.GCInfoFromIndex(
HeapObjectHeader::FromPayload(traceable)->GcInfoIndex())
->name_(traceable);
EmbedderNode* graph_node =
GraphNode(traceable, wrapper_descriptor.name_callback(traceable), nullptr,
current_parent_->GetDomTreeState());
GraphNode(traceable, name, nullptr, current_parent_->GetDomTreeState());
graph_->AddEdge(current_parent_, graph_node);
PushToWorklist(ToWorklistItem(graph_node, wrapper_descriptor));
}
......
......@@ -50,12 +50,6 @@ class PLATFORM_EXPORT ScriptWrappableVisitor {
NOTREACHED();
}
template <typename T>
static const char* NameCallback(const void* traceable) {
// Mixns never inherit from TraceWrapperBase.
return NameInHeapSnapshot(static_cast<const T*>(traceable));
}
// Trace all wrappers of |tracable|.
//
// If you cannot use TraceWrapperMember & the corresponding TraceWrappers()
......@@ -123,15 +117,6 @@ class PLATFORM_EXPORT ScriptWrappableVisitor {
}
private:
static const char* NameInHeapSnapshot(const TraceWrapperBase* traceable) {
return traceable->NameInHeapSnapshot();
}
static const char* NameInHeapSnapshot(...) {
// Default case for all non-TraceWrapperBase classes.
return "InternalNode";
}
// Helper method to invoke the virtual Visit method with wrapper descriptor.
template <typename T>
void Visit(const T* traceable) {
......
......@@ -59,6 +59,7 @@ blink_platform_sources("heap") {
"marking_visitor.cc",
"marking_visitor.h",
"member.h",
"name_traits.h",
"page_memory.cc",
"page_memory.h",
"page_pool.cc",
......
......@@ -59,7 +59,6 @@ struct TraceWrapperDescriptor {
void* base_object_payload;
TraceWrappersCallback trace_wrappers_callback;
MissedWriteBarrierCallback missed_write_barrier_callback;
NameCallback name_callback;
};
// The GarbageCollectedMixin interface and helper macro
......@@ -115,7 +114,7 @@ class PLATFORM_EXPORT GarbageCollectedMixin {
return {BlinkGC::kNotFullyConstructedObject, nullptr, false};
}
virtual TraceWrapperDescriptor GetTraceWrapperDescriptor() const {
return {BlinkGC::kNotFullyConstructedObject, nullptr, nullptr, nullptr};
return {BlinkGC::kNotFullyConstructedObject, nullptr, nullptr};
}
};
......@@ -137,8 +136,7 @@ class PLATFORM_EXPORT GarbageCollectedMixin {
TraceWrapperDescriptor GetTraceWrapperDescriptor() const override { \
return {const_cast<TYPE*>(static_cast<const TYPE*>(this)), \
TraceTrait<TYPE>::TraceWrappers, \
ScriptWrappableVisitor::MissedWriteBarrier<TYPE>, \
ScriptWrappableVisitor::NameCallback<TYPE>}; \
ScriptWrappableVisitor::MissedWriteBarrier<TYPE>}; \
} \
\
private:
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_GC_INFO_H_
#include "third_party/blink/renderer/platform/heap/finalizer_traits.h"
#include "third_party/blink/renderer/platform/heap/name_traits.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
......@@ -33,8 +34,10 @@ namespace blink {
struct GCInfo {
bool HasFinalizer() const { return non_trivial_finalizer_; }
bool HasVTable() const { return has_v_table_; }
TraceCallback trace_;
FinalizationCallback finalize_;
NameCallback name_;
bool non_trivial_finalizer_;
bool has_v_table_;
};
......@@ -107,8 +110,9 @@ struct GCInfoAtBaseType {
static size_t Index() {
static_assert(sizeof(T), "T must be fully defined");
static const GCInfo kGcInfo = {
TraceTrait<T>::Trace, FinalizerTrait<T>::Finalize,
FinalizerTrait<T>::kNonTrivialFinalizer, std::is_polymorphic<T>::value,
TraceTrait<T>::Trace, FinalizerTrait<T>::Finalize,
NameTrait<T>::GetName, FinalizerTrait<T>::kNonTrivialFinalizer,
std::is_polymorphic<T>::value,
};
static size_t gc_info_index = 0;
if (!AcquireLoad(&gc_info_index))
......
......@@ -15,7 +15,7 @@ TEST(GCInfoTest, InitialEmpty) {
TEST(GCInfoTest, ResizeToMaxIndex) {
GCInfoTable table;
GCInfo info = {nullptr, nullptr, false, false};
GCInfo info = {nullptr, nullptr, nullptr, false, false};
size_t slot = 0;
for (size_t i = 0; i < (GCInfoTable::kMaxIndex - 1); i++) {
slot = 0;
......
// Copyright 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_NAME_TRAITS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_NAME_TRAITS_H_
#include "third_party/blink/renderer/platform/bindings/trace_wrapper_base.h"
namespace blink {
template <typename T>
class NameTrait {
STATIC_ONLY(NameTrait);
public:
static const char* GetName(const void* obj) {
return GetNameFor(static_cast<const T*>(obj));
}
private:
static const char* GetNameFor(const TraceWrapperBase* wrapper_tracable) {
return wrapper_tracable->NameInHeapSnapshot();
}
static const char* GetNameFor(...) { return "InternalNode"; }
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_NAME_TRAITS_H_
......@@ -56,8 +56,7 @@ class AdjustPointerTrait<T, false> {
static TraceWrapperDescriptor GetTraceWrapperDescriptor(void* self) {
return {self, TraceTrait<T>::TraceWrappers,
ScriptWrappableVisitor::MissedWriteBarrier<T>,
ScriptWrappableVisitor::NameCallback<T>};
ScriptWrappableVisitor::MissedWriteBarrier<T>};
}
static HeapObjectHeader* GetHeapObjectHeader(void* self) {
......
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