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