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/allocation.h" | 5 #include "vm/allocation.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/zone.h" | 9 #include "vm/zone.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 return Allocate(size, isolate->current_zone()); | 29 return Allocate(size, isolate->current_zone()); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 void* ZoneAllocated::operator new(uword size, Zone* zone) { | 33 void* ZoneAllocated::operator new(uword size, Zone* zone) { |
34 ASSERT(zone == Isolate::Current()->current_zone()); | 34 ASSERT(zone == Isolate::Current()->current_zone()); |
35 return Allocate(size, zone); | 35 return Allocate(size, zone); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 void StackResource::Unwind(Isolate* isolate, uword stack_pointer) { | 39 void StackResource::UnwindAbove(Isolate* isolate, StackResource* new_top) { |
40 while (isolate->top_resource() != NULL && | |
41 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | |
42 isolate->top_resource()->~StackResource(); | |
43 } | |
44 #if defined(DEBUG) | |
45 // All remaining stack resources should be below stack_pointer. | |
46 StackResource* current = isolate->top_resource(); | |
47 while (current != NULL) { | |
48 ASSERT(reinterpret_cast<uword>(current) >= stack_pointer); | |
49 current = current->previous_; | |
50 } | |
51 #endif // DEBUG | |
52 } | |
53 | |
54 | |
55 void StackResource::Unwind(Isolate* isolate, StackResource* new_top) { | |
56 StackResource* current_resource = isolate->top_resource(); | 40 StackResource* current_resource = isolate->top_resource(); |
57 while (current_resource != new_top) { | 41 while (current_resource != new_top) { |
58 current_resource->~StackResource(); | 42 current_resource->~StackResource(); |
59 current_resource = isolate->top_resource(); | 43 current_resource = isolate->top_resource(); |
60 } | 44 } |
61 } | 45 } |
62 | 46 |
63 } // namespace dart | 47 } // namespace dart |
OLD | NEW |