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

Side by Side Diff: Source/bindings/v8/V8GCController.cpp

Issue 48633006: Teach V8GCController how to traverse TemplateContentDocumentFragment::host (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 24 matching lines...) Expand all
35 #include "V8MessagePort.h" 35 #include "V8MessagePort.h"
36 #include "V8MutationObserver.h" 36 #include "V8MutationObserver.h"
37 #include "V8Node.h" 37 #include "V8Node.h"
38 #include "V8ScriptRunner.h" 38 #include "V8ScriptRunner.h"
39 #include "bindings/v8/RetainedDOMInfo.h" 39 #include "bindings/v8/RetainedDOMInfo.h"
40 #include "bindings/v8/V8AbstractEventListener.h" 40 #include "bindings/v8/V8AbstractEventListener.h"
41 #include "bindings/v8/V8Binding.h" 41 #include "bindings/v8/V8Binding.h"
42 #include "bindings/v8/WrapperTypeInfo.h" 42 #include "bindings/v8/WrapperTypeInfo.h"
43 #include "core/dom/Attr.h" 43 #include "core/dom/Attr.h"
44 #include "core/dom/NodeTraversal.h" 44 #include "core/dom/NodeTraversal.h"
45 #include "core/dom/TemplateContentDocumentFragment.h"
45 #include "core/dom/shadow/ElementShadow.h" 46 #include "core/dom/shadow/ElementShadow.h"
46 #include "core/dom/shadow/ShadowRoot.h" 47 #include "core/dom/shadow/ShadowRoot.h"
47 #include "core/html/HTMLImageElement.h" 48 #include "core/html/HTMLImageElement.h"
48 #include "platform/TraceEvent.h" 49 #include "platform/TraceEvent.h"
49 50
50 namespace WebCore { 51 namespace WebCore {
51 52
52 // FIXME: This should use opaque GC roots. 53 // FIXME: This should use opaque GC roots.
53 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper) 54 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper)
54 { 55 {
(...skipping 22 matching lines...) Expand all
77 if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImag eElement(node)->hasPendingActivity())) 78 if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImag eElement(node)->hasPendingActivity()))
78 return &node->document(); 79 return &node->document();
79 80
80 if (node->isAttributeNode()) { 81 if (node->isAttributeNode()) {
81 Node* ownerElement = toAttr(node)->ownerElement(); 82 Node* ownerElement = toAttr(node)->ownerElement();
82 if (!ownerElement) 83 if (!ownerElement)
83 return node; 84 return node;
84 node = ownerElement; 85 node = ownerElement;
85 } 86 }
86 87
87 while (Node* parent = node->parentOrShadowHostNode()) 88 while (Node* parent = node->parentOrShadowHostOrTemplateHostNode())
88 node = parent; 89 node = parent;
89 90
90 return node; 91 return node;
91 } 92 }
92 93
93 // Regarding a minor GC algorithm for DOM nodes, see this document: 94 // Regarding a minor GC algorithm for DOM nodes, see this document:
94 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g 49mWNMW2gaWvMN5NLk8/edit#slide=id.p 95 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g 49mWNMW2gaWvMN5NLk8/edit#slide=id.p
95 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor { 96 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor {
96 public: 97 public:
97 explicit MinorGCWrapperVisitor(v8::Isolate* isolate) 98 explicit MinorGCWrapperVisitor(v8::Isolate* isolate)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 183 }
183 return true; 184 return true;
184 } 185 }
185 186
186 void gcTree(v8::Isolate* isolate, Node* startNode) 187 void gcTree(v8::Isolate* isolate, Node* startNode)
187 { 188 {
188 Vector<Node*, initialNodeVectorSize> newSpaceNodes; 189 Vector<Node*, initialNodeVectorSize> newSpaceNodes;
189 190
190 Node* node = startNode; 191 Node* node = startNode;
191 while (node->parentOrShadowHostNode()) 192 while (node->parentOrShadowHostNode())
192 node = node->parentOrShadowHostNode(); 193 node = node->parentOrShadowHostNode();
haraken 2013/10/30 00:09:53 Don't you need to change this to parentOrShadowHos
adamk 2013/10/30 17:02:45 Very good point, forgot about minor GC (I think th
193 194
194 if (!traverseTree(node, &newSpaceNodes)) 195 if (!traverseTree(node, &newSpaceNodes))
195 return; 196 return;
196 197
197 // We completed the DOM tree traversal. All wrappers in the DOM tree are 198 // We completed the DOM tree traversal. All wrappers in the DOM tree are
198 // stored in newSpaceNodes and are expected to exist in the new space of V8. 199 // stored in newSpaceNodes and are expected to exist in the new space of V8.
199 // We report those wrappers to V8 as an object group. 200 // We report those wrappers to V8 as an object group.
200 Node** nodeIterator = newSpaceNodes.begin(); 201 Node** nodeIterator = newSpaceNodes.begin();
201 Node** const nodeIteratorEnd = newSpaceNodes.end(); 202 Node** const nodeIteratorEnd = newSpaceNodes.end();
202 if (nodeIterator == nodeIteratorEnd) 203 if (nodeIterator == nodeIteratorEnd)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 { 415 {
415 v8::HandleScope handleScope(isolate); 416 v8::HandleScope handleScope(isolate);
416 v8::Local<v8::Context> context = v8::Context::New(isolate); 417 v8::Local<v8::Context> context = v8::Context::New(isolate);
417 if (context.IsEmpty()) 418 if (context.IsEmpty())
418 return; 419 return;
419 v8::Context::Scope contextScope(context); 420 v8::Context::Scope contextScope(context);
420 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate); 421 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate);
421 } 422 }
422 423
423 } // namespace WebCore 424 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698