Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ScriptWrappableHeapTracer.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ActiveScriptWrappable.h" | |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | |
| 9 #include "bindings/core/v8/ScriptWrappableVisitor.h" | |
| 10 #include "bindings/core/v8/WrapperTypeInfo.h" | |
| 11 #include "platform/heap/HeapPage.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 ScriptWrappableHeapTracer::~ScriptWrappableHeapTracer() | |
| 16 { | |
| 17 } | |
| 18 | |
| 19 void ScriptWrappableHeapTracer::TraceRoots(v8::Isolate* isolate) | |
| 20 { | |
| 21 m_tracingInProgress = true; | |
| 22 ScriptWrappableVisitor visitor(isolate, this); | |
| 23 ActiveScriptWrappable::traceActiveWrappable(&visitor); | |
| 24 } | |
| 25 | |
| 26 void ScriptWrappableHeapTracer::AddHeaderToUnmark(HeapObjectHeader* header) | |
| 27 { | |
| 28 m_headersToUnmark.push_back(header); | |
| 29 } | |
| 30 | |
| 31 void ScriptWrappableHeapTracer::ClearTracingMarks(v8::Isolate* isolate) | |
| 32 { | |
| 33 for (auto header : m_headersToUnmark) | |
| 34 header->unmarkDOM(); | |
| 35 | |
| 36 m_headersToUnmark.clear(); | |
| 37 m_tracingInProgress = false; | |
| 38 } | |
| 39 | |
| 40 void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, const s td::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
| |
| 41 { | |
| 42 ASSERT(m_tracingInProgress); | |
| 43 for (auto pair : hiddenFieldsOfPotentialWrappers) { | |
| 44 TraceWrappableFrom(isolate, pair); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 | |
| 49 void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, std::pa ir<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
| |
| 50 { | |
| 51 if (!hiddenFields.first) | |
| 52 return; | |
| 53 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,
| |
| 54 ASSERT_NOT_REACHED(); | |
| 55 if (reinterpret_cast<WrapperTypeInfo*>(hiddenFields.first)->ginEmbedder | |
| 56 != gin::GinEmbedder::kEmbedderBlink) | |
| 57 return; | |
| 58 | |
| 59 ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>( | |
| 60 hiddenFields.second); | |
| 61 uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId; | |
| 62 if (classId != WrapperTypeInfo::NodeClassId | |
| 63 && classId != WrapperTypeInfo::ObjectClassId) { | |
| 64 ASSERT_NOT_REACHED(); | |
| 65 return; | |
| 66 } | |
| 67 | |
| 68 ScriptWrappableVisitor visitor(isolate, this); | |
| 69 visitor.trace(scriptWrappable); | |
| 70 } | |
| 71 | |
| 72 void ScriptWrappableHeapTracer::TraceWrappableFrom(v8::Isolate* isolate, v8::Per sistent<v8::Object>* handle) | |
| 73 { | |
| 74 ScriptWrappable* scriptWrappable = toScriptWrappable(*handle); | |
| 75 uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId; | |
| 76 if (classId != WrapperTypeInfo::NodeClassId | |
| 77 && classId != WrapperTypeInfo::ObjectClassId) { | |
| 78 ASSERT_NOT_REACHED(); | |
| 79 return; | |
| 80 } | |
| 81 | |
| 82 ScriptWrappableVisitor visitor(isolate, this); | |
| 83 visitor.trace(scriptWrappable); | |
| 84 } | |
| 85 | |
| 86 } | |
| 87 | |
| OLD | NEW |