| OLD | NEW | 
|    1 // Copyright (c) 2008, Google Inc. |    1 // Copyright (c) 2008, Google Inc. | 
|    2 // All rights reserved. |    2 // 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  137  |  137  | 
|  138 namespace tcmalloc { |  138 namespace tcmalloc { | 
|  139  |  139  | 
|  140 // Convert byte size into pages.  This won't overflow, but may return |  140 // Convert byte size into pages.  This won't overflow, but may return | 
|  141 // an unreasonably large value if bytes is huge enough. |  141 // an unreasonably large value if bytes is huge enough. | 
|  142 inline Length pages(size_t bytes) { |  142 inline Length pages(size_t bytes) { | 
|  143   return (bytes >> kPageShift) + |  143   return (bytes >> kPageShift) + | 
|  144       ((bytes & (kPageSize - 1)) > 0 ? 1 : 0); |  144       ((bytes & (kPageSize - 1)) > 0 ? 1 : 0); | 
|  145 } |  145 } | 
|  146  |  146  | 
 |  147 // For security reasons, we want to limit the size of contiguous allocations. | 
 |  148 // See crbug.com/169327. | 
 |  149 bool IsContiguousAllocSizePermitted(size_t alloc_size); | 
 |  150  | 
|  147 // For larger allocation sizes, we use larger memory alignments to |  151 // For larger allocation sizes, we use larger memory alignments to | 
|  148 // reduce the number of size classes. |  152 // reduce the number of size classes. | 
|  149 int AlignmentForSize(size_t size); |  153 int AlignmentForSize(size_t size); | 
|  150  |  154  | 
|  151 // Size-class information + mapping |  155 // Size-class information + mapping | 
|  152 class SizeMap { |  156 class SizeMap { | 
|  153  private: |  157  private: | 
|  154   // Number of objects to move between a per-thread list and a central |  158   // Number of objects to move between a per-thread list and a central | 
|  155   // list in one shot.  We want this to be not too small so we can |  159   // list in one shot.  We want this to be not too small so we can | 
|  156   // amortize the lock overhead for accessing the central list.  Making |  160   // amortize the lock overhead for accessing the central list.  Making | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  260 static const int kMaxStackDepth = 31; |  264 static const int kMaxStackDepth = 31; | 
|  261 struct StackTrace { |  265 struct StackTrace { | 
|  262   uintptr_t size;          // Size of object |  266   uintptr_t size;          // Size of object | 
|  263   uintptr_t depth;         // Number of PC values stored in array below |  267   uintptr_t depth;         // Number of PC values stored in array below | 
|  264   void*     stack[kMaxStackDepth]; |  268   void*     stack[kMaxStackDepth]; | 
|  265 }; |  269 }; | 
|  266  |  270  | 
|  267 }  // namespace tcmalloc |  271 }  // namespace tcmalloc | 
|  268  |  272  | 
|  269 #endif  // TCMALLOC_COMMON_H_ |  273 #endif  // TCMALLOC_COMMON_H_ | 
| OLD | NEW |