Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: src/compiler/zone-stats.cc

Issue 2348303002: Replaced different means of zone pooling/reusing by one zone segment pool (Closed)
Patch Set: Added most recent changes from master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/zone-stats.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/zone-stats.cc
diff --git a/src/compiler/zone-pool.cc b/src/compiler/zone-stats.cc
similarity index 52%
rename from src/compiler/zone-pool.cc
rename to src/compiler/zone-stats.cc
index 7681eeb5d17dbc831b96372cddf438cdd0d6906e..62241a494690f453e043b4d02a4435dc1aded83a 100644
--- a/src/compiler/zone-pool.cc
+++ b/src/compiler/zone-stats.cc
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/zone-pool.h"
+#include "src/compiler/zone-stats.h"
namespace v8 {
namespace internal {
namespace compiler {
-ZonePool::StatsScope::StatsScope(ZonePool* zone_pool)
- : zone_pool_(zone_pool),
- total_allocated_bytes_at_start_(zone_pool->GetTotalAllocatedBytes()),
+ZoneStats::StatsScope::StatsScope(ZoneStats* zone_stats)
+ : zone_stats_(zone_stats),
+ total_allocated_bytes_at_start_(zone_stats->GetTotalAllocatedBytes()),
max_allocated_bytes_(0) {
- zone_pool_->stats_.push_back(this);
- for (Zone* zone : zone_pool_->used_) {
+ zone_stats_->stats_.push_back(this);
+ for (Zone* zone : zone_stats_->zones_) {
size_t size = static_cast<size_t>(zone->allocation_size());
std::pair<InitialValues::iterator, bool> res =
initial_values_.insert(std::make_pair(zone, size));
@@ -22,21 +22,18 @@ ZonePool::StatsScope::StatsScope(ZonePool* zone_pool)
}
}
-
-ZonePool::StatsScope::~StatsScope() {
- DCHECK_EQ(zone_pool_->stats_.back(), this);
- zone_pool_->stats_.pop_back();
+ZoneStats::StatsScope::~StatsScope() {
+ DCHECK_EQ(zone_stats_->stats_.back(), this);
+ zone_stats_->stats_.pop_back();
}
-
-size_t ZonePool::StatsScope::GetMaxAllocatedBytes() {
+size_t ZoneStats::StatsScope::GetMaxAllocatedBytes() {
return std::max(max_allocated_bytes_, GetCurrentAllocatedBytes());
}
-
-size_t ZonePool::StatsScope::GetCurrentAllocatedBytes() {
+size_t ZoneStats::StatsScope::GetCurrentAllocatedBytes() {
size_t total = 0;
- for (Zone* zone : zone_pool_->used_) {
+ for (Zone* zone : zone_stats_->zones_) {
total += static_cast<size_t>(zone->allocation_size());
// Adjust for initial values.
InitialValues::iterator it = initial_values_.find(zone);
@@ -47,13 +44,12 @@ size_t ZonePool::StatsScope::GetCurrentAllocatedBytes() {
return total;
}
-
-size_t ZonePool::StatsScope::GetTotalAllocatedBytes() {
- return zone_pool_->GetTotalAllocatedBytes() - total_allocated_bytes_at_start_;
+size_t ZoneStats::StatsScope::GetTotalAllocatedBytes() {
+ return zone_stats_->GetTotalAllocatedBytes() -
+ total_allocated_bytes_at_start_;
}
-
-void ZonePool::StatsScope::ZoneReturned(Zone* zone) {
+void ZoneStats::StatsScope::ZoneReturned(Zone* zone) {
size_t current_total = GetCurrentAllocatedBytes();
// Update max.
max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total);
@@ -64,53 +60,37 @@ void ZonePool::StatsScope::ZoneReturned(Zone* zone) {
}
}
-ZonePool::ZonePool(AccountingAllocator* allocator)
+ZoneStats::ZoneStats(AccountingAllocator* allocator)
: max_allocated_bytes_(0), total_deleted_bytes_(0), allocator_(allocator) {}
-ZonePool::~ZonePool() {
- DCHECK(used_.empty());
+ZoneStats::~ZoneStats() {
+ DCHECK(zones_.empty());
DCHECK(stats_.empty());
- for (Zone* zone : unused_) {
- delete zone;
- }
}
-
-size_t ZonePool::GetMaxAllocatedBytes() {
+size_t ZoneStats::GetMaxAllocatedBytes() {
return std::max(max_allocated_bytes_, GetCurrentAllocatedBytes());
}
-
-size_t ZonePool::GetCurrentAllocatedBytes() {
+size_t ZoneStats::GetCurrentAllocatedBytes() {
size_t total = 0;
- for (Zone* zone : used_) {
+ for (Zone* zone : zones_) {
total += static_cast<size_t>(zone->allocation_size());
}
return total;
}
-
-size_t ZonePool::GetTotalAllocatedBytes() {
+size_t ZoneStats::GetTotalAllocatedBytes() {
return total_deleted_bytes_ + GetCurrentAllocatedBytes();
}
-
-Zone* ZonePool::NewEmptyZone() {
- Zone* zone;
- // Grab a zone from pool if possible.
- if (!unused_.empty()) {
- zone = unused_.back();
- unused_.pop_back();
- } else {
- zone = new Zone(allocator_);
- }
- used_.push_back(zone);
- DCHECK_EQ(0u, zone->allocation_size());
+Zone* ZoneStats::NewEmptyZone() {
+ Zone* zone = new Zone(allocator_);
+ zones_.push_back(zone);
return zone;
}
-
-void ZonePool::ReturnZone(Zone* zone) {
+void ZoneStats::ReturnZone(Zone* zone) {
size_t current_total = GetCurrentAllocatedBytes();
// Update max.
max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total);
@@ -119,18 +99,11 @@ void ZonePool::ReturnZone(Zone* zone) {
stat_scope->ZoneReturned(zone);
}
// Remove from used.
- Used::iterator it = std::find(used_.begin(), used_.end(), zone);
- DCHECK(it != used_.end());
- used_.erase(it);
+ Zones::iterator it = std::find(zones_.begin(), zones_.end(), zone);
+ DCHECK(it != zones_.end());
+ zones_.erase(it);
total_deleted_bytes_ += static_cast<size_t>(zone->allocation_size());
- // Delete zone or clear and stash on unused_.
- if (unused_.size() >= kMaxUnusedSize) {
- delete zone;
- } else {
- zone->DeleteAll();
- DCHECK_EQ(0u, zone->allocation_size());
- unused_.push_back(zone);
- }
+ delete zone;
}
} // namespace compiler
« no previous file with comments | « src/compiler/zone-stats.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698