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

Side by Side Diff: Source/core/dom/StaticNodeList.cpp

Issue 154263007: Let V8 know about the external memory owned by large StaticNodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months 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
« no previous file with comments | « Source/core/dom/StaticNodeList.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2010 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 15 matching lines...) Expand all
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/dom/StaticNodeList.h" 30 #include "core/dom/StaticNodeList.h"
31 31
32 #include "core/dom/Element.h" 32 #include "core/dom/Element.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 PassRefPtr<StaticNodeList> StaticNodeList::adopt(Vector<RefPtr<Node> >& nodes)
37 {
38 RefPtr<StaticNodeList> nodeList = adoptRef(new StaticNodeList);
39 nodeList->m_nodes.swap(nodes);
40 if (nodeList->AllocationSize() > externalMemoryReportSizeLimit)
41 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(nodeLis t->AllocationSize());
42 return nodeList.release();
43 }
44
45 StaticNodeList::~StaticNodeList()
46 {
47 if (AllocationSize() > externalMemoryReportSizeLimit)
48 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-Alloca tionSize());
49 }
50
36 unsigned StaticNodeList::length() const 51 unsigned StaticNodeList::length() const
37 { 52 {
38 return m_nodes.size(); 53 return m_nodes.size();
39 } 54 }
40 55
41 Node* StaticNodeList::item(unsigned index) const 56 Node* StaticNodeList::item(unsigned index) const
42 { 57 {
43 if (index < m_nodes.size()) 58 if (index < m_nodes.size())
44 return m_nodes[index].get(); 59 return m_nodes[index].get();
45 return 0; 60 return 0;
46 } 61 }
47 62
48 } // namespace WebCore 63 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/StaticNodeList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698