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

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

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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 81e5e4e8064bb8f6407c6ff0bc92382ef2daddf6..42dcbf464143384d8dc40579e1fbf0da217374fe 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp
@@ -6,7 +6,6 @@
#include "bindings/core/v8/ActiveScriptWrappable.h"
#include "bindings/core/v8/DOMWrapperWorld.h"
-#include "bindings/core/v8/ScriptWrappable.h"
#include "bindings/core/v8/WrapperTypeInfo.h"
#include "core/dom/DocumentStyleSheetCollection.h"
#include "core/dom/ElementRareData.h"
@@ -39,27 +38,37 @@ void ScriptWrappableVisitor::TraceEpilogue()
m_tracingInProgress = false;
}
-void ScriptWrappableVisitor::TraceWrappersFrom(const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers)
+void ScriptWrappableVisitor::RegisterV8References(const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers)
{
- ASSERT(m_tracingInProgress);
// TODO(hlopko): Visit the vector in the V8 instead of passing it over if
// there is no performance impact
for (auto pair : internalFieldsOfPotentialWrappers) {
- traceWrappersFrom(pair);
+ WrapperTypeInfo* wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>(pair.first);
+ if (wrapperTypeInfo->ginEmbedder != gin::GinEmbedder::kEmbedderBlink)
+ continue;
+
+ ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>(pair.second);
+ DCHECK(wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::NodeClassId
+ || wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::ObjectClassId);
+
+ m_markingDeque.append(scriptWrappable);
}
}
-void ScriptWrappableVisitor::traceWrappersFrom(std::pair<void*, void*> internalFields)
+bool ScriptWrappableVisitor::AdvanceTracing(double deadlineInMs, v8::EmbedderHeapTracer::AdvanceTracingActions actions)
{
- WrapperTypeInfo* wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>(internalFields.first);
- if (wrapperTypeInfo->ginEmbedder != gin::GinEmbedder::kEmbedderBlink)
- return;
-
- ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>(internalFields.second);
- ASSERT(wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::NodeClassId
- || wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::ObjectClassId);
-
- scriptWrappable->traceWrappers(this);
+ DCHECK(m_tracingInProgress);
+ while (actions.force_completion == v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION
+ || WTF::monotonicallyIncreasingTimeMS() < deadlineInMs) {
+ if (m_markingDeque.isEmpty()) {
+ return false;
+ }
+
+ const ScriptWrappable* scriptWrappable = m_markingDeque.takeFirst();
+ markWrapperHeader(scriptWrappable);
+ scriptWrappable->traceWrappers(this);
+ }
+ return true;
}
bool ScriptWrappableVisitor::markWrapperHeader(HeapObjectHeader* header) const
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698