Commit 26c540f3 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[wrapper-tracing] Use name for missed write barriers

This avoids writing a pointer for each traced wrapper on dispatch. It
also brings the wrapper tracing descriptor closer to the regular trace
descriptor.

Bug: chromium:841830
Change-Id: I6be7566a465184b12d9021926b3a61cd66934bc6
Reviewed-on: https://chromium-review.googlesource.com/1067572Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561335}
parent 145fb4de
......@@ -5,7 +5,9 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_SCRIPT_WRAPPABLE_VISITOR_VERIFIER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_SCRIPT_WRAPPABLE_VISITOR_VERIFIER_H_
#include "base/logging.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable_visitor.h"
#include "third_party/blink/renderer/platform/heap/gc_info.h"
namespace blink {
......@@ -16,21 +18,22 @@ class ScriptWrappableVisitorVerifier final : public ScriptWrappableVisitor {
protected:
void Visit(const TraceWrapperV8Reference<v8::Value>&) final {}
void Visit(const TraceWrapperDescriptor& descriptor) final {
if (!HeapObjectHeader::FromPayload(descriptor.base_object_payload)
->IsWrapperHeaderMarked()) {
// If this branch is hit, it means that a white (not discovered by
// traceWrappers) object was assigned as a member to a black object
// (already processed by traceWrappers). Black object will not be
// processed anymore so White object will remain undetected and
// therefore its wrapper and all wrappers reachable from it would be
// collected.
// This means there is a write barrier missing somewhere. Check the
// backtrace to see which types are causing this and review all the
// places where white object is set to a black object.
descriptor.missed_write_barrier_callback();
NOTREACHED();
}
HeapObjectHeader* header =
HeapObjectHeader::FromPayload(descriptor.base_object_payload);
const char* name = GCInfoTable::Get()
.GCInfoFromIndex(header->GcInfoIndex())
->name_(descriptor.base_object_payload);
// If this FATAL is hit, it means that a white (not discovered by
// TraceWrappers) object was assigned as a member to a black object (already
// processed by TraceWrappers). The black object will not be processed
// anymore so white object will remain undetected and therefore its wrapper
// and all wrappers reachable from it would be collected.
//
// This means there is a write barrier missing somewhere. Check the
// backtrace to see which types are causing this and review all the places
// where white object is set to a black object.
LOG_IF(FATAL, !header->IsWrapperHeaderMarked())
<< "Write barrier missed for " << name;
}
void Visit(DOMWrapperMap<ScriptWrappable>*,
const ScriptWrappable* key) final {}
......
......@@ -28,7 +28,6 @@ using TraceCallback = VisitorCallback;
using TraceWrappersCallback = void (*)(ScriptWrappableVisitor*, void*);
using WeakCallback = VisitorCallback;
using EphemeronCallback = VisitorCallback;
using MissedWriteBarrierCallback = void (*)();
using NameCallback = const char* (*)(const void* self);
// Callback used for unit testing the marking of conservative pointers
......
......@@ -58,7 +58,6 @@ struct TraceWrapperDescriptor {
STACK_ALLOCATED();
void* base_object_payload;
TraceWrappersCallback trace_wrappers_callback;
MissedWriteBarrierCallback missed_write_barrier_callback;
};
// The GarbageCollectedMixin interface and helper macro
......@@ -114,7 +113,7 @@ class PLATFORM_EXPORT GarbageCollectedMixin {
return {BlinkGC::kNotFullyConstructedObject, nullptr, false};
}
virtual TraceWrapperDescriptor GetTraceWrapperDescriptor() const {
return {BlinkGC::kNotFullyConstructedObject, nullptr, nullptr};
return {BlinkGC::kNotFullyConstructedObject, nullptr};
}
};
......@@ -135,8 +134,7 @@ class PLATFORM_EXPORT GarbageCollectedMixin {
\
TraceWrapperDescriptor GetTraceWrapperDescriptor() const override { \
return {const_cast<TYPE*>(static_cast<const TYPE*>(this)), \
TraceTrait<TYPE>::TraceWrappers, \
ScriptWrappableVisitor::MissedWriteBarrier<TYPE>}; \
TraceTrait<TYPE>::TraceWrappers}; \
} \
\
private:
......
......@@ -55,8 +55,7 @@ class AdjustPointerTrait<T, false> {
}
static TraceWrapperDescriptor GetTraceWrapperDescriptor(void* self) {
return {self, TraceTrait<T>::TraceWrappers,
ScriptWrappableVisitor::MissedWriteBarrier<T>};
return {self, TraceTrait<T>::TraceWrappers};
}
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