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