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

Side by Side Diff: third_party/WebKit/Source/wtf/allocator/Partitions.h

Issue 2682943002: Create a dedicated partition for array buffers (Closed)
Patch Set: temp Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 class WTF_EXPORT Partitions { 43 class WTF_EXPORT Partitions {
44 public: 44 public:
45 typedef void (*ReportPartitionAllocSizeFunction)(size_t); 45 typedef void (*ReportPartitionAllocSizeFunction)(size_t);
46 46
47 // Name of allocator used by tracing for marking sub-allocations while take 47 // Name of allocator used by tracing for marking sub-allocations while take
48 // memory snapshots. 48 // memory snapshots.
49 static const char* const kAllocatedObjectPoolName; 49 static const char* const kAllocatedObjectPoolName;
50 50
51 static void initialize(ReportPartitionAllocSizeFunction); 51 static void initialize(ReportPartitionAllocSizeFunction);
52 ALWAYS_INLINE static base::PartitionRootGeneric* arrayBufferPartition() {
53 DCHECK(s_initialized);
54 return m_arrayBufferAllocator.root();
55 }
56
52 ALWAYS_INLINE static base::PartitionRootGeneric* bufferPartition() { 57 ALWAYS_INLINE static base::PartitionRootGeneric* bufferPartition() {
53 DCHECK(s_initialized); 58 DCHECK(s_initialized);
54 return m_bufferAllocator.root(); 59 return m_bufferAllocator.root();
55 } 60 }
56 61
57 ALWAYS_INLINE static base::PartitionRootGeneric* fastMallocPartition() { 62 ALWAYS_INLINE static base::PartitionRootGeneric* fastMallocPartition() {
58 DCHECK(s_initialized); 63 DCHECK(s_initialized);
59 return m_fastMallocAllocator.root(); 64 return m_fastMallocAllocator.root();
60 } 65 }
61 66
62 ALWAYS_INLINE static base::PartitionRoot* nodePartition() { 67 ALWAYS_INLINE static base::PartitionRoot* nodePartition() {
63 NOTREACHED(); 68 NOTREACHED();
64 return nullptr; 69 return nullptr;
65 } 70 }
66 ALWAYS_INLINE static base::PartitionRoot* layoutPartition() { 71 ALWAYS_INLINE static base::PartitionRoot* layoutPartition() {
67 DCHECK(s_initialized); 72 DCHECK(s_initialized);
68 return m_layoutAllocator.root(); 73 return m_layoutAllocator.root();
69 } 74 }
70 75
71 static size_t currentDOMMemoryUsage() { 76 static size_t currentDOMMemoryUsage() {
72 NOTREACHED(); 77 NOTREACHED();
73 return 0; 78 return 0;
74 } 79 }
75 80
76 static size_t totalSizeOfCommittedPages() { 81 static size_t totalSizeOfCommittedPages() {
77 size_t totalSize = 0; 82 size_t totalSize = 0;
78 totalSize += m_fastMallocAllocator.root()->total_size_of_committed_pages; 83 totalSize += m_fastMallocAllocator.root()->total_size_of_committed_pages;
84 totalSize += m_arrayBufferAllocator.root()->total_size_of_committed_pages;
79 totalSize += m_bufferAllocator.root()->total_size_of_committed_pages; 85 totalSize += m_bufferAllocator.root()->total_size_of_committed_pages;
80 totalSize += m_layoutAllocator.root()->total_size_of_committed_pages; 86 totalSize += m_layoutAllocator.root()->total_size_of_committed_pages;
81 return totalSize; 87 return totalSize;
82 } 88 }
83 89
84 static void decommitFreeableMemory(); 90 static void decommitFreeableMemory();
85 91
86 static void reportMemoryUsageHistogram(); 92 static void reportMemoryUsageHistogram();
87 93
88 static void dumpMemoryStats(bool isLightDump, base::PartitionStatsDumper*); 94 static void dumpMemoryStats(bool isLightDump, base::PartitionStatsDumper*);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 static base::subtle::SpinLock s_initializationLock; 130 static base::subtle::SpinLock s_initializationLock;
125 static bool s_initialized; 131 static bool s_initialized;
126 132
127 // We have the following four partitions. 133 // We have the following four partitions.
128 // - LayoutObject partition: A partition to allocate LayoutObjects. 134 // - LayoutObject partition: A partition to allocate LayoutObjects.
129 // We prepare a dedicated partition for LayoutObjects because they 135 // We prepare a dedicated partition for LayoutObjects because they
130 // are likely to be a source of use-after-frees. Another reason 136 // are likely to be a source of use-after-frees. Another reason
131 // is for performance: As LayoutObjects are guaranteed to only be used 137 // is for performance: As LayoutObjects are guaranteed to only be used
132 // by the main thread, we can bypass acquiring a lock. Also we can 138 // by the main thread, we can bypass acquiring a lock. Also we can
133 // improve memory locality by putting LayoutObjects together. 139 // improve memory locality by putting LayoutObjects together.
134 // - Buffer partition: A partition to allocate objects that have a strong 140 // - ArrayBuffer partition: A partition to allocate array buffers.
135 // risk where the length and/or the contents are exploited from user 141 // - Buffer partition: A partition to allocate other buffers that have
136 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are 142 // a strong risk where the length and/or the contents are exploited from
137 // allocated in the buffer partition. 143 // user scripts. Vectors, HashTables and Strings are allocated in the
144 // buffer partition.
138 // - Fast malloc partition: A partition to allocate all other objects. 145 // - Fast malloc partition: A partition to allocate all other objects.
139 static base::PartitionAllocatorGeneric m_fastMallocAllocator; 146 static base::PartitionAllocatorGeneric m_fastMallocAllocator;
147 static base::PartitionAllocatorGeneric m_arrayBufferAllocator;
140 static base::PartitionAllocatorGeneric m_bufferAllocator; 148 static base::PartitionAllocatorGeneric m_bufferAllocator;
141 static base::SizeSpecificPartitionAllocator<1024> m_layoutAllocator; 149 static base::SizeSpecificPartitionAllocator<1024> m_layoutAllocator;
142 static ReportPartitionAllocSizeFunction m_reportSizeFunction; 150 static ReportPartitionAllocSizeFunction m_reportSizeFunction;
143 }; 151 };
144 152
145 using base::kGenericMaxDirectMapped; 153 using base::kGenericMaxDirectMapped;
146 using base::kPageAllocationGranularity; 154 using base::kPageAllocationGranularity;
147 using base::kPageAllocationGranularityBaseMask; 155 using base::kPageAllocationGranularityBaseMask;
148 using base::kPageAllocationGranularityOffsetMask; 156 using base::kPageAllocationGranularityOffsetMask;
149 using base::kSystemPageSize; 157 using base::kSystemPageSize;
(...skipping 13 matching lines...) Expand all
163 using base::PageAccessible; 171 using base::PageAccessible;
164 using base::PageInaccessible; 172 using base::PageInaccessible;
165 using base::PartitionStatsDumper; 173 using base::PartitionStatsDumper;
166 using base::PartitionMemoryStats; 174 using base::PartitionMemoryStats;
167 using base::PartitionBucketMemoryStats; 175 using base::PartitionBucketMemoryStats;
168 using base::PartitionAllocHooks; 176 using base::PartitionAllocHooks;
169 177
170 } // namespace WTF 178 } // namespace WTF
171 179
172 #endif // Partitions_h 180 #endif // Partitions_h
OLDNEW
« no previous file with comments | « base/trace_event/memory_infra_background_whitelist.cc ('k') | third_party/WebKit/Source/wtf/allocator/Partitions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698