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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.cpp

Issue 1876383003: Introduce infrastructure for tracing ScriptWrappables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use newer v8 api Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(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 "bindings/core/v8/ScriptWrappableHeapTracer.h"
6
7 #include "bindings/core/v8/ActiveScriptWrappable.h"
8 #include "bindings/core/v8/DOMDataStore.h"
9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "bindings/core/v8/ScriptWrappableVisitor.h"
11 #include "bindings/core/v8/WrapperTypeInfo.h"
12 #include "platform/heap/HeapPage.h"
13
14 namespace blink {
15
16 ScriptWrappableHeapTracer::~ScriptWrappableHeapTracer()
17 {
18 }
19
20 void ScriptWrappableHeapTracer::TracePrologue(v8::Isolate* isolate)
21 {
22 m_tracingInProgress = true;
23 ScriptWrappableVisitor visitor(isolate, this);
24 ActiveScriptWrappable::traceActiveScriptWrappables(&visitor);
25 }
26
27 void ScriptWrappableHeapTracer::AddHeaderToUnmark(HeapObjectHeader* header)
28 {
29 m_headersToUnmark.append(header);
30 }
31
32 void ScriptWrappableHeapTracer::TraceEpilogue(v8::Isolate* isolate)
33 {
34 for (auto header : m_headersToUnmark)
35 header->unmarkWrapper();
36
37 m_headersToUnmark.clear();
38 m_tracingInProgress = false;
39 }
40
41 void ScriptWrappableHeapTracer::TraceWrappersFrom(v8::Isolate* isolate, const st d::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers)
42 {
43 ASSERT(m_tracingInProgress);
44 for (auto pair : internalFieldsOfPotentialWrappers) {
45 TraceWrappersFrom(isolate, pair);
46 }
47 }
48
49
50 void ScriptWrappableHeapTracer::TraceWrappersFrom(v8::Isolate* isolate, std::pai r<void*, void*> internalFields)
51 {
52 if (reinterpret_cast<WrapperTypeInfo*>(internalFields.first)->ginEmbedder
53 != gin::GinEmbedder::kEmbedderBlink)
54 return;
55
56 ScriptWrappable* scriptWrappable = reinterpret_cast<ScriptWrappable*>(
57 internalFields.second);
58 uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId;
59 if (classId != WrapperTypeInfo::NodeClassId
haraken 2016/04/19 04:58:31 ASSERT(classId == WrapperTypeInfo::NodeClassId ||
Marcel Hlopko 2016/04/19 12:40:29 Done.
60 && classId != WrapperTypeInfo::ObjectClassId) {
61 ASSERT_NOT_REACHED();
62 return;
63 }
64
65 ScriptWrappableVisitor visitor(isolate, this);
66 visitor.traceWrappers(scriptWrappable);
67 }
68
69 void ScriptWrappableHeapTracer::TraceWrappersFrom(v8::Isolate* isolate, v8::Pers istent<v8::Object>* handle)
haraken 2016/04/19 04:58:31 Where is this method used?
Marcel Hlopko 2016/04/19 12:40:29 Nowhere, removed.
70 {
71 ScriptWrappable* scriptWrappable = toScriptWrappable(*handle);
72 uint16_t classId = scriptWrappable->wrapperTypeInfo()->wrapperClassId;
73 if (classId != WrapperTypeInfo::NodeClassId
74 && classId != WrapperTypeInfo::ObjectClassId) {
haraken 2016/04/19 04:58:31 Ditto.
Marcel Hlopko 2016/04/19 12:40:29 Done.
75 ASSERT_NOT_REACHED();
76 return;
77 }
78
79 ScriptWrappableVisitor visitor(isolate, this);
80 visitor.traceWrappers(scriptWrappable);
81 }
82
83 void ScriptWrappableHeapTracer::markWrapper(const v8::Persistent<v8::Object>& ha ndle, v8::Isolate* isolate)
84 {
85 handle.RegisterExternalReference(isolate);
86 }
87
88 void ScriptWrappableHeapTracer::markWrappersInAllWorlds(const ScriptWrappable* s criptWrappable, v8::Isolate* isolate)
89 {
90 DOMWrapperWorld::markWrappersInAllWorlds(
91 const_cast<ScriptWrappable*>(scriptWrappable), isolate);
92 }
93
94 }
95
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698