Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7eff89c3fd2faab5967f91cc5d5976c6eeb93297 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.cpp |
| @@ -0,0 +1,87 @@ |
| +// 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 "ScriptWrappableHeapTracer.h" |
| + |
| +#include "bindings/core/v8/ActiveScriptWrappable.h" |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "bindings/core/v8/ScriptWrappableVisitor.h" |
| +#include "bindings/core/v8/WrapperTypeInfo.h" |
| +#include "platform/heap/HeapPage.h" |
| + |
| +namespace blink { |
| + |
| +ScriptWrappableHeapTracer::~ScriptWrappableHeapTracer() |
| +{ |
| +} |
| + |
| +void ScriptWrappableHeapTracer::TraceRoots(v8::Isolate* isolate) |
| +{ |
| + m_tracingInProgress = true; |
| + ScriptWrappableVisitor visitor(isolate, this); |
| + ActiveScriptWrappable::traceActiveWrappable(&visitor); |
| +} |
| + |
| +void ScriptWrappableHeapTracer::AddHeaderToUnmark(HeapObjectHeader* header) |
| +{ |
| + m_headersToUnmark.push_back(header); |
| +} |
| + |
| +void ScriptWrappableHeapTracer::ClearTracingMarks(v8::Isolate* isolate) |
| +{ |
| + for (auto header : m_headersToUnmark) |
| + header->unmarkDOM(); |
| + |
| + m_headersToUnmark.clear(); |
| + m_tracingInProgress = false; |
| +} |
| + |
| +void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, const std::vector<std::pair<void*, void*>>& hiddenFieldsOfPotentialWrappers) |
|
haraken
2016/04/13 12:26:22
Would you help me understand what this method does
Marcel Hlopko
2016/04/14 16:39:08
When marking, V8 detects all (possible) wrappers a
|
| +{ |
| + ASSERT(m_tracingInProgress); |
| + for (auto pair : hiddenFieldsOfPotentialWrappers) { |
| + TraceWrappableFrom(isolate, pair); |
| + } |
| +} |
| + |
| + |
| +void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, std::pair<void*, void*> hiddenFields) |
|
haraken
2016/04/13 12:26:22
What is the hidden fields?
Marcel Hlopko
2016/04/14 16:39:08
Renamed to internal fields to be consistent with t
|
| +{ |
| + if (!hiddenFields.first) |
| + return; |
| + if (reinterpret_cast<intptr_t>(hiddenFields.first) % 2 == 1) |
|
haraken
2016/04/13 12:26:22
What is this checking?
Marcel Hlopko
2016/04/14 16:39:08
That the pointer we got is a valid oilpan pointer,
|
| + ASSERT_NOT_REACHED(); |
| + if (reinterpret_cast<WrapperTypeInfo*>(hiddenFields.first)->ginEmbedder |
| + != gin::GinEmbedder::kEmbedderBlink) |
| + return; |
| + |
| + ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>( |
| + hiddenFields.second); |
| + uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId; |
| + if (classId != WrapperTypeInfo::NodeClassId |
| + && classId != WrapperTypeInfo::ObjectClassId) { |
| + ASSERT_NOT_REACHED(); |
| + return; |
| + } |
| + |
| + ScriptWrappableVisitor visitor(isolate, this); |
| + visitor.trace(scriptWrappable); |
| +} |
| + |
| +void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, v8::Persistent<v8::Object>* handle) |
| +{ |
| + ScriptWrappable* scriptWrappable = toScriptWrappable(*handle); |
| + uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId; |
| + if (classId != WrapperTypeInfo::NodeClassId |
| + && classId != WrapperTypeInfo::ObjectClassId) { |
| + ASSERT_NOT_REACHED(); |
| + return; |
| + } |
| + |
| + ScriptWrappableVisitor visitor(isolate, this); |
| + visitor.trace(scriptWrappable); |
| +} |
| + |
| +} |
| + |