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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 return node; | 92 return node; |
93 } | 93 } |
94 | 94 |
95 // Regarding a minor GC algorithm for DOM nodes, see this document: | 95 // Regarding a minor GC algorithm for DOM nodes, see this document: |
96 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g
49mWNMW2gaWvMN5NLk8/edit#slide=id.p | 96 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g
49mWNMW2gaWvMN5NLk8/edit#slide=id.p |
97 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor { | 97 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor { |
98 public: | 98 public: |
99 explicit MinorGCWrapperVisitor(v8::Isolate* isolate) | 99 explicit MinorGCWrapperVisitor(v8::Isolate* isolate) |
100 : m_isolate(isolate) | 100 : m_isolate(isolate) |
101 { | 101 { } |
102 UNUSED_PARAM(m_isolate); | |
103 } | |
104 | 102 |
105 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) OVERRIDE | 103 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_
t classId) OVERRIDE |
106 { | 104 { |
107 // A minor DOM GC can collect only Nodes. | 105 // A minor DOM GC can collect only Nodes. |
108 if (classId != v8DOMNodeClassId) | 106 if (classId != v8DOMNodeClassId) |
109 return; | 107 return; |
110 | 108 |
111 // To make minor GC cycle time bounded, we limit the number of wrappers
handled | 109 // To make minor GC cycle time bounded, we limit the number of wrappers
handled |
112 // by each minor GC cycle to 10000. This value was selected so that the
minor | 110 // by each minor GC cycle to 10000. This value was selected so that the
minor |
113 // GC cycle time is bounded to 20 ms in a case where the new space size | 111 // GC cycle time is bounded to 20 ms in a case where the new space size |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqu
eRootForGC(*it, m_isolate))); | 263 v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqu
eRootForGC(*it, m_isolate))); |
266 m_isolate->SetReferenceFromGroup(id, *value); | 264 m_isolate->SetReferenceFromGroup(id, *value); |
267 } | 265 } |
268 } else { | 266 } else { |
269 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper)
; | 267 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper)
; |
270 if (activeDOMObject && activeDOMObject->hasPendingActivity()) | 268 if (activeDOMObject && activeDOMObject->hasPendingActivity()) |
271 m_isolate->SetObjectGroupId(*value, liveRootId()); | 269 m_isolate->SetObjectGroupId(*value, liveRootId()); |
272 } | 270 } |
273 | 271 |
274 if (classId == v8DOMNodeClassId) { | 272 if (classId == v8DOMNodeClassId) { |
275 UNUSED_PARAM(m_isolate); | |
276 ASSERT(V8Node::hasInstanceInAnyWorld(*wrapper, m_isolate)); | 273 ASSERT(V8Node::hasInstanceInAnyWorld(*wrapper, m_isolate)); |
277 ASSERT(!value->IsIndependent()); | 274 ASSERT(!value->IsIndependent()); |
278 | 275 |
279 Node* node = static_cast<Node*>(object); | 276 Node* node = static_cast<Node*>(object); |
280 | 277 |
281 if (node->hasEventListeners()) | 278 if (node->hasEventListeners()) |
282 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers
istent<v8::Object>::Cast(*value)); | 279 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers
istent<v8::Object>::Cast(*value)); |
283 Node* root = V8GCController::opaqueRootForGC(node, m_isolate); | 280 Node* root = V8GCController::opaqueRootForGC(node, m_isolate); |
284 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in
tptr_t>(root))); | 281 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in
tptr_t>(root))); |
285 if (m_constructRetainedObjectInfos) | 282 if (m_constructRetainedObjectInfos) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 { | 413 { |
417 v8::HandleScope handleScope(isolate); | 414 v8::HandleScope handleScope(isolate); |
418 v8::Local<v8::Context> context = v8::Context::New(isolate); | 415 v8::Local<v8::Context> context = v8::Context::New(isolate); |
419 if (context.IsEmpty()) | 416 if (context.IsEmpty()) |
420 return; | 417 return; |
421 v8::Context::Scope contextScope(context); | 418 v8::Context::Scope contextScope(context); |
422 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();
"), isolate); | 419 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();
"), isolate); |
423 } | 420 } |
424 | 421 |
425 } // namespace WebCore | 422 } // namespace WebCore |
OLD | NEW |