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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10471002: Avoid repeated declaration of the same loop variable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « lib/compiler/implementation/dart2js.dart ('k') | no next file » | 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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 461 }
462 462
463 void declareVariable(String variableName) { 463 void declareVariable(String variableName) {
464 if (isGeneratingExpression()) { 464 if (isGeneratingExpression()) {
465 if (generationState == STATE_FIRST_DECLARATION) { 465 if (generationState == STATE_FIRST_DECLARATION) {
466 generationState = STATE_DECLARATION; 466 generationState = STATE_DECLARATION;
467 if (!isVariableDeclared(variableName)) { 467 if (!isVariableDeclared(variableName)) {
468 declaredVariables.add(variableName); 468 declaredVariables.add(variableName);
469 buffer.add("var "); 469 buffer.add("var ");
470 } 470 }
471 } else if (!isGeneratingDeclaration() 471 } else if (!isVariableDeclared(variableName)) {
472 && !isVariableDeclared(variableName)) { 472 if (!isGeneratingDeclaration()) {
473 delayedVariablesDeclaration.add(variableName); 473 delayedVariablesDeclaration.add(variableName);
474 } else {
475 declaredVariables.add(variableName);
476 }
474 } 477 }
475 } else if (!isVariableDeclared(variableName)) { 478 } else if (!isVariableDeclared(variableName)) {
476 declaredVariables.add(variableName); 479 declaredVariables.add(variableName);
477 buffer.add("var "); 480 buffer.add("var ");
478 } 481 }
479 buffer.add(variableName); 482 buffer.add(variableName);
480 } 483 }
481 484
482 void declareInstruction(HInstruction instruction) { 485 void declareInstruction(HInstruction instruction) {
483 declareVariable(variableNames.getName(instruction)); 486 declareVariable(variableNames.getName(instruction));
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 startBailoutSwitch(); 2498 startBailoutSwitch();
2496 } 2499 }
2497 } 2500 }
2498 2501
2499 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2502 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2500 if (labeledBlockInfo.body.start.hasGuards()) { 2503 if (labeledBlockInfo.body.start.hasGuards()) {
2501 endBailoutSwitch(); 2504 endBailoutSwitch();
2502 } 2505 }
2503 } 2506 }
2504 } 2507 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698