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

Unified Diff: runtime/vm/zone.cc

Issue 2570763002: Fixed bad calculations for determining total allocated size of a zone. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/zone.h ('k') | runtime/vm/zone_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/zone.cc
diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc
index 2632f3a3e5436f8a19b6522880d09741a4fffaec..36e962260dd30ed433c67ff89812392ece46ec04 100644
--- a/runtime/vm/zone.cc
+++ b/runtime/vm/zone.cc
@@ -136,6 +136,22 @@ intptr_t Zone::SizeInBytes() const {
}
+intptr_t Zone::CapacityInBytes() const {
+ intptr_t size = 0;
+ for (Segment* s = large_segments_; s != NULL; s = s->next()) {
+ size += s->size();
+ }
+ if (head_ == NULL) {
+ return size + initial_buffer_.size();
+ }
+ size += initial_buffer_.size();
+ for (Segment* s = head_; s != NULL; s = s->next()) {
+ size += s->size();
+ }
+ return size;
+}
+
+
uword Zone::AllocateExpand(intptr_t size) {
ASSERT(size >= 0);
if (FLAG_trace_zones) {
@@ -263,8 +279,8 @@ char* Zone::VPrint(const char* format, va_list args) {
#ifndef PRODUCT
void Zone::PrintJSON(JSONStream* stream) const {
JSONObject jsobj(stream);
- intptr_t capacity = SizeInBytes();
- intptr_t used_size = UsedSizeInBytes();
+ intptr_t capacity = CapacityInBytes();
+ intptr_t used_size = SizeInBytes();
jsobj.AddProperty("type", "_Zone");
jsobj.AddProperty("capacity", capacity);
jsobj.AddProperty("used", used_size);
« no previous file with comments | « runtime/vm/zone.h ('k') | runtime/vm/zone_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698