Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h

Issue 1876383003: Introduce infrastructure for tracing ScriptWrappables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase master Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..6de1dd6e7b13710cff333674d905ae0974827a83
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h
@@ -0,0 +1,75 @@
+// Copyright 2016 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 ScriptWrappableVisitor_h
+#define ScriptWrappableVisitor_h
+
+#include "platform/heap/HeapAllocator.h"
+#include <v8.h>
+#include <vector>
+
+
+namespace blink {
+
+class HeapObjectHeader;
+class ScriptWrappable;
+class ScriptWrappableHeapTracer;
+class NodeRareData;
+
+#define DECLARE_VIRTUAL_TRACE_WRAPPABLE() \
+ virtual void traceWrappable(const ScriptWrappableVisitor*) const
+
+#define DECLARE_VIRTUAL_TRACE_WRAPPABLE_CHILDREN() \
+ virtual void traceWrappableChildren(const ScriptWrappableVisitor*) const
+
+#define DECLARE_NONVIRTUAL_TRACE_WRAPPABLE() \
+ void traceWrappable(const ScriptWrappableVisitor*) const
+
+#define DECLARE_NONVIRTUAL_TRACE_WRAPPABLE_CHILDREN() \
+ void traceWrappableChildren(const ScriptWrappableVisitor*) const
+
+
+#define DECLARE_TRACE_WRAPPABLE() \
+ DECLARE_VIRTUAL_TRACE_WRAPPABLE(); \
+ DECLARE_VIRTUAL_TRACE_WRAPPABLE_CHILDREN()
+
+#define DEFINE_TRACE_WRAPPABLE(T) \
+ void T::traceWrappable(const ScriptWrappableVisitor* visitor) const \
+ { \
+ if (visitor->isVisited(this)) \
+ return; \
+ visitor->visit(this); \
+ traceWrappableChildren(visitor); \
+ }
+
+#define DECLARE_TRACE_WRAPPABLE_CHILDREN() \
+ void traceWrappableChildren(const ScriptWrappableVisitor*) const override;
+
+#define DEFINE_TRACE_WRAPPABLE_CHILDREN(T) \
+ void T::traceWrappableChildren(const ScriptWrappableVisitor* visitor) const
+
+/**
+ * Visitor able to trace through the script wrappable references. It is used
+ * by the ScriptWrappableHeapTracer during V8 garbage collection.
+ */
+class ScriptWrappableVisitor {
haraken 2016/04/13 00:44:01 It's a bit confusing to mix "trace", "visit", "acc
Marcel Hlopko 2016/04/13 08:46:09 Done
+public:
+ ScriptWrappableVisitor(v8::Isolate* isolate, ScriptWrappableHeapTracer* tracer)
+ : m_isolate(isolate)
+ , m_tracer(tracer)
+ {};
+ void accept(const ScriptWrappable* wrappable) const;
+ void accept(const ScriptWrappable& wrappable) const;
+ void accept(const NodeRareData* rareData) const;
+ bool isVisited(const void* garbageCollected) const;
+ void visit(const ScriptWrappable* scriptWrappable) const;
+ void visit(const void* garbageCollected) const;
+ void visitHandle(v8::Persistent<v8::Object>& handle) const;
+private:
+ v8::Isolate* m_isolate;
+ ScriptWrappableHeapTracer* m_tracer;
+};
+
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698