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

Side by Side Diff: src/list-inl.h

Issue 11880018: Reland r13188, r13194, r13256 (Deferred formatting of error stack trace during GC). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 7 years, 11 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 | « src/list.h ('k') | src/mark-compact.cc » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Since the element reference could be an element of the list, copy 78 // Since the element reference could be an element of the list, copy
79 // it out of the old backing storage before resizing. 79 // it out of the old backing storage before resizing.
80 T temp = element; 80 T temp = element;
81 Resize(new_capacity, alloc); 81 Resize(new_capacity, alloc);
82 data_[length_++] = temp; 82 data_[length_++] = temp;
83 } 83 }
84 84
85 85
86 template<typename T, class P> 86 template<typename T, class P>
87 void List<T, P>::Resize(int new_capacity, P alloc) { 87 void List<T, P>::Resize(int new_capacity, P alloc) {
88 ASSERT_LE(length_, new_capacity);
88 T* new_data = NewData(new_capacity, alloc); 89 T* new_data = NewData(new_capacity, alloc);
89 memcpy(new_data, data_, capacity_ * sizeof(T)); 90 memcpy(new_data, data_, length_ * sizeof(T));
90 List<T, P>::DeleteData(data_); 91 List<T, P>::DeleteData(data_);
91 data_ = new_data; 92 data_ = new_data;
92 capacity_ = new_capacity; 93 capacity_ = new_capacity;
93 } 94 }
94 95
95 96
96 template<typename T, class P> 97 template<typename T, class P>
97 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { 98 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) {
98 int start = length_; 99 int start = length_;
99 for (int i = 0; i < count; i++) Add(value, alloc); 100 for (int i = 0; i < count; i++) Add(value, alloc);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 156 }
156 157
157 158
158 template<typename T, class P> 159 template<typename T, class P>
159 void List<T, P>::Rewind(int pos) { 160 void List<T, P>::Rewind(int pos) {
160 length_ = pos; 161 length_ = pos;
161 } 162 }
162 163
163 164
164 template<typename T, class P> 165 template<typename T, class P>
166 void List<T, P>::Trim(P alloc) {
167 if (length_ < capacity_ / 4) {
168 Resize(capacity_ / 2, alloc);
169 }
170 }
171
172
173 template<typename T, class P>
165 void List<T, P>::Iterate(void (*callback)(T* x)) { 174 void List<T, P>::Iterate(void (*callback)(T* x)) {
166 for (int i = 0; i < length_; i++) callback(&data_[i]); 175 for (int i = 0; i < length_; i++) callback(&data_[i]);
167 } 176 }
168 177
169 178
170 template<typename T, class P> 179 template<typename T, class P>
171 template<class Visitor> 180 template<class Visitor>
172 void List<T, P>::Iterate(Visitor* visitor) { 181 void List<T, P>::Iterate(Visitor* visitor) {
173 for (int i = 0; i < length_; i++) visitor->Apply(&data_[i]); 182 for (int i = 0; i < length_; i++) visitor->Apply(&data_[i]);
174 } 183 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 265
257 template <typename T> 266 template <typename T>
258 int SortedListBSearch(const List<T>& list, T elem) { 267 int SortedListBSearch(const List<T>& list, T elem) {
259 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); 268 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem));
260 } 269 }
261 270
262 271
263 } } // namespace v8::internal 272 } } // namespace v8::internal
264 273
265 #endif // V8_LIST_INL_H_ 274 #endif // V8_LIST_INL_H_
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698