mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:21:54 +00:00
Fixed bad calculations for determining total allocated size of a zone.
BUG= R=johnmccutchan@google.com Review-Url: https://codereview.chromium.org/2570763002 .
This commit is contained in:
parent
9f8a85c19b
commit
a3ec04eb99
|
@ -337,7 +337,7 @@ TEST_CASE(ManySimpleTasksWithZones) {
|
|||
"\"capacity\":%" Pd
|
||||
","
|
||||
"\"used\":%" Pd "",
|
||||
top_zone->SizeInBytes(), top_zone->UsedSizeInBytes());
|
||||
top_zone->CapacityInBytes(), top_zone->SizeInBytes());
|
||||
EXPECT_SUBSTRING(zone_info_buf, json);
|
||||
top_zone = top_zone->previous();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -67,9 +67,7 @@ class Zone {
|
|||
intptr_t SizeInBytes() const;
|
||||
|
||||
// Computes the amount of space used in the zone.
|
||||
intptr_t UsedSizeInBytes() const {
|
||||
return SizeInBytes() - (limit_ - position_);
|
||||
}
|
||||
intptr_t CapacityInBytes() const;
|
||||
|
||||
// Structure for managing handles allocation.
|
||||
VMHandles* handles() { return &handles_; }
|
||||
|
@ -185,7 +183,7 @@ class StackZone : public StackResource {
|
|||
intptr_t SizeInBytes() const { return zone_.SizeInBytes(); }
|
||||
|
||||
// Computes the used space in the zone.
|
||||
intptr_t UsedSizeInBytes() const { return zone_.UsedSizeInBytes(); }
|
||||
intptr_t CapacityInBytes() const { return zone_.CapacityInBytes(); }
|
||||
|
||||
Zone* GetZone() { return &zone_; }
|
||||
|
||||
|
|
|
@ -201,7 +201,8 @@ UNIT_TEST_CASE(PrintZoneMemoryInfoToJSON) {
|
|||
OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd
|
||||
","
|
||||
"\"used\":%" Pd "",
|
||||
zone.SizeInBytes(), zone.UsedSizeInBytes());
|
||||
zone.CapacityInBytes(), zone.SizeInBytes());
|
||||
EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes());
|
||||
EXPECT_SUBSTRING(size_buf, json);
|
||||
}
|
||||
|
||||
|
@ -217,7 +218,8 @@ UNIT_TEST_CASE(PrintZoneMemoryInfoToJSON) {
|
|||
OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd
|
||||
","
|
||||
"\"used\":%" Pd "",
|
||||
zone.SizeInBytes(), zone.UsedSizeInBytes());
|
||||
zone.CapacityInBytes(), zone.SizeInBytes());
|
||||
EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes());
|
||||
EXPECT_SUBSTRING(size_buf, json);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue