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