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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 , m_liveRootGroupIdSet(false) | 248 , m_liveRootGroupIdSet(false) |
| 249 , m_constructRetainedObjectInfos(constructRetainedObjectInfos) | 249 , m_constructRetainedObjectInfos(constructRetainedObjectInfos) |
| 250 { | 250 { |
| 251 } | 251 } |
| 252 | 252 |
| 253 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_ t classId) override | 253 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_ t classId) override |
| 254 { | 254 { |
| 255 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) | 255 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) |
| 256 return; | 256 return; |
| 257 | 257 |
| 258 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); | |
| 259 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | |
| 260 | |
| 261 if (value->IsIndependent()) | 258 if (value->IsIndependent()) |
| 262 return; | 259 return; |
| 263 | 260 |
| 264 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); | 261 v8::Persistent<v8::Object>& persistentWrapper = v8::Persistent<v8::Objec t>::Cast(*value); |
| 262 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, pe rsistentWrapper); | |
| 263 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | |
| 265 | 264 |
| 266 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(wrapper); | 265 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(wrapper); |
| 266 | |
| 267 ActiveDOMObject* activeDOMObject = wrapperTypeInfo->toActiveDOMObject(wr apper); | |
| 267 if (activeDOMObject && activeDOMObject->hasPendingActivity()) { | 268 if (activeDOMObject && activeDOMObject->hasPendingActivity()) { |
| 268 m_isolate->SetObjectGroupId(*value, liveRootId()); | 269 m_isolate->SetObjectGroupId(*value, liveRootId()); |
| 269 ++m_domObjectsWithPendingActivity; | 270 ++m_domObjectsWithPendingActivity; |
| 270 } | 271 } |
| 271 | 272 |
| 272 if (classId == WrapperTypeInfo::NodeClassId) { | 273 if (classId == WrapperTypeInfo::NodeClassId) { |
| 273 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); | 274 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); |
| 274 Node* node = V8Node::toImpl(wrapper); | 275 Node* node = V8Node::toImpl(wrapper); |
| 275 if (node->hasEventListeners()) | 276 if (node->hasEventListeners()) |
| 276 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); | 277 addReferencesForNodeWithEventListeners(m_isolate, node, persiste ntWrapper); |
| 277 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); | 278 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); |
| 278 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); | 279 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); |
| 279 if (m_constructRetainedObjectInfos) | 280 if (m_constructRetainedObjectInfos) |
| 280 m_groupsWhichNeedRetainerInfo.append(root); | 281 m_groupsWhichNeedRetainerInfo.append(root); |
| 281 } else if (classId == WrapperTypeInfo::ObjectClassId) { | 282 } else if (classId == WrapperTypeInfo::ObjectClassId) { |
| 282 type->visitDOMWrapper(m_isolate, toScriptWrappable(wrapper), v8::Per sistent<v8::Object>::Cast(*value)); | 283 m_wrappersToBeVisited.append(value); |
| 283 } else { | 284 } else { |
| 284 ASSERT_NOT_REACHED(); | 285 ASSERT_NOT_REACHED(); |
| 285 } | 286 } |
| 286 } | 287 } |
| 287 | 288 |
| 288 void notifyFinished() | 289 void notifyFinished() |
| 289 { | 290 { |
| 291 for (auto& value : m_wrappersToBeVisited) { | |
| 292 ASSERT(!value->IsIndependent()); | |
|
haraken
2015/06/20 09:29:49
This CL is not correct. The access to |value| caus
jochen (gone - plz use gerrit)
2015/06/22 08:45:49
what about unwrapping the handle and collecting Sc
| |
| 293 v8::Persistent<v8::Object>& persistentWrapper = v8::Persistent<v8::O bject>::Cast(*value); | |
| 294 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate , persistentWrapper); | |
| 295 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(wrapper); | |
| 296 wrapperTypeInfo->visitDOMWrapper(m_isolate, toScriptWrappable(wrappe r), persistentWrapper); | |
|
jochen (gone - plz use gerrit)
2015/06/22 08:45:49
can this create new Persistent<> handles that need
| |
| 297 } | |
| 298 | |
| 290 if (!m_constructRetainedObjectInfos) | 299 if (!m_constructRetainedObjectInfos) |
| 291 return; | 300 return; |
| 292 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end()); | 301 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end()); |
| 293 Node* alreadyAdded = 0; | 302 Node* alreadyAdded = 0; |
| 294 v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); | 303 v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); |
| 295 for (size_t i = 0; i < m_groupsWhichNeedRetainerInfo.size(); ++i) { | 304 for (size_t i = 0; i < m_groupsWhichNeedRetainerInfo.size(); ++i) { |
| 296 Node* root = m_groupsWhichNeedRetainerInfo[i]; | 305 Node* root = m_groupsWhichNeedRetainerInfo[i]; |
| 297 if (root != alreadyAdded) { | 306 if (root != alreadyAdded) { |
| 298 profiler->SetRetainedObjectInfo(v8::UniqueId(reinterpret_cast<in tptr_t>(root)), new RetainedDOMInfo(root)); | 307 profiler->SetRetainedObjectInfo(v8::UniqueId(reinterpret_cast<in tptr_t>(root)), new RetainedDOMInfo(root)); |
| 299 alreadyAdded = root; | 308 alreadyAdded = root; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 312 if (!m_liveRootGroupIdSet) { | 321 if (!m_liveRootGroupIdSet) { |
| 313 m_isolate->SetObjectGroupId(liveRoot, id); | 322 m_isolate->SetObjectGroupId(liveRoot, id); |
| 314 m_liveRootGroupIdSet = true; | 323 m_liveRootGroupIdSet = true; |
| 315 ++m_domObjectsWithPendingActivity; | 324 ++m_domObjectsWithPendingActivity; |
| 316 } | 325 } |
| 317 return id; | 326 return id; |
| 318 } | 327 } |
| 319 | 328 |
| 320 v8::Isolate* m_isolate; | 329 v8::Isolate* m_isolate; |
| 321 WillBePersistentHeapVector<RawPtrWillBeMember<Node>> m_groupsWhichNeedRetain erInfo; | 330 WillBePersistentHeapVector<RawPtrWillBeMember<Node>> m_groupsWhichNeedRetain erInfo; |
| 331 Vector<v8::Persistent<v8::Value>*> m_wrappersToBeVisited; | |
| 322 int m_domObjectsWithPendingActivity; | 332 int m_domObjectsWithPendingActivity; |
| 323 bool m_liveRootGroupIdSet; | 333 bool m_liveRootGroupIdSet; |
| 324 bool m_constructRetainedObjectInfos; | 334 bool m_constructRetainedObjectInfos; |
| 325 }; | 335 }; |
| 326 | 336 |
| 327 static unsigned long long usedHeapSize(v8::Isolate* isolate) | 337 static unsigned long long usedHeapSize(v8::Isolate* isolate) |
| 328 { | 338 { |
| 329 v8::HeapStatistics heapStatistics; | 339 v8::HeapStatistics heapStatistics; |
| 330 isolate->GetHeapStatistics(&heapStatistics); | 340 isolate->GetHeapStatistics(&heapStatistics); |
| 331 return heapStatistics.used_heap_size(); | 341 return heapStatistics.used_heap_size(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 Visitor* m_visitor; | 511 Visitor* m_visitor; |
| 502 }; | 512 }; |
| 503 | 513 |
| 504 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) | 514 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) |
| 505 { | 515 { |
| 506 DOMWrapperTracer tracer(visitor); | 516 DOMWrapperTracer tracer(visitor); |
| 507 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); | 517 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); |
| 508 } | 518 } |
| 509 | 519 |
| 510 } // namespace blink | 520 } // namespace blink |
| OLD | NEW |