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

Side by Side Diff: src/compiler/zone-stats.cc

Issue 2957693002: Merged changes to avoid OOM for large wasm modules. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/compiler/zone-stats.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-stats.h" 5 #include "src/compiler/zone-stats.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 ZoneStats::ZoneStats(AccountingAllocator* allocator) 63 ZoneStats::ZoneStats(AccountingAllocator* allocator)
64 : max_allocated_bytes_(0), total_deleted_bytes_(0), allocator_(allocator) {} 64 : max_allocated_bytes_(0), total_deleted_bytes_(0), allocator_(allocator) {}
65 65
66 ZoneStats::~ZoneStats() { 66 ZoneStats::~ZoneStats() {
67 DCHECK(zones_.empty()); 67 DCHECK(zones_.empty());
68 DCHECK(stats_.empty()); 68 DCHECK(stats_.empty());
69 } 69 }
70 70
71 size_t ZoneStats::GetMaxAllocatedBytes() { 71 size_t ZoneStats::GetMaxAllocatedBytes() const {
72 return std::max(max_allocated_bytes_, GetCurrentAllocatedBytes()); 72 return std::max(max_allocated_bytes_, GetCurrentAllocatedBytes());
73 } 73 }
74 74
75 size_t ZoneStats::GetCurrentAllocatedBytes() { 75 size_t ZoneStats::GetCurrentAllocatedBytes() const {
76 size_t total = 0; 76 size_t total = 0;
77 for (Zone* zone : zones_) { 77 for (Zone* zone : zones_) {
78 total += static_cast<size_t>(zone->allocation_size()); 78 total += static_cast<size_t>(zone->allocation_size());
79 } 79 }
80 return total; 80 return total;
81 } 81 }
82 82
83 size_t ZoneStats::GetTotalAllocatedBytes() { 83 size_t ZoneStats::GetTotalAllocatedBytes() const {
84 return total_deleted_bytes_ + GetCurrentAllocatedBytes(); 84 return total_deleted_bytes_ + GetCurrentAllocatedBytes();
85 } 85 }
86 86
87 Zone* ZoneStats::NewEmptyZone(const char* zone_name) { 87 Zone* ZoneStats::NewEmptyZone(const char* zone_name) {
88 Zone* zone = new Zone(allocator_, zone_name); 88 Zone* zone = new Zone(allocator_, zone_name);
89 zones_.push_back(zone); 89 zones_.push_back(zone);
90 return zone; 90 return zone;
91 } 91 }
92 92
93 void ZoneStats::ReturnZone(Zone* zone) { 93 void ZoneStats::ReturnZone(Zone* zone) {
94 size_t current_total = GetCurrentAllocatedBytes(); 94 size_t current_total = GetCurrentAllocatedBytes();
95 // Update max. 95 // Update max.
96 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total); 96 max_allocated_bytes_ = std::max(max_allocated_bytes_, current_total);
97 // Update stats. 97 // Update stats.
98 for (StatsScope* stat_scope : stats_) { 98 for (StatsScope* stat_scope : stats_) {
99 stat_scope->ZoneReturned(zone); 99 stat_scope->ZoneReturned(zone);
100 } 100 }
101 // Remove from used. 101 // Remove from used.
102 Zones::iterator it = std::find(zones_.begin(), zones_.end(), zone); 102 Zones::iterator it = std::find(zones_.begin(), zones_.end(), zone);
103 DCHECK(it != zones_.end()); 103 DCHECK(it != zones_.end());
104 zones_.erase(it); 104 zones_.erase(it);
105 total_deleted_bytes_ += static_cast<size_t>(zone->allocation_size()); 105 total_deleted_bytes_ += static_cast<size_t>(zone->allocation_size());
106 delete zone; 106 delete zone;
107 } 107 }
108 108
109 } // namespace compiler 109 } // namespace compiler
110 } // namespace internal 110 } // namespace internal
111 } // namespace v8 111 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/zone-stats.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698