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

Side by Side Diff: runtime/vm/zone.h

Issue 2554983002: Created methods to surface zone memory information for each isolate and thread in JSON. (Closed)
Patch Set: Created methods to surface zone memory information for each isolate and thread in JSON. Created 4 years 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 | « runtime/vm/thread_test.cc ('k') | runtime/vm/zone.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_ZONE_H_ 5 #ifndef RUNTIME_VM_ZONE_H_
6 #define RUNTIME_VM_ZONE_H_ 6 #define RUNTIME_VM_ZONE_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/handles.h" 10 #include "vm/handles.h"
11 #include "vm/json_stream.h"
11 #include "vm/thread.h" 12 #include "vm/thread.h"
12 #include "vm/memory_region.h" 13 #include "vm/memory_region.h"
13 14
14 namespace dart { 15 namespace dart {
15 16
16 // Zones support very fast allocation of small chunks of memory. The 17 // Zones support very fast allocation of small chunks of memory. The
17 // chunks cannot be deallocated individually, but instead zones 18 // chunks cannot be deallocated individually, but instead zones
18 // support deallocating all chunks in one fast operation. 19 // support deallocating all chunks in one fast operation.
19 20
20 class Zone { 21 class Zone {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // These calls are deprecated. Do not add further calls to these functions. 59 // These calls are deprecated. Do not add further calls to these functions.
59 // instead use OS::SCreate and OS::VSCreate. 60 // instead use OS::SCreate and OS::VSCreate.
60 // Make a zone-allocated string based on printf format and args. 61 // Make a zone-allocated string based on printf format and args.
61 char* PrintToString(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 62 char* PrintToString(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
62 char* VPrint(const char* format, va_list args); 63 char* VPrint(const char* format, va_list args);
63 64
64 // Compute the total size of this zone. This includes wasted space that is 65 // Compute the total size of this zone. This includes wasted space that is
65 // due to internal fragmentation in the segments. 66 // due to internal fragmentation in the segments.
66 intptr_t SizeInBytes() const; 67 intptr_t SizeInBytes() const;
67 68
69 // Computes the amount of space used in the zone.
70 intptr_t UsedSizeInBytes() const {
71 return SizeInBytes() - (limit_ - position_);
72 }
73
68 // Structure for managing handles allocation. 74 // Structure for managing handles allocation.
69 VMHandles* handles() { return &handles_; } 75 VMHandles* handles() { return &handles_; }
70 76
71 void VisitObjectPointers(ObjectPointerVisitor* visitor); 77 void VisitObjectPointers(ObjectPointerVisitor* visitor);
72 78
73 Zone* previous() const { return previous_; } 79 Zone* previous() const { return previous_; }
74 80
81 #ifndef PRODUCT
82 void PrintJSON(JSONStream* stream) const;
83 #endif
84
75 private: 85 private:
76 Zone(); 86 Zone();
77 ~Zone(); // Delete all memory associated with the zone. 87 ~Zone(); // Delete all memory associated with the zone.
78 88
79 // All pointers returned from AllocateUnsafe() and New() have this alignment. 89 // All pointers returned from AllocateUnsafe() and New() have this alignment.
80 static const intptr_t kAlignment = kDoubleSize; 90 static const intptr_t kAlignment = kDoubleSize;
81 91
82 // Default initial chunk size. 92 // Default initial chunk size.
83 static const intptr_t kInitialChunkSize = 1 * KB; 93 static const intptr_t kInitialChunkSize = 1 * KB;
84 94
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Create an empty zone and set is at the current zone for the Thread. 177 // Create an empty zone and set is at the current zone for the Thread.
168 explicit StackZone(Thread* thread); 178 explicit StackZone(Thread* thread);
169 179
170 // Delete all memory associated with the zone. 180 // Delete all memory associated with the zone.
171 ~StackZone(); 181 ~StackZone();
172 182
173 // Compute the total size of this zone. This includes wasted space that is 183 // Compute the total size of this zone. This includes wasted space that is
174 // due to internal fragmentation in the segments. 184 // due to internal fragmentation in the segments.
175 intptr_t SizeInBytes() const { return zone_.SizeInBytes(); } 185 intptr_t SizeInBytes() const { return zone_.SizeInBytes(); }
176 186
187 // Computes the used space in the zone.
188 intptr_t UsedSizeInBytes() const { return zone_.UsedSizeInBytes(); }
189
177 Zone* GetZone() { return &zone_; } 190 Zone* GetZone() { return &zone_; }
178 191
179 private: 192 private:
180 Zone zone_; 193 Zone zone_;
181 194
182 template <typename T> 195 template <typename T>
183 friend class GrowableArray; 196 friend class GrowableArray;
184 template <typename T> 197 template <typename T>
185 friend class ZoneGrowableArray; 198 friend class ZoneGrowableArray;
186 199
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (old_data != 0) { 265 if (old_data != 0) {
253 memmove(reinterpret_cast<void*>(new_data), 266 memmove(reinterpret_cast<void*>(new_data),
254 reinterpret_cast<void*>(old_data), old_len * kElementSize); 267 reinterpret_cast<void*>(old_data), old_len * kElementSize);
255 } 268 }
256 return new_data; 269 return new_data;
257 } 270 }
258 271
259 } // namespace dart 272 } // namespace dart
260 273
261 #endif // RUNTIME_VM_ZONE_H_ 274 #endif // RUNTIME_VM_ZONE_H_
OLDNEW
« no previous file with comments | « runtime/vm/thread_test.cc ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698