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

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

Issue 665893006: [turbofan] add ZonePool to correctly track compiler phase memory usage (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/scheduler.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_ZONE_POOL_H_
6 #define V8_COMPILER_ZONE_POOL_H_
7
8 #include <map>
9 #include <set>
10 #include <vector>
11
12 #include "src/v8.h"
13
14 namespace v8 {
15 namespace internal {
16 namespace compiler {
17
18 class ZonePool FINAL {
19 public:
20 class Scope FINAL {
21 public:
22 explicit Scope(ZonePool* zone_pool) : zone_pool_(zone_pool), zone_(NULL) {}
23 ~Scope() { Destroy(); }
24
25 Zone* zone() {
26 if (zone_ == NULL) zone_ = zone_pool_->NewEmptyZone();
27 return zone_;
28 }
29 void Destroy() {
30 if (zone_ != NULL) zone_pool_->ReturnZone(zone_);
31 zone_ = NULL;
32 }
33
34 private:
35 ZonePool* const zone_pool_;
36 Zone* zone_;
37 DISALLOW_COPY_AND_ASSIGN(Scope);
38 };
39
40 class StatsScope FINAL {
41 public:
42 explicit StatsScope(ZonePool* zone_pool);
43 ~StatsScope();
44
45 size_t GetMaxAllocatedBytes();
46 size_t GetCurrentAllocatedBytes();
47
48 private:
49 friend class ZonePool;
50 void ZoneReturned(Zone* zone);
51
52 typedef std::map<Zone*, size_t> InitialValues;
53
54 ZonePool* const zone_pool_;
55 InitialValues initial_values_;
56 size_t max_allocated_bytes_;
57
58 DISALLOW_COPY_AND_ASSIGN(StatsScope);
59 };
60
61 explicit ZonePool(Isolate* isolate);
62 ~ZonePool();
63
64 size_t GetMaxAllocatedBytes();
65 size_t GetTotalAllocatedBytes();
66 size_t GetCurrentAllocatedBytes();
67
68 private:
69 Zone* NewEmptyZone();
70 void ReturnZone(Zone* zone);
71
72 static const size_t kMaxUnusedSize = 3;
73 typedef std::vector<Zone*> Unused;
74 typedef std::vector<Zone*> Used;
75 typedef std::vector<StatsScope*> Stats;
76
77 Isolate* const isolate_;
78 Unused unused_;
79 Used used_;
80 Stats stats_;
81 size_t max_allocated_bytes_;
82 size_t total_deleted_bytes_;
83
84 DISALLOW_COPY_AND_ASSIGN(ZonePool);
85 };
86
87 } // namespace compiler
88 } // namespace internal
89 } // namespace v8
90
91 #endif
OLDNEW
« no previous file with comments | « src/compiler/scheduler.cc ('k') | src/compiler/zone-pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698