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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 intptr_t size = 0; | 209 intptr_t size = 0; |
210 for (Segment* s = large_segments_; s != NULL; s = s->next()) { | 210 for (Segment* s = large_segments_; s != NULL; s = s->next()) { |
211 size += s->size(); | 211 size += s->size(); |
212 } | 212 } |
213 OS::Print("Size in bytes allocated, Total = %d Large Segments = %d\n", | 213 OS::Print("Size in bytes allocated, Total = %d Large Segments = %d\n", |
214 SizeInBytes(), size); | 214 SizeInBytes(), size); |
215 } | 215 } |
216 #endif | 216 #endif |
217 | 217 |
218 | 218 |
| 219 Zone::Zone() |
| 220 : StackResource(NULL), |
| 221 zone_(), |
| 222 handles_(), |
| 223 previous_(NULL) { |
| 224 } |
| 225 |
| 226 |
219 Zone::Zone(Isolate* isolate) | 227 Zone::Zone(Isolate* isolate) |
220 : StackResource(isolate), | 228 : StackResource(isolate), |
221 zone_(), | 229 zone_(), |
222 handles_(), | 230 handles_(), |
223 previous_(NULL) { | 231 previous_(NULL) { |
224 // Assert that there is no current zone as we only want to scope | 232 // Assert that there is no current zone as we only want to scope |
225 // zones when transitioning from generated dart code to dart VM | 233 // zones when transitioning from generated dart code to dart VM |
226 // runtime code. | 234 // runtime code. |
227 previous_ = isolate->current_zone(); | 235 previous_ = isolate->current_zone(); |
228 isolate->set_current_zone(this); | 236 isolate->set_current_zone(this); |
229 } | 237 } |
230 | 238 |
231 | 239 |
232 Zone::~Zone() { | 240 Zone::~Zone() { |
233 ASSERT(isolate()->current_zone() == this); | 241 if (isolate() != NULL) { |
234 isolate()->set_current_zone(previous_); | 242 ASSERT(isolate()->current_zone() == this); |
| 243 isolate()->set_current_zone(previous_); |
| 244 } |
235 } | 245 } |
236 | 246 |
237 | 247 |
238 void Zone::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 248 void Zone::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 249 ASSERT(isolate() != NULL); |
239 Zone* zone = this; | 250 Zone* zone = this; |
240 while (zone != NULL) { | 251 while (zone != NULL) { |
241 zone->handles()->VisitObjectPointers(visitor); | 252 zone->handles()->VisitObjectPointers(visitor); |
242 zone = zone->previous_; | 253 zone = zone->previous_; |
243 } | 254 } |
244 } | 255 } |
245 | 256 |
246 } // namespace dart | 257 } // namespace dart |
OLD | NEW |