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

Side by Side Diff: runtime/vm/kernel_binary.cc

Issue 2655463005: Switched from GrowableArray to MallocGrowableArray to fix crash caused by no isolate/thread existin… (Closed)
Patch Set: Switched from GrowableArray to MallocGrowableArray to fix crash caused by no isolate/thread existin… Created 3 years, 10 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
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/kernel.h" 9 #include "vm/kernel.h"
10 #include "vm/kernel_to_il.h" 10 #include "vm/kernel_to_il.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 current_count_--; 184 current_count_--;
185 } 185 }
186 186
187 void Pop(List<T>* decl) { 187 void Pop(List<T>* decl) {
188 variables_.TruncateTo(variables_.length() - decl->length()); 188 variables_.TruncateTo(variables_.length() - decl->length());
189 current_count_ -= decl->length(); 189 current_count_ -= decl->length();
190 } 190 }
191 191
192 private: 192 private:
193 int current_count_; 193 int current_count_;
194 GrowableArray<T*> variables_; 194 MallocGrowableArray<T*> variables_;
195 GrowableArray<int> variable_count_; 195 MallocGrowableArray<int> variable_count_;
196 }; 196 };
197 197
198 198
199 template <typename T> 199 template <typename T>
200 class BlockMap { 200 class BlockMap {
201 public: 201 public:
202 BlockMap() : current_count_(0), stack_height_(0) {} 202 BlockMap() : current_count_(0), stack_height_(0) {}
203 203
204 void EnterScope() { 204 void EnterScope() {
205 variable_count_.Add(current_count_); 205 variable_count_.Add(current_count_);
206 current_count_ = 0; 206 current_count_ = 0;
207 } 207 }
208 208
209 void LeaveScope() { 209 void LeaveScope() {
210 stack_height_ -= current_count_; 210 stack_height_ -= current_count_;
211 current_count_ = variable_count_[variable_count_.length() - 1]; 211 current_count_ = variable_count_[variable_count_.length() - 1];
212 variable_count_.RemoveLast(); 212 variable_count_.RemoveLast();
213 } 213 }
214 214
215 int Lookup(T* object) { 215 int Lookup(T* object) {
216 typename Map<T, int>::Pair* result = variables_.LookupPair(object); 216 typename MallocMap<T, int>::Pair* result = variables_.LookupPair(object);
217 ASSERT(result != NULL); 217 ASSERT(result != NULL);
218 if (result == NULL) FATAL("lookup failure"); 218 if (result == NULL) FATAL("lookup failure");
219 return RawPointerKeyValueTrait<T, int>::ValueOf(*result); 219 return RawPointerKeyValueTrait<T, int>::ValueOf(*result);
220 } 220 }
221 221
222 void Push(T* v) { 222 void Push(T* v) {
223 ASSERT(variables_.LookupPair(v) == NULL); 223 ASSERT(variables_.LookupPair(v) == NULL);
224 int index = stack_height_++; 224 int index = stack_height_++;
225 variables_.Insert(v, index); 225 variables_.Insert(v, index);
226 current_count_++; 226 current_count_++;
227 } 227 }
228 228
229 void Set(T* v, int index) { 229 void Set(T* v, int index) {
230 typename Map<T, int>::Pair* entry = variables_.LookupPair(v); 230 typename MallocMap<T, int>::Pair* entry = variables_.LookupPair(v);
231 ASSERT(entry != NULL); 231 ASSERT(entry != NULL);
232 entry->value = index; 232 entry->value = index;
233 } 233 }
234 234
235 void Push(List<T>* decl) { 235 void Push(List<T>* decl) {
236 for (int i = 0; i < decl->length(); i++) { 236 for (int i = 0; i < decl->length(); i++) {
237 Push(decl[i]); 237 Push(decl[i]);
238 } 238 }
239 } 239 }
240 240
241 void Pop(T* v) { 241 void Pop(T* v) {
242 current_count_--; 242 current_count_--;
243 stack_height_--; 243 stack_height_--;
244 } 244 }
245 245
246 private: 246 private:
247 int current_count_; 247 int current_count_;
248 int stack_height_; 248 int stack_height_;
249 Map<T, int> variables_; 249 MallocMap<T, int> variables_;
250 GrowableArray<int> variable_count_; 250 MallocGrowableArray<int> variable_count_;
251 }; 251 };
252 252
253 253
254 template <typename T> 254 template <typename T>
255 class VariableScope { 255 class VariableScope {
256 public: 256 public:
257 explicit VariableScope(T* builder) : builder_(builder) { 257 explicit VariableScope(T* builder) : builder_(builder) {
258 builder_->variables().EnterScope(); 258 builder_->variables().EnterScope();
259 } 259 }
260 ~VariableScope() { builder_->variables().LeaveScope(); } 260 ~VariableScope() { builder_->variables().LeaveScope(); }
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 1892
1893 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1893 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1894 intptr_t buffer_length) { 1894 intptr_t buffer_length) {
1895 kernel::Reader reader(buffer, buffer_length); 1895 kernel::Reader reader(buffer, buffer_length);
1896 return kernel::Program::ReadFrom(&reader); 1896 return kernel::Program::ReadFrom(&reader);
1897 } 1897 }
1898 1898
1899 1899
1900 } // namespace dart 1900 } // namespace dart
1901 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1901 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698