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

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

Issue 2394213003: Named all zones in the project (Closed)
Patch Set: Merge branch 'master' into zonenames 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 unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/zone-stats.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 #ifndef V8_COMPILER_ZONE_STATS_H_ 5 #ifndef V8_COMPILER_ZONE_STATS_H_
6 #define V8_COMPILER_ZONE_STATS_H_ 6 #define V8_COMPILER_ZONE_STATS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "src/globals.h" 12 #include "src/globals.h"
13 #include "src/zone/zone.h" 13 #include "src/zone/zone.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 namespace compiler { 17 namespace compiler {
18 18
19 class V8_EXPORT_PRIVATE ZoneStats final { 19 class V8_EXPORT_PRIVATE ZoneStats final {
20 public: 20 public:
21 class Scope final { 21 class Scope final {
22 public: 22 public:
23 explicit Scope(ZoneStats* zone_stats) 23 explicit Scope(ZoneStats* zone_stats, const char* zone_name)
24 : zone_stats_(zone_stats), zone_(nullptr) {} 24 : zone_name_(zone_name), zone_stats_(zone_stats), zone_(nullptr) {}
25 ~Scope() { Destroy(); } 25 ~Scope() { Destroy(); }
26 26
27 Zone* zone() { 27 Zone* zone() {
28 if (zone_ == nullptr) zone_ = zone_stats_->NewEmptyZone(); 28 if (zone_ == nullptr) zone_ = zone_stats_->NewEmptyZone(zone_name_);
29 return zone_; 29 return zone_;
30 } 30 }
31 void Destroy() { 31 void Destroy() {
32 if (zone_ != nullptr) zone_stats_->ReturnZone(zone_); 32 if (zone_ != nullptr) zone_stats_->ReturnZone(zone_);
33 zone_ = nullptr; 33 zone_ = nullptr;
34 } 34 }
35 35
36 private: 36 private:
37 const char* zone_name_;
37 ZoneStats* const zone_stats_; 38 ZoneStats* const zone_stats_;
38 Zone* zone_; 39 Zone* zone_;
39 DISALLOW_COPY_AND_ASSIGN(Scope); 40 DISALLOW_COPY_AND_ASSIGN(Scope);
40 }; 41 };
41 42
42 class V8_EXPORT_PRIVATE StatsScope final { 43 class V8_EXPORT_PRIVATE StatsScope final {
43 public: 44 public:
44 explicit StatsScope(ZoneStats* zone_stats); 45 explicit StatsScope(ZoneStats* zone_stats);
45 ~StatsScope(); 46 ~StatsScope();
46 47
(...skipping 16 matching lines...) Expand all
63 }; 64 };
64 65
65 explicit ZoneStats(AccountingAllocator* allocator); 66 explicit ZoneStats(AccountingAllocator* allocator);
66 ~ZoneStats(); 67 ~ZoneStats();
67 68
68 size_t GetMaxAllocatedBytes(); 69 size_t GetMaxAllocatedBytes();
69 size_t GetTotalAllocatedBytes(); 70 size_t GetTotalAllocatedBytes();
70 size_t GetCurrentAllocatedBytes(); 71 size_t GetCurrentAllocatedBytes();
71 72
72 private: 73 private:
73 Zone* NewEmptyZone(); 74 Zone* NewEmptyZone(const char* zone_name);
74 void ReturnZone(Zone* zone); 75 void ReturnZone(Zone* zone);
75 76
76 static const size_t kMaxUnusedSize = 3; 77 static const size_t kMaxUnusedSize = 3;
77 typedef std::vector<Zone*> Zones; 78 typedef std::vector<Zone*> Zones;
78 typedef std::vector<StatsScope*> Stats; 79 typedef std::vector<StatsScope*> Stats;
79 80
80 Zones zones_; 81 Zones zones_;
81 Stats stats_; 82 Stats stats_;
82 size_t max_allocated_bytes_; 83 size_t max_allocated_bytes_;
83 size_t total_deleted_bytes_; 84 size_t total_deleted_bytes_;
84 AccountingAllocator* allocator_; 85 AccountingAllocator* allocator_;
85 86
86 DISALLOW_COPY_AND_ASSIGN(ZoneStats); 87 DISALLOW_COPY_AND_ASSIGN(ZoneStats);
87 }; 88 };
88 89
89 } // namespace compiler 90 } // namespace compiler
90 } // namespace internal 91 } // namespace internal
91 } // namespace v8 92 } // namespace v8
92 93
93 #endif // V8_COMPILER_ZONE_STATS_H_ 94 #endif // V8_COMPILER_ZONE_STATS_H_
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/zone-stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698