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

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

Issue 2401173002: Version 5.6.1.1 (cherry-pick) (Closed)
Patch Set: 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-pool.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_POOL_H_
6 #define V8_COMPILER_ZONE_STATS_H_ 6 #define V8_COMPILER_ZONE_POOL_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/zone/zone.h" 12 #include "src/zone/zone.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace compiler { 16 namespace compiler {
17 17
18 class ZoneStats final { 18 class ZonePool final {
19 public: 19 public:
20 class Scope final { 20 class Scope final {
21 public: 21 public:
22 explicit Scope(ZoneStats* zone_stats) 22 explicit Scope(ZonePool* zone_pool)
23 : zone_stats_(zone_stats), zone_(nullptr) {} 23 : zone_pool_(zone_pool), zone_(nullptr) {}
24 ~Scope() { Destroy(); } 24 ~Scope() { Destroy(); }
25 25
26 Zone* zone() { 26 Zone* zone() {
27 if (zone_ == nullptr) zone_ = zone_stats_->NewEmptyZone(); 27 if (zone_ == nullptr) zone_ = zone_pool_->NewEmptyZone();
28 return zone_; 28 return zone_;
29 } 29 }
30 void Destroy() { 30 void Destroy() {
31 if (zone_ != nullptr) zone_stats_->ReturnZone(zone_); 31 if (zone_ != nullptr) zone_pool_->ReturnZone(zone_);
32 zone_ = nullptr; 32 zone_ = nullptr;
33 } 33 }
34 34
35 private: 35 private:
36 ZoneStats* const zone_stats_; 36 ZonePool* const zone_pool_;
37 Zone* zone_; 37 Zone* zone_;
38 DISALLOW_COPY_AND_ASSIGN(Scope); 38 DISALLOW_COPY_AND_ASSIGN(Scope);
39 }; 39 };
40 40
41 class StatsScope final { 41 class StatsScope final {
42 public: 42 public:
43 explicit StatsScope(ZoneStats* zone_stats); 43 explicit StatsScope(ZonePool* zone_pool);
44 ~StatsScope(); 44 ~StatsScope();
45 45
46 size_t GetMaxAllocatedBytes(); 46 size_t GetMaxAllocatedBytes();
47 size_t GetCurrentAllocatedBytes(); 47 size_t GetCurrentAllocatedBytes();
48 size_t GetTotalAllocatedBytes(); 48 size_t GetTotalAllocatedBytes();
49 49
50 private: 50 private:
51 friend class ZoneStats; 51 friend class ZonePool;
52 void ZoneReturned(Zone* zone); 52 void ZoneReturned(Zone* zone);
53 53
54 typedef std::map<Zone*, size_t> InitialValues; 54 typedef std::map<Zone*, size_t> InitialValues;
55 55
56 ZoneStats* const zone_stats_; 56 ZonePool* const zone_pool_;
57 InitialValues initial_values_; 57 InitialValues initial_values_;
58 size_t total_allocated_bytes_at_start_; 58 size_t total_allocated_bytes_at_start_;
59 size_t max_allocated_bytes_; 59 size_t max_allocated_bytes_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(StatsScope); 61 DISALLOW_COPY_AND_ASSIGN(StatsScope);
62 }; 62 };
63 63
64 explicit ZoneStats(AccountingAllocator* allocator); 64 explicit ZonePool(AccountingAllocator* allocator);
65 ~ZoneStats(); 65 ~ZonePool();
66 66
67 size_t GetMaxAllocatedBytes(); 67 size_t GetMaxAllocatedBytes();
68 size_t GetTotalAllocatedBytes(); 68 size_t GetTotalAllocatedBytes();
69 size_t GetCurrentAllocatedBytes(); 69 size_t GetCurrentAllocatedBytes();
70 70
71 private: 71 private:
72 Zone* NewEmptyZone(); 72 Zone* NewEmptyZone();
73 void ReturnZone(Zone* zone); 73 void ReturnZone(Zone* zone);
74 74
75 static const size_t kMaxUnusedSize = 3; 75 static const size_t kMaxUnusedSize = 3;
76 typedef std::vector<Zone*> Zones; 76 typedef std::vector<Zone*> Unused;
77 typedef std::vector<Zone*> Used;
77 typedef std::vector<StatsScope*> Stats; 78 typedef std::vector<StatsScope*> Stats;
78 79
79 Zones zones_; 80 Unused unused_;
81 Used used_;
80 Stats stats_; 82 Stats stats_;
81 size_t max_allocated_bytes_; 83 size_t max_allocated_bytes_;
82 size_t total_deleted_bytes_; 84 size_t total_deleted_bytes_;
83 AccountingAllocator* allocator_; 85 AccountingAllocator* allocator_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(ZoneStats); 87 DISALLOW_COPY_AND_ASSIGN(ZonePool);
86 }; 88 };
87 89
88 } // namespace compiler 90 } // namespace compiler
89 } // namespace internal 91 } // namespace internal
90 } // namespace v8 92 } // namespace v8
91 93
92 #endif // V8_COMPILER_ZONE_STATS_H_ 94 #endif
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/zone-pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698