OLD | NEW |
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" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // instead use OS::SCreate and OS::VSCreate. | 60 // instead use OS::SCreate and OS::VSCreate. |
61 // Make a zone-allocated string based on printf format and args. | 61 // Make a zone-allocated string based on printf format and args. |
62 char* PrintToString(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 62 char* PrintToString(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
63 char* VPrint(const char* format, va_list args); | 63 char* VPrint(const char* format, va_list args); |
64 | 64 |
65 // 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 |
66 // due to internal fragmentation in the segments. | 66 // due to internal fragmentation in the segments. |
67 intptr_t SizeInBytes() const; | 67 intptr_t SizeInBytes() const; |
68 | 68 |
69 // Computes the amount of space used in the zone. | 69 // Computes the amount of space used in the zone. |
70 intptr_t UsedSizeInBytes() const { | 70 intptr_t CapacityInBytes() const; |
71 return SizeInBytes() - (limit_ - position_); | |
72 } | |
73 | 71 |
74 // Structure for managing handles allocation. | 72 // Structure for managing handles allocation. |
75 VMHandles* handles() { return &handles_; } | 73 VMHandles* handles() { return &handles_; } |
76 | 74 |
77 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 75 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
78 | 76 |
79 Zone* previous() const { return previous_; } | 77 Zone* previous() const { return previous_; } |
80 | 78 |
81 #ifndef PRODUCT | 79 #ifndef PRODUCT |
82 void PrintJSON(JSONStream* stream) const; | 80 void PrintJSON(JSONStream* stream) const; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 explicit StackZone(Thread* thread); | 176 explicit StackZone(Thread* thread); |
179 | 177 |
180 // Delete all memory associated with the zone. | 178 // Delete all memory associated with the zone. |
181 ~StackZone(); | 179 ~StackZone(); |
182 | 180 |
183 // Compute the total size of this zone. This includes wasted space that is | 181 // Compute the total size of this zone. This includes wasted space that is |
184 // due to internal fragmentation in the segments. | 182 // due to internal fragmentation in the segments. |
185 intptr_t SizeInBytes() const { return zone_.SizeInBytes(); } | 183 intptr_t SizeInBytes() const { return zone_.SizeInBytes(); } |
186 | 184 |
187 // Computes the used space in the zone. | 185 // Computes the used space in the zone. |
188 intptr_t UsedSizeInBytes() const { return zone_.UsedSizeInBytes(); } | 186 intptr_t CapacityInBytes() const { return zone_.CapacityInBytes(); } |
189 | 187 |
190 Zone* GetZone() { return &zone_; } | 188 Zone* GetZone() { return &zone_; } |
191 | 189 |
192 private: | 190 private: |
193 Zone zone_; | 191 Zone zone_; |
194 | 192 |
195 template <typename T> | 193 template <typename T> |
196 friend class GrowableArray; | 194 friend class GrowableArray; |
197 template <typename T> | 195 template <typename T> |
198 friend class ZoneGrowableArray; | 196 friend class ZoneGrowableArray; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (old_data != 0) { | 263 if (old_data != 0) { |
266 memmove(reinterpret_cast<void*>(new_data), | 264 memmove(reinterpret_cast<void*>(new_data), |
267 reinterpret_cast<void*>(old_data), old_len * kElementSize); | 265 reinterpret_cast<void*>(old_data), old_len * kElementSize); |
268 } | 266 } |
269 return new_data; | 267 return new_data; |
270 } | 268 } |
271 | 269 |
272 } // namespace dart | 270 } // namespace dart |
273 | 271 |
274 #endif // RUNTIME_VM_ZONE_H_ | 272 #endif // RUNTIME_VM_ZONE_H_ |
OLD | NEW |