| 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 // Defines growable array classes, that differ where they are allocated: | 4 // Defines growable array classes, that differ where they are allocated: |
| 5 // - GrowableArray: allocated on stack. | 5 // - GrowableArray: allocated on stack. |
| 6 // - ZoneGrowableArray: allocated in the zone. | 6 // - ZoneGrowableArray: allocated in the zone. |
| 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called | 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called |
| 8 // at destruction. | 8 // at destruction. |
| 9 | 9 |
| 10 #ifndef VM_GROWABLE_ARRAY_H_ | 10 #ifndef VM_GROWABLE_ARRAY_H_ |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 data_ = new_data; | 139 data_ = new_data; |
| 140 capacity_ = new_length; | 140 capacity_ = new_length; |
| 141 } | 141 } |
| 142 length_ = new_length; | 142 length_ = new_length; |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 template<typename T> | 146 template<typename T> |
| 147 class GrowableArray : public BaseGrowableArray<T, ValueObject> { | 147 class GrowableArray : public BaseGrowableArray<T, ValueObject> { |
| 148 public: | 148 public: |
| 149 GrowableArray(Isolate* isolate, intptr_t initial_capacity) | 149 GrowableArray(Zone* zone, intptr_t initial_capacity) |
| 150 : BaseGrowableArray<T, ValueObject>( | 150 : BaseGrowableArray<T, ValueObject>( |
| 151 initial_capacity, ASSERT_NOTNULL(isolate->current_zone())) {} | 151 initial_capacity, ASSERT_NOTNULL(zone)) {} |
| 152 explicit GrowableArray(intptr_t initial_capacity) | 152 explicit GrowableArray(intptr_t initial_capacity) |
| 153 : BaseGrowableArray<T, ValueObject>( | 153 : BaseGrowableArray<T, ValueObject>( |
| 154 initial_capacity, | 154 initial_capacity, |
| 155 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} | 155 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} |
| 156 GrowableArray() | 156 GrowableArray() |
| 157 : BaseGrowableArray<T, ValueObject>( | 157 : BaseGrowableArray<T, ValueObject>( |
| 158 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} | 158 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 | 161 |
| 162 template<typename T> | 162 template<typename T> |
| 163 class ZoneGrowableArray : public BaseGrowableArray<T, ZoneAllocated> { | 163 class ZoneGrowableArray : public BaseGrowableArray<T, ZoneAllocated> { |
| 164 public: | 164 public: |
| 165 ZoneGrowableArray(Isolate* isolate, intptr_t initial_capacity) | 165 ZoneGrowableArray(Zone* zone, intptr_t initial_capacity) |
| 166 : BaseGrowableArray<T, ZoneAllocated>( | 166 : BaseGrowableArray<T, ZoneAllocated>( |
| 167 initial_capacity, ASSERT_NOTNULL(isolate->current_zone())) {} | 167 initial_capacity, ASSERT_NOTNULL(zone)) {} |
| 168 explicit ZoneGrowableArray(intptr_t initial_capacity) | 168 explicit ZoneGrowableArray(intptr_t initial_capacity) |
| 169 : BaseGrowableArray<T, ZoneAllocated>( | 169 : BaseGrowableArray<T, ZoneAllocated>( |
| 170 initial_capacity, | 170 initial_capacity, |
| 171 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} | 171 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} |
| 172 ZoneGrowableArray() | 172 ZoneGrowableArray() |
| 173 : BaseGrowableArray<T, ZoneAllocated>( | 173 : BaseGrowableArray<T, ZoneAllocated>( |
| 174 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} | 174 ASSERT_NOTNULL(Isolate::Current()->current_zone())) {} |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 | 177 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 202 public: | 202 public: |
| 203 explicit MallocGrowableArray(intptr_t initial_capacity) | 203 explicit MallocGrowableArray(intptr_t initial_capacity) |
| 204 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} | 204 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} |
| 205 MallocGrowableArray() | 205 MallocGrowableArray() |
| 206 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} | 206 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 } // namespace dart | 209 } // namespace dart |
| 210 | 210 |
| 211 #endif // VM_GROWABLE_ARRAY_H_ | 211 #endif // VM_GROWABLE_ARRAY_H_ |
| OLD | NEW |