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 42dcbf464143384d8dc40579e1fbf0da217374fe..50515091926724267e739f8b3c54b8f82de652fc 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp |
@@ -38,20 +38,34 @@ void ScriptWrappableVisitor::TraceEpilogue() |
m_tracingInProgress = false; |
} |
+void ScriptWrappableVisitor::RegisterV8Reference(const std::pair<void*, void*>& internalFields) |
+{ |
+ if (!m_tracingInProgress) { |
+ return; |
+ } |
+ |
+ WrapperTypeInfo* wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>(internalFields.first); |
+ if (wrapperTypeInfo->ginEmbedder != gin::GinEmbedder::kEmbedderBlink) { |
+ return; |
+ } |
+ |
+ ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>(internalFields.second); |
+ DCHECK(wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::NodeClassId |
+ || wrapperTypeInfo->wrapperClassId == WrapperTypeInfo::ObjectClassId); |
+ |
+ if (wrapperTypeInfo->getHeader(scriptWrappable)->isWrapperHeaderMarked()) { |
+ return; |
+ } |
+ |
+ m_markingDeque.append(scriptWrappable); |
+} |
+ |
void ScriptWrappableVisitor::RegisterV8References(const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers) |
{ |
// TODO(hlopko): Visit the vector in the V8 instead of passing it over if |
// there is no performance impact |
- for (auto pair : internalFieldsOfPotentialWrappers) { |
- 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); |
+ for (auto& pair : internalFieldsOfPotentialWrappers) { |
+ RegisterV8Reference(pair); |
} |
} |
@@ -124,4 +138,20 @@ WRAPPER_VISITOR_SPECIAL_CLASSES(DEFINE_DISPATCH_TRACE_WRAPPERS); |
#undef DEFINE_DISPATCH_TRACE_WRAPPERS |
+void ScriptWrappableVisitor::traceMarkingDeque(Visitor* visitor) |
+{ |
+ for (auto& scriptWrappable : m_markingDeque) { |
+ scriptWrappable->wrapperTypeInfo() |
+ ->trace(visitor, const_cast<ScriptWrappable*>(scriptWrappable)); |
+ } |
+} |
+ |
+void ScriptWrappableVisitor::traceWrappersMarkingDequeTracing(v8::Isolate* isolate, Visitor* visitor) |
haraken
2016/06/08 08:56:07
traceWrappersInMarkingDeque
|
+{ |
+ ScriptWrappableVisitor* scriptWrappableVisitor = V8PerIsolateData::from(isolate)->scriptWrappableVisitor(); |
+ if (scriptWrappableVisitor) { |
+ scriptWrappableVisitor->traceMarkingDeque(visitor); |
+ } |
+} |
+ |
} // namespace blink |