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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 zone.GetZone()->Alloc<uint32_t>(kNumElements); | 190 zone.GetZone()->Alloc<uint32_t>(kNumElements); |
191 allocated_size += sizeof(uint32_t) * kNumElements; | 191 allocated_size += sizeof(uint32_t) * kNumElements; |
192 | 192 |
193 EXPECT_LE(allocated_size, zone.SizeInBytes()); | 193 EXPECT_LE(allocated_size, zone.SizeInBytes()); |
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 = OS::SCreate(string_stack_zone.GetZone(), | 200 char* size_buf = |
201 "\"capacity\":%ld," | 201 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd |
202 "\"used\":%ld", | 202 "," |
203 zone.SizeInBytes(), zone.UsedSizeInBytes()); | 203 "\"used\":%" Pd "", |
| 204 zone.SizeInBytes(), zone.UsedSizeInBytes()); |
204 EXPECT_SUBSTRING(size_buf, json); | 205 EXPECT_SUBSTRING(size_buf, json); |
205 } | 206 } |
206 | 207 |
207 // Expand the zone to ensure that JSON is updated accordingly. | 208 // Expand the zone to ensure that JSON is updated accordingly. |
208 zone.GetZone()->Alloc<uint32_t>(kNumElements); | 209 zone.GetZone()->Alloc<uint32_t>(kNumElements); |
209 allocated_size += sizeof(uint32_t) * kNumElements; | 210 allocated_size += sizeof(uint32_t) * kNumElements; |
210 EXPECT_LE(allocated_size, zone.SizeInBytes()); | 211 EXPECT_LE(allocated_size, zone.SizeInBytes()); |
211 { | 212 { |
212 JSONStream stream; | 213 JSONStream stream; |
213 zone.GetZone()->PrintJSON(&stream); | 214 zone.GetZone()->PrintJSON(&stream); |
214 const char* json = stream.ToCString(); | 215 const char* json = stream.ToCString(); |
215 char* size_buf = OS::SCreate(string_stack_zone.GetZone(), | 216 char* size_buf = |
216 "\"capacity\":%ld," | 217 OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd |
217 "\"used\":%ld", | 218 "," |
218 zone.SizeInBytes(), zone.UsedSizeInBytes()); | 219 "\"used\":%" Pd "", |
| 220 zone.SizeInBytes(), zone.UsedSizeInBytes()); |
219 EXPECT_SUBSTRING(size_buf, json); | 221 EXPECT_SUBSTRING(size_buf, json); |
220 } | 222 } |
221 } | 223 } |
222 EXPECT(thread->zone() == NULL); | 224 EXPECT(thread->zone() == NULL); |
223 Dart_ShutdownIsolate(); | 225 Dart_ShutdownIsolate(); |
224 } | 226 } |
225 #endif | 227 #endif |
226 | 228 |
227 } // namespace dart | 229 } // namespace dart |
OLD | NEW |