| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 68 ZonePool::ZonePool(Isolate* isolate) | 68 ZonePool::ZonePool() : max_allocated_bytes_(0), total_deleted_bytes_(0) {} |
| 69 : isolate_(isolate), max_allocated_bytes_(0), total_deleted_bytes_(0) {} | |
| 70 | 69 |
| 71 | 70 |
| 72 ZonePool::~ZonePool() { | 71 ZonePool::~ZonePool() { |
| 73 DCHECK(used_.empty()); | 72 DCHECK(used_.empty()); |
| 74 DCHECK(stats_.empty()); | 73 DCHECK(stats_.empty()); |
| 75 for (Zone* zone : unused_) { | 74 for (Zone* zone : unused_) { |
| 76 delete zone; | 75 delete zone; |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 97 } | 96 } |
| 98 | 97 |
| 99 | 98 |
| 100 Zone* ZonePool::NewEmptyZone() { | 99 Zone* ZonePool::NewEmptyZone() { |
| 101 Zone* zone; | 100 Zone* zone; |
| 102 // Grab a zone from pool if possible. | 101 // Grab a zone from pool if possible. |
| 103 if (!unused_.empty()) { | 102 if (!unused_.empty()) { |
| 104 zone = unused_.back(); | 103 zone = unused_.back(); |
| 105 unused_.pop_back(); | 104 unused_.pop_back(); |
| 106 } else { | 105 } else { |
| 107 zone = new Zone(isolate_); | 106 zone = new Zone(); |
| 108 } | 107 } |
| 109 used_.push_back(zone); | 108 used_.push_back(zone); |
| 110 DCHECK_EQ(0, zone->allocation_size()); | 109 DCHECK_EQ(0, zone->allocation_size()); |
| 111 return zone; | 110 return zone; |
| 112 } | 111 } |
| 113 | 112 |
| 114 | 113 |
| 115 void ZonePool::ReturnZone(Zone* zone) { | 114 void ZonePool::ReturnZone(Zone* zone) { |
| 116 size_t current_total = GetCurrentAllocatedBytes(); | 115 size_t current_total = GetCurrentAllocatedBytes(); |
| 117 // Update max. | 116 // Update max. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 131 } else { | 130 } else { |
| 132 zone->DeleteAll(); | 131 zone->DeleteAll(); |
| 133 DCHECK_EQ(0, zone->allocation_size()); | 132 DCHECK_EQ(0, zone->allocation_size()); |
| 134 unused_.push_back(zone); | 133 unused_.push_back(zone); |
| 135 } | 134 } |
| 136 } | 135 } |
| 137 | 136 |
| 138 } // namespace compiler | 137 } // namespace compiler |
| 139 } // namespace internal | 138 } // namespace internal |
| 140 } // namespace v8 | 139 } // namespace v8 |
| OLD | NEW |