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

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

Issue 2265873003: binding: Moves hasPendingActivity from ActiveScriptWrappable to ScriptWrappable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 3 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
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 // MinorGC does not collect objects because it may be expensive to 110 // MinorGC does not collect objects because it may be expensive to
111 // update references during minorGC 111 // update references during minorGC
112 if (classId == WrapperTypeInfo::ObjectClassId) { 112 if (classId == WrapperTypeInfo::ObjectClassId) {
113 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); 113 v8::Persistent<v8::Object>::Cast(*value).MarkActive();
114 return; 114 return;
115 } 115 }
116 116
117 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 117 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
118 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 118 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
119 if (toWrapperTypeInfo(wrapper)->hasPendingActivity(wrapper)) { 119 if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable()
120 && toScriptWrappable(wrapper)->hasPendingActivity()) {
120 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); 121 v8::Persistent<v8::Object>::Cast(*value).MarkActive();
121 return; 122 return;
122 } 123 }
123 124
124 if (classId == WrapperTypeInfo::NodeClassId) { 125 if (classId == WrapperTypeInfo::NodeClassId) {
125 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); 126 ASSERT(V8Node::hasInstance(wrapper, m_isolate));
126 Node* node = V8Node::toImpl(wrapper); 127 Node* node = V8Node::toImpl(wrapper);
127 if (node->hasEventListeners()) { 128 if (node->hasEventListeners()) {
128 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); 129 v8::Persistent<v8::Object>::Cast(*value).MarkActive();
129 return; 130 return;
(...skipping 20 matching lines...) Expand all
150 , m_liveRootGroupIdSet(false) 151 , m_liveRootGroupIdSet(false)
151 , m_constructRetainedObjectInfos(constructRetainedObjectInfos) 152 , m_constructRetainedObjectInfos(constructRetainedObjectInfos)
152 { 153 {
153 } 154 }
154 155
155 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classI d) override 156 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classI d) override
156 { 157 {
157 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) 158 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId)
158 return; 159 return;
159 160
161 if (value->IsIndependent())
162 return;
163
160 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 164 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
161 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 165 DCHECK(V8DOMWrapper::hasInternalFieldsSet(wrapper));
162 166
163 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 167 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
164 if (type->hasPendingActivity(wrapper)) { 168 if (type->isActiveScriptWrappable()
165 // If you hit this assert, you'll need to add a [DependentiLifetime] 169 && toScriptWrappable(wrapper)->hasPendingActivity()) {
166 // extended attribute to the DOM interface. A DOM interface that
167 // overrides hasPendingActivity must be marked as [DependentLifetime ].
168 RELEASE_ASSERT(!value->IsIndependent());
169 m_isolate->SetObjectGroupId(*value, liveRootId()); 170 m_isolate->SetObjectGroupId(*value, liveRootId());
170 ++m_domObjectsWithPendingActivity; 171 ++m_domObjectsWithPendingActivity;
171 } 172 }
172 173
173 if (value->IsIndependent())
174 return;
175
176 if (classId == WrapperTypeInfo::NodeClassId) { 174 if (classId == WrapperTypeInfo::NodeClassId) {
177 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); 175 DCHECK(V8Node::hasInstance(wrapper, m_isolate));
178 Node* node = V8Node::toImpl(wrapper); 176 Node* node = V8Node::toImpl(wrapper);
179 if (node->hasEventListeners()) 177 if (node->hasEventListeners())
180 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); 178 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value));
181 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); 179 Node* root = V8GCController::opaqueRootForGC(m_isolate, node);
182 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); 180 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root)));
183 if (m_constructRetainedObjectInfos) 181 if (m_constructRetainedObjectInfos)
184 m_groupsWhichNeedRetainerInfo.append(root); 182 m_groupsWhichNeedRetainerInfo.append(root);
185 } else if (classId == WrapperTypeInfo::ObjectClassId) { 183 } else if (classId == WrapperTypeInfo::ObjectClassId) {
186 type->visitDOMWrapper(m_isolate, toScriptWrappable(wrapper), v8::Per sistent<v8::Object>::Cast(*value)); 184 type->visitDOMWrapper(m_isolate, toScriptWrappable(wrapper), v8::Per sistent<v8::Object>::Cast(*value));
187 } else { 185 } else {
188 ASSERT_NOT_REACHED(); 186 NOTREACHED();
189 } 187 }
190 } 188 }
191 189
192 void notifyFinished() 190 void notifyFinished()
193 { 191 {
194 if (!m_constructRetainedObjectInfos) 192 if (!m_constructRetainedObjectInfos)
195 return; 193 return;
196 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end()); 194 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end());
197 Node* alreadyAdded = 0; 195 Node* alreadyAdded = 0;
198 v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); 196 v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // we don't need to check other wrappers. 448 // we don't need to check other wrappers.
451 if (m_pendingActivityFound) 449 if (m_pendingActivityFound)
452 return; 450 return;
453 451
454 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) 452 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId)
455 return; 453 return;
456 454
457 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 455 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
458 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 456 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
459 // The ExecutionContext check is heavy, so it should be done at the last . 457 // The ExecutionContext check is heavy, so it should be done at the last .
460 if (toWrapperTypeInfo(wrapper)->hasPendingActivity(wrapper) 458 if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable()
459 && toScriptWrappable(wrapper)->hasPendingActivity()
461 // TODO(haraken): Currently we don't have a way to get a creation 460 // TODO(haraken): Currently we don't have a way to get a creation
462 // context from a wrapper. We should implement the way and enable 461 // context from a wrapper. We should implement the way and enable
463 // the following condition. 462 // the following condition.
464 // 463 //
465 // This condition affects only compositor workers, where one isolate 464 // This condition affects only compositor workers, where one isolate
466 // is shared by multiple workers. If we don't have the condition, 465 // is shared by multiple workers. If we don't have the condition,
467 // a worker object for a compositor worker doesn't get collected 466 // a worker object for a compositor worker doesn't get collected
468 // until all compositor workers in the same isolate lose pending 467 // until all compositor workers in the same isolate lose pending
469 // activities. In other words, not having the condition delays 468 // activities. In other words, not having the condition delays
470 // destruction of a worker object of a compositor worker. 469 // destruction of a worker object of a compositor worker.
(...skipping 20 matching lines...) Expand all
491 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); 490 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0));
492 double startTime = WTF::currentTimeMS(); 491 double startTime = WTF::currentTimeMS();
493 v8::HandleScope scope(isolate); 492 v8::HandleScope scope(isolate);
494 PendingActivityVisitor visitor(isolate, executionContext); 493 PendingActivityVisitor visitor(isolate, executionContext);
495 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 494 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
496 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); 495 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime));
497 return visitor.pendingActivityFound(); 496 return visitor.pendingActivityFound();
498 } 497 }
499 498
500 } // namespace blink 499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698