| 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 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/dart.h" | 6 #include "vm/dart.h" |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 #include "vm/zone.h" | 9 #include "vm/zone.h" |
| 10 | 10 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 { | 194 { |
| 195 JSONStream stream; | 195 JSONStream stream; |
| 196 // Get the JSON formated zone information. | 196 // Get the JSON formated zone information. |
| 197 zone.GetZone()->PrintJSON(&stream); | 197 zone.GetZone()->PrintJSON(&stream); |
| 198 const char* json = stream.ToCString(); | 198 const char* json = stream.ToCString(); |
| 199 // Ensure that matches actual values. | 199 // Ensure that matches actual values. |
| 200 char* size_buf = | 200 char* size_buf = |
| 201 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd | 201 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd |
| 202 "," | 202 "," |
| 203 "\"used\":%" Pd "", | 203 "\"used\":%" Pd "", |
| 204 zone.SizeInBytes(), zone.UsedSizeInBytes()); | 204 zone.CapacityInBytes(), zone.SizeInBytes()); |
| 205 EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes()); |
| 205 EXPECT_SUBSTRING(size_buf, json); | 206 EXPECT_SUBSTRING(size_buf, json); |
| 206 } | 207 } |
| 207 | 208 |
| 208 // Expand the zone to ensure that JSON is updated accordingly. | 209 // Expand the zone to ensure that JSON is updated accordingly. |
| 209 zone.GetZone()->Alloc<uint32_t>(kNumElements); | 210 zone.GetZone()->Alloc<uint32_t>(kNumElements); |
| 210 allocated_size += sizeof(uint32_t) * kNumElements; | 211 allocated_size += sizeof(uint32_t) * kNumElements; |
| 211 EXPECT_LE(allocated_size, zone.SizeInBytes()); | 212 EXPECT_LE(allocated_size, zone.SizeInBytes()); |
| 212 { | 213 { |
| 213 JSONStream stream; | 214 JSONStream stream; |
| 214 zone.GetZone()->PrintJSON(&stream); | 215 zone.GetZone()->PrintJSON(&stream); |
| 215 const char* json = stream.ToCString(); | 216 const char* json = stream.ToCString(); |
| 216 char* size_buf = | 217 char* size_buf = |
| 217 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd | 218 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd |
| 218 "," | 219 "," |
| 219 "\"used\":%" Pd "", | 220 "\"used\":%" Pd "", |
| 220 zone.SizeInBytes(), zone.UsedSizeInBytes()); | 221 zone.CapacityInBytes(), zone.SizeInBytes()); |
| 222 EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes()); |
| 221 EXPECT_SUBSTRING(size_buf, json); | 223 EXPECT_SUBSTRING(size_buf, json); |
| 222 } | 224 } |
| 223 } | 225 } |
| 224 EXPECT(thread->zone() == NULL); | 226 EXPECT(thread->zone() == NULL); |
| 225 Dart_ShutdownIsolate(); | 227 Dart_ShutdownIsolate(); |
| 226 } | 228 } |
| 227 #endif | 229 #endif |
| 228 | 230 |
| 229 } // namespace dart | 231 } // namespace dart |
| OLD | NEW |