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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 private: | 147 private: |
148 v8::Isolate* m_isolate; | 148 v8::Isolate* m_isolate; |
149 }; | 149 }; |
150 | 150 |
151 class MajorGCWrapperVisitor : public v8::PersistentHandleVisitor { | 151 class MajorGCWrapperVisitor : public v8::PersistentHandleVisitor { |
152 public: | 152 public: |
153 explicit MajorGCWrapperVisitor(v8::Isolate* isolate, | 153 explicit MajorGCWrapperVisitor(v8::Isolate* isolate, |
154 bool constructRetainedObjectInfos) | 154 bool constructRetainedObjectInfos, |
155 bool constructImplicitReferenceGroups) | |
155 : m_isolate(isolate), | 156 : m_isolate(isolate), |
156 m_domObjectsWithPendingActivity(0), | 157 m_domObjectsWithPendingActivity(0), |
157 m_liveRootGroupIdSet(false), | 158 m_liveRootGroupIdSet(false), |
158 m_constructRetainedObjectInfos(constructRetainedObjectInfos) {} | 159 m_constructRetainedObjectInfos(constructRetainedObjectInfos), |
160 m_constructImplicitReferenceGroups(constructImplicitReferenceGroups) { | |
161 DCHECK(m_constructRetainedObjectInfos || | |
162 m_constructImplicitReferenceGroups); | |
163 } | |
159 | 164 |
160 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, | 165 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, |
161 uint16_t classId) override { | 166 uint16_t classId) override { |
162 if (classId != WrapperTypeInfo::NodeClassId && | 167 if (classId != WrapperTypeInfo::NodeClassId && |
163 classId != WrapperTypeInfo::ObjectClassId) | 168 classId != WrapperTypeInfo::ObjectClassId) |
164 return; | 169 return; |
165 | 170 |
166 if (value->IsIndependent()) | 171 if (value->IsIndependent()) |
167 return; | 172 return; |
168 | 173 |
(...skipping 17 matching lines...) Expand all Loading... | |
186 toExecutionContext(wrapper->CreationContext()); | 191 toExecutionContext(wrapper->CreationContext()); |
187 if (context && !context->activeDOMObjectsAreStopped()) { | 192 if (context && !context->activeDOMObjectsAreStopped()) { |
188 m_isolate->SetObjectGroupId(*value, liveRootId()); | 193 m_isolate->SetObjectGroupId(*value, liveRootId()); |
189 ++m_domObjectsWithPendingActivity; | 194 ++m_domObjectsWithPendingActivity; |
190 } | 195 } |
191 } | 196 } |
192 | 197 |
193 if (classId == WrapperTypeInfo::NodeClassId) { | 198 if (classId == WrapperTypeInfo::NodeClassId) { |
194 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); | 199 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); |
195 Node* node = V8Node::toImpl(wrapper); | 200 Node* node = V8Node::toImpl(wrapper); |
196 if (node->hasEventListeners()) | 201 if (node->hasEventListeners()) |
Michael Lippautz
2016/10/04 10:42:51
This branch should also be guarded with m_construc
Michael Lippautz
2016/10/04 11:02:36
Sorry for the confusion but if we want to stay com
| |
197 addReferencesForNodeWithEventListeners( | 202 addReferencesForNodeWithEventListeners( |
198 m_isolate, node, v8::Persistent<v8::Object>::Cast(*value)); | 203 m_isolate, node, v8::Persistent<v8::Object>::Cast(*value)); |
199 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); | 204 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); |
200 m_isolate->SetObjectGroupId( | 205 m_isolate->SetObjectGroupId( |
201 *value, v8::UniqueId(reinterpret_cast<intptr_t>(root))); | 206 *value, v8::UniqueId(reinterpret_cast<intptr_t>(root))); |
202 if (m_constructRetainedObjectInfos) | 207 if (m_constructRetainedObjectInfos) |
203 m_groupsWhichNeedRetainerInfo.append(root); | 208 m_groupsWhichNeedRetainerInfo.append(root); |
204 } else if (classId == WrapperTypeInfo::ObjectClassId) { | 209 } else if (classId == WrapperTypeInfo::ObjectClassId) { |
205 type->visitDOMWrapper(m_isolate, toScriptWrappable(wrapper), | 210 if (m_constructImplicitReferenceGroups) { |
haraken
2016/10/04 11:24:48
I'd directly use !RuntimeEnabledFeatures::traceWra
Michael Lippautz
2016/10/04 11:31:02
Done.
| |
206 v8::Persistent<v8::Object>::Cast(*value)); | 211 type->visitDOMWrapper(m_isolate, toScriptWrappable(wrapper), |
212 v8::Persistent<v8::Object>::Cast(*value)); | |
213 } | |
207 } else { | 214 } else { |
208 NOTREACHED(); | 215 NOTREACHED(); |
209 } | 216 } |
210 } | 217 } |
211 | 218 |
212 void notifyFinished() { | 219 void notifyFinished() { |
213 if (!m_constructRetainedObjectInfos) | 220 if (!m_constructRetainedObjectInfos) |
214 return; | 221 return; |
215 std::sort(m_groupsWhichNeedRetainerInfo.begin(), | 222 std::sort(m_groupsWhichNeedRetainerInfo.begin(), |
216 m_groupsWhichNeedRetainerInfo.end()); | 223 m_groupsWhichNeedRetainerInfo.end()); |
(...skipping 29 matching lines...) Expand all Loading... | |
246 } | 253 } |
247 | 254 |
248 v8::Isolate* m_isolate; | 255 v8::Isolate* m_isolate; |
249 // v8 guarantees that Blink will not regain control while a v8 GC runs | 256 // v8 guarantees that Blink will not regain control while a v8 GC runs |
250 // (=> no Oilpan GCs will be triggered), hence raw, untraced members | 257 // (=> no Oilpan GCs will be triggered), hence raw, untraced members |
251 // can safely be kept here. | 258 // can safely be kept here. |
252 Vector<UntracedMember<Node>> m_groupsWhichNeedRetainerInfo; | 259 Vector<UntracedMember<Node>> m_groupsWhichNeedRetainerInfo; |
253 int m_domObjectsWithPendingActivity; | 260 int m_domObjectsWithPendingActivity; |
254 bool m_liveRootGroupIdSet; | 261 bool m_liveRootGroupIdSet; |
255 bool m_constructRetainedObjectInfos; | 262 bool m_constructRetainedObjectInfos; |
263 bool m_constructImplicitReferenceGroups; | |
256 }; | 264 }; |
257 | 265 |
258 static unsigned long long usedHeapSize(v8::Isolate* isolate) { | 266 static unsigned long long usedHeapSize(v8::Isolate* isolate) { |
259 v8::HeapStatistics heapStatistics; | 267 v8::HeapStatistics heapStatistics; |
260 isolate->GetHeapStatistics(&heapStatistics); | 268 isolate->GetHeapStatistics(&heapStatistics); |
261 return heapStatistics.used_heap_size(); | 269 return heapStatistics.used_heap_size(); |
262 } | 270 } |
263 | 271 |
264 namespace { | 272 namespace { |
265 | 273 |
266 void visitWeakHandlesForMinorGC(v8::Isolate* isolate) { | 274 void visitWeakHandlesForMinorGC(v8::Isolate* isolate) { |
267 MinorGCUnmodifiedWrapperVisitor visitor(isolate); | 275 MinorGCUnmodifiedWrapperVisitor visitor(isolate); |
268 isolate->VisitWeakHandles(&visitor); | 276 isolate->VisitWeakHandles(&visitor); |
269 } | 277 } |
270 | 278 |
271 void objectGroupingForMajorGC(v8::Isolate* isolate, | 279 void objectGroupingForMajorGC(v8::Isolate* isolate, |
272 bool constructRetainedObjectInfos) { | 280 bool constructRetainedObjectInfos, |
273 MajorGCWrapperVisitor visitor(isolate, constructRetainedObjectInfos); | 281 bool constructImplicitReferenceGroups) { |
haraken
2016/10/04 11:24:48
constructImplicitReferenceGroups is unused.
Michael Lippautz
2016/10/04 11:31:02
Done.
| |
282 MajorGCWrapperVisitor visitor( | |
283 isolate, constructRetainedObjectInfos, | |
284 !RuntimeEnabledFeatures::traceWrappablesEnabled()); | |
274 isolate->VisitHandlesWithClassIds(&visitor); | 285 isolate->VisitHandlesWithClassIds(&visitor); |
275 visitor.notifyFinished(); | 286 visitor.notifyFinished(); |
276 } | 287 } |
277 | 288 |
278 void gcPrologueForMajorGC(v8::Isolate* isolate, | 289 void gcPrologueForMajorGC(v8::Isolate* isolate, |
279 bool constructRetainedObjectInfos) { | 290 bool constructRetainedObjectInfos) { |
280 // TODO(hlopko): Collect retained object infos for heap profiler | 291 const bool objectGrouping = !RuntimeEnabledFeatures::traceWrappablesEnabled(); |
281 if (!RuntimeEnabledFeatures::traceWrappablesEnabled()) { | 292 if (objectGrouping || constructRetainedObjectInfos) { |
282 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); | 293 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos, |
294 objectGrouping); | |
283 } | 295 } |
284 } | 296 } |
285 | 297 |
286 } // namespace | 298 } // namespace |
287 | 299 |
288 void V8GCController::gcPrologue(v8::Isolate* isolate, | 300 void V8GCController::gcPrologue(v8::Isolate* isolate, |
289 v8::GCType type, | 301 v8::GCType type, |
290 v8::GCCallbackFlags flags) { | 302 v8::GCCallbackFlags flags) { |
291 if (isMainThread()) | 303 if (isMainThread()) |
292 ScriptForbiddenScope::enter(); | 304 ScriptForbiddenScope::enter(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 double startTime = WTF::currentTimeMS(); | 549 double startTime = WTF::currentTimeMS(); |
538 v8::HandleScope scope(isolate); | 550 v8::HandleScope scope(isolate); |
539 PendingActivityVisitor visitor(isolate, executionContext); | 551 PendingActivityVisitor visitor(isolate, executionContext); |
540 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 552 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
541 scanPendingActivityHistogram.count( | 553 scanPendingActivityHistogram.count( |
542 static_cast<int>(WTF::currentTimeMS() - startTime)); | 554 static_cast<int>(WTF::currentTimeMS() - startTime)); |
543 return visitor.pendingActivityFound(); | 555 return visitor.pendingActivityFound(); |
544 } | 556 } |
545 | 557 |
546 } // namespace blink | 558 } // namespace blink |
OLD | NEW |