| 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 |
| 11 ZonePool::StatsScope::StatsScope(ZonePool* zone_pool) | 11 ZonePool::StatsScope::StatsScope(ZonePool* zone_pool) |
| 12 : zone_pool_(zone_pool), max_allocated_bytes_(0) { | 12 : zone_pool_(zone_pool), |
| 13 total_allocated_bytes_at_start_(zone_pool->GetTotalAllocatedBytes()), |
| 14 max_allocated_bytes_(0) { |
| 13 zone_pool_->stats_.push_back(this); | 15 zone_pool_->stats_.push_back(this); |
| 14 for (auto zone : zone_pool_->used_) { | 16 for (auto zone : zone_pool_->used_) { |
| 15 size_t size = static_cast<size_t>(zone->allocation_size()); | 17 size_t size = static_cast<size_t>(zone->allocation_size()); |
| 16 std::pair<InitialValues::iterator, bool> res = | 18 std::pair<InitialValues::iterator, bool> res = |
| 17 initial_values_.insert(std::make_pair(zone, size)); | 19 initial_values_.insert(std::make_pair(zone, size)); |
| 18 USE(res); | 20 USE(res); |
| 19 DCHECK(res.second); | 21 DCHECK(res.second); |
| 20 } | 22 } |
| 21 } | 23 } |
| 22 | 24 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 // Adjust for initial values. | 41 // Adjust for initial values. |
| 40 InitialValues::iterator it = initial_values_.find(zone); | 42 InitialValues::iterator it = initial_values_.find(zone); |
| 41 if (it != initial_values_.end()) { | 43 if (it != initial_values_.end()) { |
| 42 total -= it->second; | 44 total -= it->second; |
| 43 } | 45 } |
| 44 } | 46 } |
| 45 return total; | 47 return total; |
| 46 } | 48 } |
| 47 | 49 |
| 48 | 50 |
| 51 size_t ZonePool::StatsScope::GetTotalAllocatedBytes() { |
| 52 return zone_pool_->GetTotalAllocatedBytes() - total_allocated_bytes_at_start_; |
| 53 } |
| 54 |
| 55 |
| 49 void ZonePool::StatsScope::ZoneReturned(Zone* zone) { | 56 void ZonePool::StatsScope::ZoneReturned(Zone* zone) { |
| 50 size_t current_total = GetCurrentAllocatedBytes(); | 57 size_t current_total = GetCurrentAllocatedBytes(); |
| 51 // Update max. | 58 // Update max. |
| 52 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total); | 59 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total); |
| 53 // Drop zone from initial value map. | 60 // Drop zone from initial value map. |
| 54 InitialValues::iterator it = initial_values_.find(zone); | 61 InitialValues::iterator it = initial_values_.find(zone); |
| 55 if (it != initial_values_.end()) { | 62 if (it != initial_values_.end()) { |
| 56 initial_values_.erase(it); | 63 initial_values_.erase(it); |
| 57 } | 64 } |
| 58 } | 65 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } else { | 131 } else { |
| 125 zone->DeleteAll(); | 132 zone->DeleteAll(); |
| 126 DCHECK_EQ(0, zone->allocation_size()); | 133 DCHECK_EQ(0, zone->allocation_size()); |
| 127 unused_.push_back(zone); | 134 unused_.push_back(zone); |
| 128 } | 135 } |
| 129 } | 136 } |
| 130 | 137 |
| 131 } // namespace compiler | 138 } // namespace compiler |
| 132 } // namespace internal | 139 } // namespace internal |
| 133 } // namespace v8 | 140 } // namespace v8 |
| OLD | NEW |