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 #ifndef VM_ZONE_H_ | 5 #ifndef VM_ZONE_H_ |
6 #define VM_ZONE_H_ | 6 #define VM_ZONE_H_ |
7 | 7 |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 friend class StackZone; | 150 friend class StackZone; |
151 friend class ApiZone; | 151 friend class ApiZone; |
152 template<typename T, typename B> friend class BaseGrowableArray; | 152 template<typename T, typename B> friend class BaseGrowableArray; |
153 DISALLOW_COPY_AND_ASSIGN(Zone); | 153 DISALLOW_COPY_AND_ASSIGN(Zone); |
154 }; | 154 }; |
155 | 155 |
156 | 156 |
157 class StackZone : public StackResource { | 157 class StackZone : public StackResource { |
158 public: | 158 public: |
159 // Create an empty zone and set is at the current zone for the Isolate. | 159 // Create an empty zone and set is at the current zone for the Isolate. |
160 explicit StackZone(BaseIsolate* isolate) | 160 explicit StackZone(Isolate* isolate) |
161 : StackResource(isolate), | 161 : StackResource(isolate), |
162 zone_() { | 162 zone_() { |
163 #ifdef DEBUG | 163 #ifdef DEBUG |
164 if (FLAG_trace_zones) { | 164 if (FLAG_trace_zones) { |
165 OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n", | 165 OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n", |
166 reinterpret_cast<intptr_t>(this), | 166 reinterpret_cast<intptr_t>(this), |
167 reinterpret_cast<intptr_t>(&zone_)); | 167 reinterpret_cast<intptr_t>(&zone_)); |
168 } | 168 } |
169 #endif | 169 #endif |
170 zone_.Link(isolate->current_zone()); | 170 BaseIsolate* base_isolate = reinterpret_cast<BaseIsolate*>(isolate); |
171 isolate->set_current_zone(&zone_); | 171 zone_.Link(base_isolate->current_zone()); |
| 172 base_isolate->set_current_zone(&zone_); |
172 } | 173 } |
173 | 174 |
174 // Delete all memory associated with the zone. | 175 // Delete all memory associated with the zone. |
175 ~StackZone() { | 176 ~StackZone() { |
176 ASSERT(isolate()->current_zone() == &zone_); | 177 BaseIsolate* base_isolate = reinterpret_cast<BaseIsolate*>(isolate()); |
177 isolate()->set_current_zone(zone_.previous_); | 178 ASSERT(base_isolate->current_zone() == &zone_); |
| 179 base_isolate->set_current_zone(zone_.previous_); |
178 #ifdef DEBUG | 180 #ifdef DEBUG |
179 if (FLAG_trace_zones) { | 181 if (FLAG_trace_zones) { |
180 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", | 182 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", |
181 reinterpret_cast<intptr_t>(this), | 183 reinterpret_cast<intptr_t>(this), |
182 reinterpret_cast<intptr_t>(&zone_)); | 184 reinterpret_cast<intptr_t>(&zone_)); |
183 } | 185 } |
184 #endif | 186 #endif |
185 } | 187 } |
186 | 188 |
187 // Compute the total size of this zone. This includes wasted space that is | 189 // Compute the total size of this zone. This includes wasted space that is |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 reinterpret_cast<void*>(old_data), | 245 reinterpret_cast<void*>(old_data), |
244 Utils::Minimum(old_len * sizeof(ElementType), | 246 Utils::Minimum(old_len * sizeof(ElementType), |
245 new_len * sizeof(ElementType))); | 247 new_len * sizeof(ElementType))); |
246 } | 248 } |
247 return new_data; | 249 return new_data; |
248 } | 250 } |
249 | 251 |
250 } // namespace dart | 252 } // namespace dart |
251 | 253 |
252 #endif // VM_ZONE_H_ | 254 #endif // VM_ZONE_H_ |
OLD | NEW |