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

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: Add DCHECK 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) {
139 DCHECK(isMainThread());
140 }
139 141
140 // Collect interesting V8 roots for the heap snapshot. Currently these are 142 // Collect interesting V8 roots for the heap snapshot. Currently these are
141 // DOM nodes. 143 // DOM nodes.
142 void collectV8Roots() { m_isolate->VisitHandlesWithClassIds(this); } 144 void collectV8Roots() { m_isolate->VisitHandlesWithClassIds(this); }
143 145
144 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, 146 void VisitPersistentHandle(v8::Persistent<v8::Value>* value,
145 uint16_t classId) override { 147 uint16_t classId) override {
146 if (classId != WrapperTypeInfo::NodeClassId) 148 if (classId != WrapperTypeInfo::NodeClassId)
147 return; 149 return;
148 150
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 groupChildren.insert(persistentForWrappable(node)); 190 groupChildren.insert(persistentForWrappable(node));
189 } 191 }
190 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first), 192 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first),
191 std::move(groupChildren))); 193 std::move(groupChildren)));
192 } 194 }
193 } 195 }
194 196
195 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); } 197 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); }
196 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); } 198 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); }
197 199
200 void markWrappersInAllWorlds(
201 const ScriptWrappable* traceable) const override {
202 // Only mark the main thread wrapper as we cannot properly intercept
203 // DOMWrapperMap::markWrapper. This means that edges from the isolated
204 // worlds are missing in the snapshot.
205 traceable->markWrapper(this);
206 }
207
198 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override { 208 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override {
199 if (m_currentParent && m_currentParent != value) 209 if (m_currentParent && m_currentParent != value)
200 m_edges.push_back(std::make_pair(m_currentParent, value)); 210 m_edges.push_back(std::make_pair(m_currentParent, value));
201 m_foundV8Wrappers.insert(value); 211 m_foundV8Wrappers.insert(value);
202 } 212 }
203 213
204 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override { 214 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override {
205 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() || 215 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() ||
206 !reinterpret_cast<const ScriptWrappable*>(traceable) 216 !reinterpret_cast<const ScriptWrappable*>(traceable)
207 ->containsWrapper() || 217 ->containsWrapper() ||
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 double startTime = WTF::currentTimeMS(); 547 double startTime = WTF::currentTimeMS();
538 v8::HandleScope scope(isolate); 548 v8::HandleScope scope(isolate);
539 PendingActivityVisitor visitor(isolate, executionContext); 549 PendingActivityVisitor visitor(isolate, executionContext);
540 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 550 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
541 scanPendingActivityHistogram.count( 551 scanPendingActivityHistogram.count(
542 static_cast<int>(WTF::currentTimeMS() - startTime)); 552 static_cast<int>(WTF::currentTimeMS() - startTime));
543 return visitor.pendingActivityFound(); 553 return visitor.pendingActivityFound();
544 } 554 }
545 555
546 } // namespace blink 556 } // 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