| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/zone-pool.h" | 5 #include "src/compiler/zone-pool.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 size_t current_total = GetCurrentAllocatedBytes(); | 57 size_t current_total = GetCurrentAllocatedBytes(); |
| 58 // Update max. | 58 // Update max. |
| 59 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total); | 59 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total); |
| 60 // Drop zone from initial value map. | 60 // Drop zone from initial value map. |
| 61 InitialValues::iterator it = initial_values_.find(zone); | 61 InitialValues::iterator it = initial_values_.find(zone); |
| 62 if (it != initial_values_.end()) { | 62 if (it != initial_values_.end()) { |
| 63 initial_values_.erase(it); | 63 initial_values_.erase(it); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 ZonePool::ZonePool(base::AccountingAllocator* allocator) |
| 68 ZonePool::ZonePool() : max_allocated_bytes_(0), total_deleted_bytes_(0) {} | 68 : max_allocated_bytes_(0), total_deleted_bytes_(0), allocator_(allocator) {} |
| 69 | |
| 70 | 69 |
| 71 ZonePool::~ZonePool() { | 70 ZonePool::~ZonePool() { |
| 72 DCHECK(used_.empty()); | 71 DCHECK(used_.empty()); |
| 73 DCHECK(stats_.empty()); | 72 DCHECK(stats_.empty()); |
| 74 for (Zone* zone : unused_) { | 73 for (Zone* zone : unused_) { |
| 75 delete zone; | 74 delete zone; |
| 76 } | 75 } |
| 77 } | 76 } |
| 78 | 77 |
| 79 | 78 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 } | 95 } |
| 97 | 96 |
| 98 | 97 |
| 99 Zone* ZonePool::NewEmptyZone() { | 98 Zone* ZonePool::NewEmptyZone() { |
| 100 Zone* zone; | 99 Zone* zone; |
| 101 // Grab a zone from pool if possible. | 100 // Grab a zone from pool if possible. |
| 102 if (!unused_.empty()) { | 101 if (!unused_.empty()) { |
| 103 zone = unused_.back(); | 102 zone = unused_.back(); |
| 104 unused_.pop_back(); | 103 unused_.pop_back(); |
| 105 } else { | 104 } else { |
| 106 zone = new Zone(); | 105 zone = new Zone(allocator_); |
| 107 } | 106 } |
| 108 used_.push_back(zone); | 107 used_.push_back(zone); |
| 109 DCHECK_EQ(0u, zone->allocation_size()); | 108 DCHECK_EQ(0u, zone->allocation_size()); |
| 110 return zone; | 109 return zone; |
| 111 } | 110 } |
| 112 | 111 |
| 113 | 112 |
| 114 void ZonePool::ReturnZone(Zone* zone) { | 113 void ZonePool::ReturnZone(Zone* zone) { |
| 115 size_t current_total = GetCurrentAllocatedBytes(); | 114 size_t current_total = GetCurrentAllocatedBytes(); |
| 116 // Update max. | 115 // Update max. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 130 } else { | 129 } else { |
| 131 zone->DeleteAll(); | 130 zone->DeleteAll(); |
| 132 DCHECK_EQ(0u, zone->allocation_size()); | 131 DCHECK_EQ(0u, zone->allocation_size()); |
| 133 unused_.push_back(zone); | 132 unused_.push_back(zone); |
| 134 } | 133 } |
| 135 } | 134 } |
| 136 | 135 |
| 137 } // namespace compiler | 136 } // namespace compiler |
| 138 } // namespace internal | 137 } // namespace internal |
| 139 } // namespace v8 | 138 } // namespace v8 |
| OLD | NEW |