OLD | NEW |
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ALWAYS_INLINE static void bufferFree(void* p) | 111 ALWAYS_INLINE static void bufferFree(void* p) |
112 { | 112 { |
113 partitionFreeGeneric(bufferPartition(), p); | 113 partitionFreeGeneric(bufferPartition(), p); |
114 } | 114 } |
115 | 115 |
116 ALWAYS_INLINE static size_t bufferActualSize(size_t n) | 116 ALWAYS_INLINE static size_t bufferActualSize(size_t n) |
117 { | 117 { |
118 return partitionAllocActualSize(bufferPartition(), n); | 118 return partitionAllocActualSize(bufferPartition(), n); |
119 } | 119 } |
120 | 120 |
| 121 static void handleOutOfMemory(); |
| 122 |
121 private: | 123 private: |
122 static int s_initializationLock; | 124 static int s_initializationLock; |
123 static bool s_initialized; | 125 static bool s_initialized; |
124 | 126 |
125 // We have the following four partitions. | 127 // We have the following four partitions. |
126 // - Node partition: A partition to allocate Nodes. We prepare a | 128 // - Node partition: A partition to allocate Nodes. We prepare a |
127 // dedicated partition for Nodes because Nodes are likely to be | 129 // dedicated partition for Nodes because Nodes are likely to be |
128 // a source of use-after-frees. Another reason is for performance: | 130 // a source of use-after-frees. Another reason is for performance: |
129 // Since Nodes are guaranteed to be used only by the main | 131 // Since Nodes are guaranteed to be used only by the main |
130 // thread, we can bypass acquiring a lock. Also we can improve memory | 132 // thread, we can bypass acquiring a lock. Also we can improve memory |
131 // locality by putting Nodes together. | 133 // locality by putting Nodes together. |
132 // - Layout object partition: A partition to allocate LayoutObjects. | 134 // - Layout object partition: A partition to allocate LayoutObjects. |
133 // we prepare a dedicated partition for the same reason as Nodes. | 135 // we prepare a dedicated partition for the same reason as Nodes. |
134 // - Buffer partition: A partition to allocate objects that have a strong | 136 // - Buffer partition: A partition to allocate objects that have a strong |
135 // risk where the length and/or the contents are exploited from user | 137 // risk where the length and/or the contents are exploited from user |
136 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are | 138 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are |
137 // allocated in the buffer partition. | 139 // allocated in the buffer partition. |
138 // - Fast malloc partition: A partition to allocate all other objects. | 140 // - Fast malloc partition: A partition to allocate all other objects. |
139 static PartitionAllocatorGeneric m_fastMallocAllocator; | 141 static PartitionAllocatorGeneric m_fastMallocAllocator; |
140 static PartitionAllocatorGeneric m_bufferAllocator; | 142 static PartitionAllocatorGeneric m_bufferAllocator; |
141 static SizeSpecificPartitionAllocator<3328> m_nodeAllocator; | 143 static SizeSpecificPartitionAllocator<3328> m_nodeAllocator; |
142 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; | 144 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; |
143 static HistogramEnumerationFunction m_histogramEnumeration; | 145 static HistogramEnumerationFunction m_histogramEnumeration; |
144 }; | 146 }; |
145 | 147 |
146 } // namespace WTF | 148 } // namespace WTF |
147 | 149 |
148 #endif // Partitions_h | 150 #endif // Partitions_h |
OLD | NEW |