| 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 "vm/zone.h" | 5 #include "vm/zone.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/handles_impl.h" | 10 #include "vm/handles_impl.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 va_end(args); | 253 va_end(args); |
| 254 return buffer; | 254 return buffer; |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| 258 char* Zone::VPrint(const char* format, va_list args) { | 258 char* Zone::VPrint(const char* format, va_list args) { |
| 259 return OS::VSCreate(this, format, args); | 259 return OS::VSCreate(this, format, args); |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 #ifndef PRODUCT |
| 264 void Zone::PrintJSON(JSONStream* stream) const { |
| 265 JSONObject jsobj(stream); |
| 266 intptr_t capacity = SizeInBytes(); |
| 267 intptr_t used_size = UsedSizeInBytes(); |
| 268 jsobj.AddProperty("type", "_Zone"); |
| 269 jsobj.AddProperty("capacity", capacity); |
| 270 jsobj.AddProperty("used", used_size); |
| 271 } |
| 272 #endif |
| 273 |
| 274 |
| 263 StackZone::StackZone(Thread* thread) : StackResource(thread), zone_() { | 275 StackZone::StackZone(Thread* thread) : StackResource(thread), zone_() { |
| 264 if (FLAG_trace_zones) { | 276 if (FLAG_trace_zones) { |
| 265 OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n", | 277 OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n", |
| 266 reinterpret_cast<intptr_t>(this), | 278 reinterpret_cast<intptr_t>(this), |
| 267 reinterpret_cast<intptr_t>(&zone_)); | 279 reinterpret_cast<intptr_t>(&zone_)); |
| 268 } | 280 } |
| 269 zone_.Link(thread->zone()); | 281 zone_.Link(thread->zone()); |
| 270 thread->set_zone(&zone_); | 282 thread->set_zone(&zone_); |
| 271 } | 283 } |
| 272 | 284 |
| 273 | 285 |
| 274 StackZone::~StackZone() { | 286 StackZone::~StackZone() { |
| 275 ASSERT(thread()->zone() == &zone_); | 287 ASSERT(thread()->zone() == &zone_); |
| 276 thread()->set_zone(zone_.previous_); | 288 thread()->set_zone(zone_.previous_); |
| 277 if (FLAG_trace_zones) { | 289 if (FLAG_trace_zones) { |
| 278 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", | 290 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", |
| 279 reinterpret_cast<intptr_t>(this), | 291 reinterpret_cast<intptr_t>(this), |
| 280 reinterpret_cast<intptr_t>(&zone_)); | 292 reinterpret_cast<intptr_t>(&zone_)); |
| 281 } | 293 } |
| 282 } | 294 } |
| 283 | 295 |
| 284 } // namespace dart | 296 } // namespace dart |
| OLD | NEW |