| 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..d806f33a882e7ec628cad8741830c255ae56c44f
|
| --- /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)
|
| +{
|
| + ASSERT(m_tracingInProgress);
|
| + for (auto pair : hiddenFieldsOfPotentialWrappers) {
|
| + TraceWrappableFrom(isolate, pair);
|
| + }
|
| +}
|
| +
|
| +
|
| +void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, std::pair<void*, void*> hiddenFields)
|
| +{
|
| + if (!hiddenFields.first)
|
| + return;
|
| + if (reinterpret_cast<intptr_t>(hiddenFields.first) % 2 == 1)
|
| + 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);
|
| + scriptWrappable->traceWrappable(&visitor);
|
| +}
|
| +
|
| +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);
|
| + scriptWrappable->traceWrappable(&visitor);
|
| +}
|
| +
|
| +}
|
| +
|
|
|