Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: runtime/vm/growable_array.h

Issue 10800037: New linear scan allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Kevin's comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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: 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
(...skipping 18 matching lines...) Expand all
29 if (initial_capacity > 0) { 29 if (initial_capacity > 0) {
30 capacity_ = Utils::RoundUpToPowerOfTwo(initial_capacity); 30 capacity_ = Utils::RoundUpToPowerOfTwo(initial_capacity);
31 data_ = reinterpret_cast<T*>(zone_->Allocate(capacity_ * sizeof(T))); 31 data_ = reinterpret_cast<T*>(zone_->Allocate(capacity_ * sizeof(T)));
32 } 32 }
33 } 33 }
34 34
35 int length() const { return length_; } 35 int length() const { return length_; }
36 T* data() const { return data_; } 36 T* data() const { return data_; }
37 bool is_empty() const { return length_ == 0; } 37 bool is_empty() const { return length_ == 0; }
38 38
39 void TruncateTo(intptr_t length) {
40 ASSERT(length_ >= length);
41 length_ = length;
42 }
43
39 void Add(const T& value) { 44 void Add(const T& value) {
40 Resize(length() + 1); 45 Resize(length() + 1);
41 Last() = value; 46 Last() = value;
42 } 47 }
43 48
44 void RemoveLast() { 49 void RemoveLast() {
45 ASSERT(length_ > 0); 50 ASSERT(length_ > 0);
46 length_--; 51 length_--;
47 } 52 }
48 53
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 initial_capacity, 149 initial_capacity,
145 Isolate::Current()->current_zone()->GetBaseZone()) {} 150 Isolate::Current()->current_zone()->GetBaseZone()) {}
146 ZoneGrowableArray() : 151 ZoneGrowableArray() :
147 BaseGrowableArray<T, ZoneAllocated>( 152 BaseGrowableArray<T, ZoneAllocated>(
148 Isolate::Current()->current_zone()->GetBaseZone()) {} 153 Isolate::Current()->current_zone()->GetBaseZone()) {}
149 }; 154 };
150 155
151 } // namespace dart 156 } // namespace dart
152 157
153 #endif // VM_GROWABLE_ARRAY_H_ 158 #endif // VM_GROWABLE_ARRAY_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698