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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 24 matching lines...) Expand all Loading... | |
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 |
160 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); | 161 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); |
161 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | 162 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); |
162 | 163 |
163 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); | 164 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); |
164 if (type->hasPendingActivity(wrapper)) { | 165 if (type->isActiveScriptWrappable() |
166 && toScriptWrappable(wrapper)->hasPendingActivity()) { | |
165 // If you hit this assert, you'll need to add a [DependentiLifetime] | 167 // If you hit this assert, you'll need to add a [DependentiLifetime] |
166 // extended attribute to the DOM interface. A DOM interface that | 168 // extended attribute to the DOM interface. A DOM interface that |
167 // overrides hasPendingActivity must be marked as [DependentLifetime ]. | 169 // overrides hasPendingActivity must be marked as [DependentLifetime ]. |
168 RELEASE_ASSERT(!value->IsIndependent()); | 170 CHECK(!value->IsIndependent()); |
169 m_isolate->SetObjectGroupId(*value, liveRootId()); | 171 m_isolate->SetObjectGroupId(*value, liveRootId()); |
170 ++m_domObjectsWithPendingActivity; | 172 ++m_domObjectsWithPendingActivity; |
171 } | 173 } |
172 | 174 |
173 if (value->IsIndependent()) | 175 if (value->IsIndependent()) |
haraken
2016/08/23 12:51:18
Now we can move this check to above line 164 (whic
Yuki
2016/08/23 13:13:33
Done.
| |
174 return; | 176 return; |
175 | 177 |
176 if (classId == WrapperTypeInfo::NodeClassId) { | 178 if (classId == WrapperTypeInfo::NodeClassId) { |
177 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); | 179 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); |
178 Node* node = V8Node::toImpl(wrapper); | 180 Node* node = V8Node::toImpl(wrapper); |
179 if (node->hasEventListeners()) | 181 if (node->hasEventListeners()) |
180 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); | 182 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); |
181 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); | 183 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); |
182 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); | 184 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); |
183 if (m_constructRetainedObjectInfos) | 185 if (m_constructRetainedObjectInfos) |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 // we don't need to check other wrappers. | 452 // we don't need to check other wrappers. |
451 if (m_pendingActivityFound) | 453 if (m_pendingActivityFound) |
452 return; | 454 return; |
453 | 455 |
454 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) | 456 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) |
455 return; | 457 return; |
456 | 458 |
457 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); | 459 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); |
458 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | 460 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); |
459 // The ExecutionContext check is heavy, so it should be done at the last . | 461 // The ExecutionContext check is heavy, so it should be done at the last . |
460 if (toWrapperTypeInfo(wrapper)->hasPendingActivity(wrapper) | 462 if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable() |
463 && toScriptWrappable(wrapper)->hasPendingActivity() | |
461 // TODO(haraken): Currently we don't have a way to get a creation | 464 // 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 | 465 // context from a wrapper. We should implement the way and enable |
463 // the following condition. | 466 // the following condition. |
464 // | 467 // |
465 // This condition affects only compositor workers, where one isolate | 468 // This condition affects only compositor workers, where one isolate |
466 // is shared by multiple workers. If we don't have the condition, | 469 // is shared by multiple workers. If we don't have the condition, |
467 // a worker object for a compositor worker doesn't get collected | 470 // a worker object for a compositor worker doesn't get collected |
468 // until all compositor workers in the same isolate lose pending | 471 // until all compositor workers in the same isolate lose pending |
469 // activities. In other words, not having the condition delays | 472 // activities. In other words, not having the condition delays |
470 // destruction of a worker object of a compositor worker. | 473 // destruction of a worker object of a compositor worker. |
(...skipping 20 matching lines...) Expand all Loading... | |
491 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); | 494 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); |
492 double startTime = WTF::currentTimeMS(); | 495 double startTime = WTF::currentTimeMS(); |
493 v8::HandleScope scope(isolate); | 496 v8::HandleScope scope(isolate); |
494 PendingActivityVisitor visitor(isolate, executionContext); | 497 PendingActivityVisitor visitor(isolate, executionContext); |
495 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 498 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
496 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); | 499 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); |
497 return visitor.pendingActivityFound(); | 500 return visitor.pendingActivityFound(); |
498 } | 501 } |
499 | 502 |
500 } // namespace blink | 503 } // namespace blink |
OLD | NEW |