| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // is 16 MB and it is full of wrappers (which is almost the worst case). | 120 // is 16 MB and it is full of wrappers (which is almost the worst case). |
| 121 // Practically speaking, as far as I crawled real web applications, | 121 // Practically speaking, as far as I crawled real web applications, |
| 122 // the number of wrappers handled by each minor GC cycle is at most 3000
. | 122 // the number of wrappers handled by each minor GC cycle is at most 3000
. |
| 123 // So this limit is mainly for pathological micro benchmarks. | 123 // So this limit is mainly for pathological micro benchmarks. |
| 124 const unsigned wrappersHandledByEachMinorGC = 10000; | 124 const unsigned wrappersHandledByEachMinorGC = 10000; |
| 125 if (m_nodesInNewSpace.size() >= wrappersHandledByEachMinorGC) | 125 if (m_nodesInNewSpace.size() >= wrappersHandledByEachMinorGC) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d | 128 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d |
| 129 // during the GC prologue. | 129 // during the GC prologue. |
| 130 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); | 130 ASSERT((*reinterpret_cast<v8::Local<v8::Value>*>(value))->IsObject()); |
| 131 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object
>*>(value); | 131 v8::Local<v8::Object>* wrapper = reinterpret_cast<v8::Local<v8::Object>*
>(value); |
| 132 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); | 132 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); |
| 133 ASSERT(V8Node::hasInstance(*wrapper, m_isolate)); | 133 ASSERT(V8Node::hasInstance(*wrapper, m_isolate)); |
| 134 Node* node = V8Node::toImpl(*wrapper); | 134 Node* node = V8Node::toImpl(*wrapper); |
| 135 // A minor DOM GC can handle only node wrappers in the main world. | 135 // A minor DOM GC can handle only node wrappers in the main world. |
| 136 // Note that node->wrapper().IsEmpty() returns true for nodes that | 136 // Note that node->wrapper().IsEmpty() returns true for nodes that |
| 137 // do not have wrappers in the main world. | 137 // do not have wrappers in the main world. |
| 138 if (node->containsWrapper()) { | 138 if (node->containsWrapper()) { |
| 139 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); | 139 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); |
| 140 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper)
; | 140 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper)
; |
| 141 if (activeDOMObject && activeDOMObject->hasPendingActivity()) | 141 if (activeDOMObject && activeDOMObject->hasPendingActivity()) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 { | 253 { |
| 254 } | 254 } |
| 255 | 255 |
| 256 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) override | 256 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) override |
| 257 { | 257 { |
| 258 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) | 258 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) |
| 259 return; | 259 return; |
| 260 | 260 |
| 261 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d | 261 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d |
| 262 // during the GC prologue. | 262 // during the GC prologue. |
| 263 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); | 263 ASSERT((*reinterpret_cast<v8::Local<v8::Value>*>(value))->IsObject()); |
| 264 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object
>*>(value); | 264 v8::Local<v8::Object>* wrapper = reinterpret_cast<v8::Local<v8::Object>*
>(value); |
| 265 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); | 265 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); |
| 266 | 266 |
| 267 if (value->IsIndependent()) | 267 if (value->IsIndependent()) |
| 268 return; | 268 return; |
| 269 | 269 |
| 270 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); | 270 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); |
| 271 | 271 |
| 272 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper); | 272 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper); |
| 273 if (activeDOMObject && activeDOMObject->hasPendingActivity()) { | 273 if (activeDOMObject && activeDOMObject->hasPendingActivity()) { |
| 274 m_isolate->SetObjectGroupId(*value, liveRootId()); | 274 m_isolate->SetObjectGroupId(*value, liveRootId()); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 { | 489 { |
| 490 } | 490 } |
| 491 | 491 |
| 492 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) override | 492 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) override |
| 493 { | 493 { |
| 494 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) | 494 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf
o::ObjectClassId) |
| 495 return; | 495 return; |
| 496 | 496 |
| 497 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d | 497 // Casting to a Handle is safe here, since the Persistent doesn't get GC
d |
| 498 // during tracing. | 498 // during tracing. |
| 499 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); | 499 ASSERT((*reinterpret_cast<v8::Local<v8::Value>*>(value))->IsObject()); |
| 500 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object
>*>(value); | 500 v8::Local<v8::Object>* wrapper = reinterpret_cast<v8::Local<v8::Object>*
>(value); |
| 501 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); | 501 ASSERT(V8DOMWrapper::hasInternalFieldsSet(*wrapper)); |
| 502 if (m_visitor) | 502 if (m_visitor) |
| 503 toWrapperTypeInfo(*wrapper)->trace(m_visitor, toScriptWrappable(*wra
pper)); | 503 toWrapperTypeInfo(*wrapper)->trace(m_visitor, toScriptWrappable(*wra
pper)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 private: | 506 private: |
| 507 Visitor* m_visitor; | 507 Visitor* m_visitor; |
| 508 }; | 508 }; |
| 509 | 509 |
| 510 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) | 510 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) |
| 511 { | 511 { |
| 512 DOMWrapperTracer tracer(visitor); | 512 DOMWrapperTracer tracer(visitor); |
| 513 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); | 513 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // namespace blink | 516 } // namespace blink |
| OLD | NEW |