| 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/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return result; | 72 return result; |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 Zone::Zone() | 76 Zone::Zone() |
| 77 : initial_buffer_(buffer_, kInitialChunkSize), | 77 : initial_buffer_(buffer_, kInitialChunkSize), |
| 78 position_(initial_buffer_.start()), | 78 position_(initial_buffer_.start()), |
| 79 limit_(initial_buffer_.end()), | 79 limit_(initial_buffer_.end()), |
| 80 head_(NULL), | 80 head_(NULL), |
| 81 large_segments_(NULL), | 81 large_segments_(NULL), |
| 82 handles_() { | 82 handles_(), |
| 83 previous_(NULL) { |
| 83 #ifdef DEBUG | 84 #ifdef DEBUG |
| 84 // Zap the entire initial buffer. | 85 // Zap the entire initial buffer. |
| 85 memset(initial_buffer_.pointer(), kZapUninitializedByte, | 86 memset(initial_buffer_.pointer(), kZapUninitializedByte, |
| 86 initial_buffer_.size()); | 87 initial_buffer_.size()); |
| 87 #endif | 88 #endif |
| 88 } | 89 } |
| 89 | 90 |
| 90 | 91 |
| 91 Zone::~Zone() { | 92 Zone::~Zone() { |
| 92 DeleteAll(); | 93 DeleteAll(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 size += s->size(); | 200 size += s->size(); |
| 200 } | 201 } |
| 201 OS::Print("Size in bytes allocated, Total = %"Pd" Large Segments = %"Pd"\n", | 202 OS::Print("Size in bytes allocated, Total = %"Pd" Large Segments = %"Pd"\n", |
| 202 SizeInBytes(), size); | 203 SizeInBytes(), size); |
| 203 } | 204 } |
| 204 #endif | 205 #endif |
| 205 | 206 |
| 206 | 207 |
| 207 StackZone::StackZone(BaseIsolate* isolate) | 208 StackZone::StackZone(BaseIsolate* isolate) |
| 208 : StackResource(isolate), | 209 : StackResource(isolate), |
| 209 zone_(), | 210 zone_() { |
| 210 previous_(NULL) { | 211 zone_.Link(isolate->current_zone()); |
| 211 // Assert that there is no current zone as we only want to scope | 212 isolate->set_current_zone(&zone_); |
| 212 // zones when transitioning from generated dart code to dart VM | |
| 213 // runtime code. | |
| 214 previous_ = isolate->current_zone(); | |
| 215 isolate->set_current_zone(this); | |
| 216 } | 213 } |
| 217 | 214 |
| 218 | 215 |
| 219 StackZone::~StackZone() { | 216 StackZone::~StackZone() { |
| 220 ASSERT(isolate()->current_zone() == this); | 217 ASSERT(isolate()->current_zone() == &zone_); |
| 221 isolate()->set_current_zone(previous_); | 218 isolate()->set_current_zone(zone_.previous_); |
| 222 } | 219 } |
| 223 | 220 |
| 224 | 221 |
| 225 void StackZone::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 222 void Zone::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 226 StackZone* zone = this; | 223 Zone* zone = this; |
| 227 while (zone != NULL) { | 224 while (zone != NULL) { |
| 228 zone->handles()->VisitObjectPointers(visitor); | 225 zone->handles()->VisitObjectPointers(visitor); |
| 229 zone = zone->previous_; | 226 zone = zone->previous_; |
| 230 } | 227 } |
| 231 } | 228 } |
| 232 | 229 |
| 233 | 230 |
| 234 char* StackZone::PrintToString(const char* format, ...) { | 231 char* Zone::PrintToString(const char* format, ...) { |
| 235 va_list args; | 232 va_list args; |
| 236 va_start(args, format); | 233 va_start(args, format); |
| 237 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 234 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
| 238 va_end(args); | 235 va_end(args); |
| 239 | 236 |
| 240 char* buffer = Alloc<char>(len + 1); | 237 char* buffer = Alloc<char>(len + 1); |
| 241 va_list args2; | 238 va_list args2; |
| 242 va_start(args2, format); | 239 va_start(args2, format); |
| 243 OS::VSNPrint(buffer, (len + 1), format, args2); | 240 OS::VSNPrint(buffer, (len + 1), format, args2); |
| 244 va_end(args2); | 241 va_end(args2); |
| 245 | 242 |
| 246 return buffer; | 243 return buffer; |
| 247 } | 244 } |
| 248 | 245 |
| 249 | 246 |
| 250 } // namespace dart | 247 } // namespace dart |
| OLD | NEW |