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_POOL_H_ | 5 #ifndef V8_COMPILER_ZONE_POOL_H_ |
6 #define V8_COMPILER_ZONE_POOL_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.h" | 12 #include "src/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 ZonePool FINAL { | 18 class ZonePool final { |
19 public: | 19 public: |
20 class Scope FINAL { | 20 class Scope final { |
21 public: | 21 public: |
22 explicit Scope(ZonePool* zone_pool) : zone_pool_(zone_pool), zone_(NULL) {} | 22 explicit Scope(ZonePool* zone_pool) : zone_pool_(zone_pool), zone_(NULL) {} |
23 ~Scope() { Destroy(); } | 23 ~Scope() { Destroy(); } |
24 | 24 |
25 Zone* zone() { | 25 Zone* zone() { |
26 if (zone_ == NULL) zone_ = zone_pool_->NewEmptyZone(); | 26 if (zone_ == NULL) zone_ = zone_pool_->NewEmptyZone(); |
27 return zone_; | 27 return zone_; |
28 } | 28 } |
29 void Destroy() { | 29 void Destroy() { |
30 if (zone_ != NULL) zone_pool_->ReturnZone(zone_); | 30 if (zone_ != NULL) zone_pool_->ReturnZone(zone_); |
31 zone_ = NULL; | 31 zone_ = NULL; |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 ZonePool* const zone_pool_; | 35 ZonePool* const zone_pool_; |
36 Zone* zone_; | 36 Zone* zone_; |
37 DISALLOW_COPY_AND_ASSIGN(Scope); | 37 DISALLOW_COPY_AND_ASSIGN(Scope); |
38 }; | 38 }; |
39 | 39 |
40 class StatsScope FINAL { | 40 class StatsScope final { |
41 public: | 41 public: |
42 explicit StatsScope(ZonePool* zone_pool); | 42 explicit StatsScope(ZonePool* zone_pool); |
43 ~StatsScope(); | 43 ~StatsScope(); |
44 | 44 |
45 size_t GetMaxAllocatedBytes(); | 45 size_t GetMaxAllocatedBytes(); |
46 size_t GetCurrentAllocatedBytes(); | 46 size_t GetCurrentAllocatedBytes(); |
47 size_t GetTotalAllocatedBytes(); | 47 size_t GetTotalAllocatedBytes(); |
48 | 48 |
49 private: | 49 private: |
50 friend class ZonePool; | 50 friend class ZonePool; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 size_t total_deleted_bytes_; | 83 size_t total_deleted_bytes_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(ZonePool); | 85 DISALLOW_COPY_AND_ASSIGN(ZonePool); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace compiler | 88 } // namespace compiler |
89 } // namespace internal | 89 } // namespace internal |
90 } // namespace v8 | 90 } // namespace v8 |
91 | 91 |
92 #endif | 92 #endif |
OLD | NEW |