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 #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/zone/zone.h" | 13 #include "src/zone/zone.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace compiler { | 17 namespace compiler { |
17 | 18 |
18 class ZoneStats final { | 19 class V8_EXPORT_PRIVATE ZoneStats final { |
19 public: | 20 public: |
20 class Scope final { | 21 class Scope final { |
21 public: | 22 public: |
22 explicit Scope(ZoneStats* zone_stats) | 23 explicit Scope(ZoneStats* zone_stats) |
23 : zone_stats_(zone_stats), zone_(nullptr) {} | 24 : zone_stats_(zone_stats), zone_(nullptr) {} |
24 ~Scope() { Destroy(); } | 25 ~Scope() { Destroy(); } |
25 | 26 |
26 Zone* zone() { | 27 Zone* zone() { |
27 if (zone_ == nullptr) zone_ = zone_stats_->NewEmptyZone(); | 28 if (zone_ == nullptr) zone_ = zone_stats_->NewEmptyZone(); |
28 return zone_; | 29 return zone_; |
29 } | 30 } |
30 void Destroy() { | 31 void Destroy() { |
31 if (zone_ != nullptr) zone_stats_->ReturnZone(zone_); | 32 if (zone_ != nullptr) zone_stats_->ReturnZone(zone_); |
32 zone_ = nullptr; | 33 zone_ = nullptr; |
33 } | 34 } |
34 | 35 |
35 private: | 36 private: |
36 ZoneStats* const zone_stats_; | 37 ZoneStats* const zone_stats_; |
37 Zone* zone_; | 38 Zone* zone_; |
38 DISALLOW_COPY_AND_ASSIGN(Scope); | 39 DISALLOW_COPY_AND_ASSIGN(Scope); |
39 }; | 40 }; |
40 | 41 |
41 class StatsScope final { | 42 class V8_EXPORT_PRIVATE StatsScope final { |
42 public: | 43 public: |
43 explicit StatsScope(ZoneStats* zone_stats); | 44 explicit StatsScope(ZoneStats* zone_stats); |
44 ~StatsScope(); | 45 ~StatsScope(); |
45 | 46 |
46 size_t GetMaxAllocatedBytes(); | 47 size_t GetMaxAllocatedBytes(); |
47 size_t GetCurrentAllocatedBytes(); | 48 size_t GetCurrentAllocatedBytes(); |
48 size_t GetTotalAllocatedBytes(); | 49 size_t GetTotalAllocatedBytes(); |
49 | 50 |
50 private: | 51 private: |
51 friend class ZoneStats; | 52 friend class ZoneStats; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 AccountingAllocator* allocator_; | 84 AccountingAllocator* allocator_; |
84 | 85 |
85 DISALLOW_COPY_AND_ASSIGN(ZoneStats); | 86 DISALLOW_COPY_AND_ASSIGN(ZoneStats); |
86 }; | 87 }; |
87 | 88 |
88 } // namespace compiler | 89 } // namespace compiler |
89 } // namespace internal | 90 } // namespace internal |
90 } // namespace v8 | 91 } // namespace v8 |
91 | 92 |
92 #endif // V8_COMPILER_ZONE_STATS_H_ | 93 #endif // V8_COMPILER_ZONE_STATS_H_ |
OLD | NEW |