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

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

Issue 11893002: Improve compilation speed on a pathological case > 2x (7 sec -> 2.7 sec) by improving local lookups. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | « runtime/vm/object_test.cc ('k') | runtime/vm/scopes_test.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 (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 4
5 #include "vm/scopes.h" 5 #include "vm/scopes.h"
6 6
7 #include "vm/ast.h" 7 #include "vm/ast.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 SourceLabel* label = labels_[i]; 287 SourceLabel* label = labels_[i];
288 if (label->name().Equals(name)) { 288 if (label->name().Equals(name)) {
289 return label; 289 return label;
290 } 290 }
291 } 291 }
292 return NULL; 292 return NULL;
293 } 293 }
294 294
295 295
296 LocalVariable* LocalScope::LocalLookupVariable(const String& name) const { 296 LocalVariable* LocalScope::LocalLookupVariable(const String& name) const {
297 ASSERT(name.IsSymbol());
297 for (intptr_t i = 0; i < variables_.length(); i++) { 298 for (intptr_t i = 0; i < variables_.length(); i++) {
298 LocalVariable* var = variables_[i]; 299 LocalVariable* var = variables_[i];
299 if (var->name().Equals(name) && !var->is_invisible_) { 300 ASSERT(var->name().IsSymbol());
301 if ((var->name().raw() == name.raw()) && !var->is_invisible_) {
300 return var; 302 return var;
301 } 303 }
302 } 304 }
303 return NULL; 305 return NULL;
304 } 306 }
305 307
306 308
307 LocalVariable* LocalScope::LookupVariable(const String& name, bool test_only) { 309 LocalVariable* LocalScope::LookupVariable(const String& name, bool test_only) {
308 LocalScope* current_scope = this; 310 LocalScope* current_scope = this;
309 while (current_scope != NULL) { 311 while (current_scope != NULL) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } else { 566 } else {
565 // Shift negative indexes so that the lowest one is 0 (they are still 567 // Shift negative indexes so that the lowest one is 0 (they are still
566 // non-positive). 568 // non-positive).
567 return fixed_parameter_count - 569 return fixed_parameter_count -
568 (index() - ParsedFunction::kFirstLocalSlotIndex); 570 (index() - ParsedFunction::kFirstLocalSlotIndex);
569 } 571 }
570 } 572 }
571 573
572 574
573 } // namespace dart 575 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/scopes_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698