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

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

Issue 2673693003: [wrapper-tracing] Don't call into V8 during heap snapshot creation (Closed)
Patch Set: Comment Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 v8::Isolate* m_isolate; 128 v8::Isolate* m_isolate;
129 }; 129 };
130 130
131 class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor, 131 class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor,
132 public v8::PersistentHandleVisitor { 132 public v8::PersistentHandleVisitor {
133 public: 133 public:
134 explicit HeapSnaphotWrapperVisitor(v8::Isolate* isolate) 134 explicit HeapSnaphotWrapperVisitor(v8::Isolate* isolate)
135 : ScriptWrappableVisitor(isolate), 135 : ScriptWrappableVisitor(isolate),
136 m_currentParent(nullptr), 136 m_currentParent(nullptr),
137 m_onlyTraceSingleLevel(false), 137 m_onlyTraceSingleLevel(false),
138 m_firstScriptWrappableTraced(false) {} 138 m_firstScriptWrappableTraced(false) {}
haraken 2017/02/03 07:46:12 Shall we add DCHECK(isMainThread()) (for a documen
Michael Lippautz 2017/02/03 15:51:31 Good idea, done.
139 139
140 // Collect interesting V8 roots for the heap snapshot. Currently these are 140 // Collect interesting V8 roots for the heap snapshot. Currently these are
141 // DOM nodes. 141 // DOM nodes.
142 void collectV8Roots() { m_isolate->VisitHandlesWithClassIds(this); } 142 void collectV8Roots() { m_isolate->VisitHandlesWithClassIds(this); }
143 143
144 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, 144 void VisitPersistentHandle(v8::Persistent<v8::Value>* value,
145 uint16_t classId) override { 145 uint16_t classId) override {
146 if (classId != WrapperTypeInfo::NodeClassId) 146 if (classId != WrapperTypeInfo::NodeClassId)
147 return; 147 return;
148 148
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 groupChildren.insert(persistentForWrappable(node)); 188 groupChildren.insert(persistentForWrappable(node));
189 } 189 }
190 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first), 190 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first),
191 std::move(groupChildren))); 191 std::move(groupChildren)));
192 } 192 }
193 } 193 }
194 194
195 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); } 195 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); }
196 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); } 196 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); }
197 197
198 void markWrappersInAllWorlds(
199 const ScriptWrappable* traceable) const override {
200 // Only mark the main thread wrapper as we cannot properly intercept
201 // DOMWrapperMap::markWrapper. This means that edges from the isolated
202 // worlds are missing in the snapshot.
203 traceable->markWrapper(this);
204 }
205
198 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override { 206 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override {
199 if (m_currentParent && m_currentParent != value) 207 if (m_currentParent && m_currentParent != value)
200 m_edges.push_back(std::make_pair(m_currentParent, value)); 208 m_edges.push_back(std::make_pair(m_currentParent, value));
201 m_foundV8Wrappers.insert(value); 209 m_foundV8Wrappers.insert(value);
202 } 210 }
203 211
204 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override { 212 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override {
205 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() || 213 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() ||
206 !reinterpret_cast<const ScriptWrappable*>(traceable) 214 !reinterpret_cast<const ScriptWrappable*>(traceable)
207 ->containsWrapper() || 215 ->containsWrapper() ||
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 double startTime = WTF::currentTimeMS(); 545 double startTime = WTF::currentTimeMS();
538 v8::HandleScope scope(isolate); 546 v8::HandleScope scope(isolate);
539 PendingActivityVisitor visitor(isolate, executionContext); 547 PendingActivityVisitor visitor(isolate, executionContext);
540 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 548 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
541 scanPendingActivityHistogram.count( 549 scanPendingActivityHistogram.count(
542 static_cast<int>(WTF::currentTimeMS() - startTime)); 550 static_cast<int>(WTF::currentTimeMS() - startTime));
543 return visitor.pendingActivityFound(); 551 return visitor.pendingActivityFound();
544 } 552 }
545 553
546 } // namespace blink 554 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698