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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "bindings/core/v8/V8GCController.h" | 31 #include "bindings/core/v8/V8GCController.h" |
32 | 32 |
33 #include "bindings/core/v8/ActiveScriptWrappable.h" | 33 #include "bindings/core/v8/ActiveScriptWrappable.h" |
34 #include "bindings/core/v8/NPV8Object.h" | |
35 #include "bindings/core/v8/RetainedDOMInfo.h" | 34 #include "bindings/core/v8/RetainedDOMInfo.h" |
36 #include "bindings/core/v8/V8AbstractEventListener.h" | 35 #include "bindings/core/v8/V8AbstractEventListener.h" |
37 #include "bindings/core/v8/V8Binding.h" | 36 #include "bindings/core/v8/V8Binding.h" |
38 #include "bindings/core/v8/V8MutationObserver.h" | 37 #include "bindings/core/v8/V8MutationObserver.h" |
39 #include "bindings/core/v8/V8Node.h" | 38 #include "bindings/core/v8/V8Node.h" |
40 #include "bindings/core/v8/V8ScriptRunner.h" | 39 #include "bindings/core/v8/V8ScriptRunner.h" |
41 #include "bindings/core/v8/WrapperTypeInfo.h" | 40 #include "bindings/core/v8/WrapperTypeInfo.h" |
42 #include "core/dom/Attr.h" | 41 #include "core/dom/Attr.h" |
43 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
44 #include "core/dom/NodeTraversal.h" | 43 #include "core/dom/NodeTraversal.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 111 |
113 // MinorGC does not collect objects because it may be expensive to | 112 // MinorGC does not collect objects because it may be expensive to |
114 // update references during minorGC | 113 // update references during minorGC |
115 if (classId == WrapperTypeInfo::ObjectClassId) { | 114 if (classId == WrapperTypeInfo::ObjectClassId) { |
116 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); | 115 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); |
117 return; | 116 return; |
118 } | 117 } |
119 | 118 |
120 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8
::Persistent<v8::Object>::Cast(*value)); | 119 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8
::Persistent<v8::Object>::Cast(*value)); |
121 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | 120 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); |
122 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); | 121 if (toWrapperTypeInfo(wrapper)->hasPendingActivity(wrapper)) { |
123 if (type != npObjectTypeInfo() && type->hasPendingActivity(wrapper)) { | |
124 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); | 122 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); |
125 return; | 123 return; |
126 } | 124 } |
127 | 125 |
128 if (classId == WrapperTypeInfo::NodeClassId) { | 126 if (classId == WrapperTypeInfo::NodeClassId) { |
129 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); | 127 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); |
130 Node* node = V8Node::toImpl(wrapper); | 128 Node* node = V8Node::toImpl(wrapper); |
131 if (node->hasEventListeners()) { | 129 if (node->hasEventListeners()) { |
132 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); | 130 v8::Persistent<v8::Object>::Cast(*value).MarkActive(); |
133 return; | 131 return; |
(...skipping 24 matching lines...) Expand all Loading... |
158 | 156 |
159 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classI
d) override | 157 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classI
d) override |
160 { | 158 { |
161 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) | 159 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) |
162 return; | 160 return; |
163 | 161 |
164 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8
::Persistent<v8::Object>::Cast(*value)); | 162 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8
::Persistent<v8::Object>::Cast(*value)); |
165 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | 163 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); |
166 | 164 |
167 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); | 165 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); |
168 if (type != npObjectTypeInfo() && type->hasPendingActivity(wrapper)) { | 166 if (type->hasPendingActivity(wrapper)) { |
169 // 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] |
170 // extended attribute to the DOM interface. A DOM interface that | 168 // extended attribute to the DOM interface. A DOM interface that |
171 // overrides hasPendingActivity must be marked as [DependentiLifetim
e]. | 169 // overrides hasPendingActivity must be marked as [DependentiLifetim
e]. |
172 RELEASE_ASSERT(!value->IsIndependent()); | 170 RELEASE_ASSERT(!value->IsIndependent()); |
173 m_isolate->SetObjectGroupId(*value, liveRootId()); | 171 m_isolate->SetObjectGroupId(*value, liveRootId()); |
174 ++m_domObjectsWithPendingActivity; | 172 ++m_domObjectsWithPendingActivity; |
175 } | 173 } |
176 | 174 |
177 if (value->IsIndependent()) | 175 if (value->IsIndependent()) |
178 return; | 176 return; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // If we have already found any wrapper that has a pending activity, | 447 // If we have already found any wrapper that has a pending activity, |
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 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); | |
460 // 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
. |
461 if (type != npObjectTypeInfo() | 458 if (toWrapperTypeInfo(wrapper)->hasPendingActivity(wrapper) |
462 && type->hasPendingActivity(wrapper) | |
463 // TODO(haraken): Currently we don't have a way to get a creation | 459 // TODO(haraken): Currently we don't have a way to get a creation |
464 // context from a wrapper. We should implement the way and enable | 460 // context from a wrapper. We should implement the way and enable |
465 // the following condition. | 461 // the following condition. |
466 // | 462 // |
467 // This condition affects only compositor workers, where one isolate | 463 // This condition affects only compositor workers, where one isolate |
468 // is shared by multiple workers. If we don't have the condition, | 464 // is shared by multiple workers. If we don't have the condition, |
469 // a worker object for a compositor worker doesn't get collected | 465 // a worker object for a compositor worker doesn't get collected |
470 // until all compositor workers in the same isolate lose pending | 466 // until all compositor workers in the same isolate lose pending |
471 // activities. In other words, not having the condition delays | 467 // activities. In other words, not having the condition delays |
472 // destruction of a worker object of a compositor worker. | 468 // destruction of a worker object of a compositor worker. |
(...skipping 20 matching lines...) Expand all Loading... |
493 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 489 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
494 double startTime = WTF::currentTimeMS(); | 490 double startTime = WTF::currentTimeMS(); |
495 v8::HandleScope scope(isolate); | 491 v8::HandleScope scope(isolate); |
496 PendingActivityVisitor visitor(isolate, executionContext); | 492 PendingActivityVisitor visitor(isolate, executionContext); |
497 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 493 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
498 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 494 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
499 return visitor.pendingActivityFound(); | 495 return visitor.pendingActivityFound(); |
500 } | 496 } |
501 | 497 |
502 } // namespace blink | 498 } // namespace blink |
OLD | NEW |