OLD | NEW |
1 // Copyright (c) 2011, 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 // Defines growable array classes, that differ where they are allocated: | 4 // Defines growable array classes, that differ where they are allocated: |
5 // - GrowableArray: allocate on stack. | 5 // - GrowableArray: allocate on stack. |
6 // - ZoneGrowableArray: allocated in the zone. | 6 // - ZoneGrowableArray: allocated in the zone. |
7 | 7 |
8 #ifndef VM_GROWABLE_ARRAY_H_ | 8 #ifndef VM_GROWABLE_ARRAY_H_ |
9 #define VM_GROWABLE_ARRAY_H_ | 9 #define VM_GROWABLE_ARRAY_H_ |
10 | 10 |
| 11 #include "platform/utils.h" |
11 #include "vm/allocation.h" | 12 #include "vm/allocation.h" |
12 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
13 #include "vm/utils.h" | |
14 #include "vm/zone.h" | 14 #include "vm/zone.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 template<typename T, typename B> | 18 template<typename T, typename B> |
19 class BaseGrowableArray : public B { | 19 class BaseGrowableArray : public B { |
20 public: | 20 public: |
21 BaseGrowableArray() : length_(0), capacity_(0), data_(NULL), zone_(NULL) { | 21 BaseGrowableArray() : length_(0), capacity_(0), data_(NULL), zone_(NULL) { |
22 ASSERT(Isolate::Current() != NULL); | 22 ASSERT(Isolate::Current() != NULL); |
23 zone_ = Isolate::Current()->current_zone(); | 23 zone_ = Isolate::Current()->current_zone(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 class ZoneGrowableArray : public BaseGrowableArray<T, ZoneAllocated> { | 124 class ZoneGrowableArray : public BaseGrowableArray<T, ZoneAllocated> { |
125 public: | 125 public: |
126 explicit ZoneGrowableArray(int initial_capacity) | 126 explicit ZoneGrowableArray(int initial_capacity) |
127 : BaseGrowableArray<T, ZoneAllocated>(initial_capacity) {} | 127 : BaseGrowableArray<T, ZoneAllocated>(initial_capacity) {} |
128 ZoneGrowableArray() : BaseGrowableArray<T, ZoneAllocated>() {} | 128 ZoneGrowableArray() : BaseGrowableArray<T, ZoneAllocated>() {} |
129 }; | 129 }; |
130 | 130 |
131 } // namespace dart | 131 } // namespace dart |
132 | 132 |
133 #endif // VM_GROWABLE_ARRAY_H_ | 133 #endif // VM_GROWABLE_ARRAY_H_ |
OLD | NEW |