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

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

Issue 1876383003: Introduce infrastructure for tracing ScriptWrappables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use newer v8 api 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.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7e2307abd6e0ecf98f9d7ad60649cadc3ad252ac
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp
@@ -0,0 +1,48 @@
+// 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.
+
+#include "bindings/core/v8/ScriptWrappableVisitor.h"
+
+#include "bindings/core/v8/ScriptWrappable.h"
+#include "bindings/core/v8/ScriptWrappableHeapTracer.h"
+#include "core/dom/NodeRareData.h"
+#include "core/events/EventListenerMap.h"
+#include "core/events/EventTarget.h"
+#include "platform/heap/HeapPage.h"
+
+namespace blink {
+
+bool ScriptWrappableVisitor::isHeaderMarked(const void* garbageCollected) const
haraken 2016/04/19 04:58:31 If you think that the tracing performance really m
Marcel Hlopko 2016/04/19 12:40:29 Done for private methods. I'll measure the impact
haraken 2016/04/19 12:51:05 Sounds like a plan :)
+{
+ return HeapObjectHeader::fromPayload(garbageCollected)->isWrapperMarked();
+}
+
+void ScriptWrappableVisitor::markHeader(const ScriptWrappable* scriptWrappable) const
+{
+ markHeader(static_cast<const void*>(scriptWrappable));
+
+ ScriptWrappableHeapTracer::markWrappersInAllWorlds(scriptWrappable, m_isolate);
+}
+
+void ScriptWrappableVisitor::markHeader(const void* garbageCollected) const
+{
+ HeapObjectHeader* header = HeapObjectHeader::fromPayload(garbageCollected);
+ header->markWrapper();
haraken 2016/04/19 04:58:31 It looks a bit confusing that markHeader calls mar
Marcel Hlopko 2016/04/19 12:40:29 Done.
+ m_tracer->AddHeaderToUnmark(header);
+}
+
+void ScriptWrappableVisitor::traceWrappers(const ScriptWrappable* wrappable) const
+{
+ if (wrappable && !isHeaderMarked(wrappable)) {
+ markHeader(wrappable);
+ wrappable->traceWrappers(this);
+ }
+}
+
+void ScriptWrappableVisitor::traceWrappers(const ScriptWrappable& wrappable) const
+{
+ traceWrappers(&wrappable);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698