| 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 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef Partitions_h | 31 #ifndef Partitions_h |
| 32 #define Partitions_h | 32 #define Partitions_h |
| 33 | 33 |
| 34 #include <string.h> | 34 #include <string.h> |
| 35 #include "base/allocator/partition_allocator/partition_alloc.h" | 35 #include "base/allocator/partition_allocator/partition_alloc.h" |
| 36 #include "base/allocator/partition_allocator/spin_lock.h" | 36 #include "base/allocator/partition_allocator/spin_lock.h" |
| 37 #include "base/numerics/checked_math.h" |
| 37 #include "platform/wtf/Assertions.h" | 38 #include "platform/wtf/Assertions.h" |
| 38 #include "platform/wtf/WTF.h" | 39 #include "platform/wtf/WTF.h" |
| 39 #include "platform/wtf/WTFExport.h" | 40 #include "platform/wtf/WTFExport.h" |
| 40 | 41 |
| 41 namespace WTF { | 42 namespace WTF { |
| 42 | 43 |
| 43 class WTF_EXPORT Partitions { | 44 class WTF_EXPORT Partitions { |
| 44 public: | 45 public: |
| 45 typedef void (*ReportPartitionAllocSizeFunction)(size_t); | 46 typedef void (*ReportPartitionAllocSizeFunction)(size_t); |
| 46 | 47 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 | 62 |
| 62 ALWAYS_INLINE static base::PartitionRootGeneric* FastMallocPartition() { | 63 ALWAYS_INLINE static base::PartitionRootGeneric* FastMallocPartition() { |
| 63 DCHECK(initialized_); | 64 DCHECK(initialized_); |
| 64 return fast_malloc_allocator_.root(); | 65 return fast_malloc_allocator_.root(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 ALWAYS_INLINE static base::PartitionRoot* NodePartition() { | 68 ALWAYS_INLINE static base::PartitionRoot* NodePartition() { |
| 68 NOTREACHED(); | 69 NOTREACHED(); |
| 69 return nullptr; | 70 return nullptr; |
| 70 } | 71 } |
| 72 |
| 71 ALWAYS_INLINE static base::PartitionRoot* LayoutPartition() { | 73 ALWAYS_INLINE static base::PartitionRoot* LayoutPartition() { |
| 72 DCHECK(initialized_); | 74 DCHECK(initialized_); |
| 73 return layout_allocator_.root(); | 75 return layout_allocator_.root(); |
| 74 } | 76 } |
| 75 | 77 |
| 78 ALWAYS_INLINE static size_t ComputeAllocationSize(size_t count, size_t size) { |
| 79 base::CheckedNumeric<size_t> total = count; |
| 80 total *= size; |
| 81 return total.ValueOrDie(); |
| 82 } |
| 83 |
| 76 static size_t CurrentDOMMemoryUsage() { | 84 static size_t CurrentDOMMemoryUsage() { |
| 77 NOTREACHED(); | 85 NOTREACHED(); |
| 78 return 0; | 86 return 0; |
| 79 } | 87 } |
| 80 | 88 |
| 81 static size_t TotalSizeOfCommittedPages() { | 89 static size_t TotalSizeOfCommittedPages() { |
| 82 size_t total_size = 0; | 90 size_t total_size = 0; |
| 83 total_size += fast_malloc_allocator_.root()->total_size_of_committed_pages; | 91 total_size += fast_malloc_allocator_.root()->total_size_of_committed_pages; |
| 84 total_size += array_buffer_allocator_.root()->total_size_of_committed_pages; | 92 total_size += array_buffer_allocator_.root()->total_size_of_committed_pages; |
| 85 total_size += buffer_allocator_.root()->total_size_of_committed_pages; | 93 total_size += buffer_allocator_.root()->total_size_of_committed_pages; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 using base::PageAccessible; | 167 using base::PageAccessible; |
| 160 using base::PageInaccessible; | 168 using base::PageInaccessible; |
| 161 using base::PartitionStatsDumper; | 169 using base::PartitionStatsDumper; |
| 162 using base::PartitionMemoryStats; | 170 using base::PartitionMemoryStats; |
| 163 using base::PartitionBucketMemoryStats; | 171 using base::PartitionBucketMemoryStats; |
| 164 using base::PartitionAllocHooks; | 172 using base::PartitionAllocHooks; |
| 165 | 173 |
| 166 } // namespace WTF | 174 } // namespace WTF |
| 167 | 175 |
| 168 #endif // Partitions_h | 176 #endif // Partitions_h |
| OLD | NEW |