Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 std::make_pair(new SuspendableObjectsInfo(m_foundV8Wrappers.size()), | 196 std::make_pair(new SuspendableObjectsInfo(m_foundV8Wrappers.size()), |
| 197 std::move(m_foundV8Wrappers))); | 197 std::move(m_foundV8Wrappers))); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Trace through the blink heap to find all V8 wrappers reachable from any | 200 // Trace through the blink heap to find all V8 wrappers reachable from any |
| 201 // of the collected roots. Also collect retainer edges on the way. | 201 // of the collected roots. Also collect retainer edges on the way. |
| 202 void traceV8Roots() { | 202 void traceV8Roots() { |
| 203 for (auto& groupPair : m_nodesRequiringTracing) { | 203 for (auto& groupPair : m_nodesRequiringTracing) { |
| 204 v8::HeapProfiler::RetainerChildren groupChildren; | 204 v8::HeapProfiler::RetainerChildren groupChildren; |
| 205 for (auto& node : groupPair.second) { | 205 for (auto& node : groupPair.second) { |
| 206 auto wrappers = findV8WrappersDirectlyReachableFrom(node); | 206 // Ignore the actual wrappers reachable as we only want to create |
| 207 groupChildren.insert(wrappers.begin(), wrappers.end()); | 207 // groups of DOM nodes. The method is still used to collect edges |
| 208 // though. | |
| 209 findV8WrappersDirectlyReachableFrom(node); | |
|
haraken
2017/01/24 21:04:58
Now, isn't it useless to call findV8WrappersDirect
| |
| 210 groupChildren.insert(persistentForWrappable(node)); | |
| 208 } | 211 } |
| 209 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first), | 212 m_groups.push_back(std::make_pair(new RetainedDOMInfo(groupPair.first), |
| 210 std::move(groupChildren))); | 213 std::move(groupChildren))); |
| 211 } | 214 } |
| 212 } | 215 } |
| 213 | 216 |
| 214 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); } | 217 v8::HeapProfiler::RetainerEdges edges() { return std::move(m_edges); } |
| 215 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); } | 218 v8::HeapProfiler::RetainerGroups groups() { return std::move(m_groups); } |
| 216 | 219 |
| 217 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override { | 220 void markWrapper(const v8::PersistentBase<v8::Value>* value) const override { |
| 218 if (m_currentParent && m_currentParent != value) | 221 if (m_currentParent && m_currentParent != value) |
| 219 m_edges.push_back(std::make_pair(m_currentParent, value)); | 222 m_edges.push_back(std::make_pair(m_currentParent, value)); |
| 220 m_foundV8Wrappers.insert(value); | 223 m_foundV8Wrappers.insert(value); |
| 221 } | 224 } |
| 222 | 225 |
| 223 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override { | 226 void dispatchTraceWrappers(const TraceWrapperBase* traceable) const override { |
| 224 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() || | 227 if (!m_onlyTraceSingleLevel || !traceable->isScriptWrappable() || |
| 225 !reinterpret_cast<const ScriptWrappable*>(traceable) | 228 !reinterpret_cast<const ScriptWrappable*>(traceable) |
| 226 ->containsWrapper() || | 229 ->containsWrapper() || |
| 227 !m_firstScriptWrappableTraced) { | 230 !m_firstScriptWrappableTraced) { |
| 228 m_firstScriptWrappableTraced = true; | 231 m_firstScriptWrappableTraced = true; |
| 229 traceable->traceWrappers(this); | 232 traceable->traceWrappers(this); |
| 230 } | 233 } |
| 231 } | 234 } |
| 232 | 235 |
| 233 private: | 236 private: |
| 237 inline v8::PersistentBase<v8::Value>* persistentForWrappable( | |
| 238 ScriptWrappable* wrappable) { | |
| 239 return &v8::Persistent<v8::Value>::Cast(*wrappable->rawMainWorldWrapper()); | |
| 240 } | |
| 241 | |
| 234 v8::HeapProfiler::RetainerChildren findV8WrappersDirectlyReachableFrom( | 242 v8::HeapProfiler::RetainerChildren findV8WrappersDirectlyReachableFrom( |
| 235 Node* traceable) { | 243 Node* traceable) { |
| 236 CHECK(m_foundV8Wrappers.empty()); | 244 CHECK(m_foundV8Wrappers.empty()); |
| 237 WTF::AutoReset<bool> scope(&m_onlyTraceSingleLevel, true); | 245 WTF::AutoReset<bool> scope(&m_onlyTraceSingleLevel, true); |
| 238 m_firstScriptWrappableTraced = false; | 246 m_firstScriptWrappableTraced = false; |
| 239 m_currentParent = | 247 m_currentParent = persistentForWrappable(traceable); |
| 240 &v8::Persistent<v8::Value>::Cast(*traceable->rawMainWorldWrapper()); | |
| 241 | 248 |
| 242 TracePrologue(); | 249 TracePrologue(); |
| 243 traceable->wrapperTypeInfo()->traceWrappers(this, traceable); | 250 traceable->wrapperTypeInfo()->traceWrappers(this, traceable); |
| 244 AdvanceTracing( | 251 AdvanceTracing( |
| 245 0, | 252 0, |
| 246 v8::EmbedderHeapTracer::AdvanceTracingActions( | 253 v8::EmbedderHeapTracer::AdvanceTracingActions( |
| 247 v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); | 254 v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); |
| 248 // Abort instead of Epilogue as we want to finish synchronously. | 255 // Abort instead of Epilogue as we want to finish synchronously. |
| 249 AbortTracing(); | 256 AbortTracing(); |
| 250 | 257 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 double startTime = WTF::currentTimeMS(); | 688 double startTime = WTF::currentTimeMS(); |
| 682 v8::HandleScope scope(isolate); | 689 v8::HandleScope scope(isolate); |
| 683 PendingActivityVisitor visitor(isolate, executionContext); | 690 PendingActivityVisitor visitor(isolate, executionContext); |
| 684 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 691 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
| 685 scanPendingActivityHistogram.count( | 692 scanPendingActivityHistogram.count( |
| 686 static_cast<int>(WTF::currentTimeMS() - startTime)); | 693 static_cast<int>(WTF::currentTimeMS() - startTime)); |
| 687 return visitor.pendingActivityFound(); | 694 return visitor.pendingActivityFound(); |
| 688 } | 695 } |
| 689 | 696 |
| 690 } // namespace blink | 697 } // namespace blink |
| OLD | NEW |