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

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

Issue 2044023002: Maintain wrapper tracing deque in ScriptWrappableVisitor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments Created 4 years, 6 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
index 15ab14a313fbc9caa1cf708889fc082353710db9..7d6a6b28294800f4ff24f8f9aea9e7316cc25287 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h
@@ -6,15 +6,16 @@
#define ScriptWrappableVisitor_h
#include "bindings/core/v8/ScopedPersistent.h"
+#include "bindings/core/v8/ScriptWrappable.h"
#include "core/CoreExport.h"
#include "platform/heap/WrapperVisitor.h"
+#include "wtf/Deque.h"
#include "wtf/Vector.h"
#include <v8.h>
namespace blink {
-class ScriptWrappable;
class HeapObjectHeader;
template<typename T> class Member;
@@ -23,8 +24,9 @@ template<typename T> class Member;
* references. It is used during V8 garbage collection. When this visitor is
* set to the v8::Isolate as its embedder heap tracer, V8 will call it during
* its garbage collection. At the beginning, it will call TracePrologue, then
- * repeatedly (as v8 discovers more wrappers) it will call TraceWrappersFrom,
- * and at the end it will call TraceEpilogue.
+ * repeatedly it will call AdvanceTracing, and at the end it will call
+ * TraceEpilogue. Everytime V8 finds new wrappers, it will let the tracer know
+ * using RegisterV8References.
*/
class CORE_EXPORT ScriptWrappableVisitor : public WrapperVisitor, public v8::EmbedderHeapTracer {
public:
@@ -45,11 +47,10 @@ public:
}
void TracePrologue() override;
- void TraceWrappersFrom(const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers) override;
+ void RegisterV8References(const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers) override;
+ bool AdvanceTracing(double deadlineInMs, v8::EmbedderHeapTracer::AdvanceTracingActions) override;
void TraceEpilogue() override;
- void traceWrappersFrom(const ScriptWrappable*) const;
-
template <typename T>
void markWrapper(const v8::Persistent<T>* handle) const
{
@@ -71,9 +72,16 @@ private:
bool markWrapperHeader(HeapObjectHeader*) const;
bool markWrapperHeader(const ScriptWrappable*) const override;
bool markWrapperHeader(const void* garbageCollected) const override;
- inline void traceWrappersFrom(std::pair<void*, void*> internalFields);
bool m_tracingInProgress = false;
/**
+ * Collection of ScriptWrappables we need to trace from. We assume it safe
+ * to hold on to the raw pointers because:
+ * * oilpan object cannot move
+ * * for the oilpan gc, this deque is part of the root set, so objects
+ * in the deque will not die
+ */
+ mutable WTF::Deque<const ScriptWrappable*> m_markingDeque;
+ /**
* Collection of headers we need to unmark after the tracing finished. We
* assume it is safe to hold on to the headers because:
* * oilpan objects cannot move

Powered by Google App Engine
This is Rietveld 408576698