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

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

Issue 85593002: Make sure the SSA codegen visit constants used in a switch through the 'visitConstant' method, to e… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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
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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 generateStatements(info.expression); 668 generateStatements(info.expression);
669 } 669 }
670 670
671 if (isExpression) { 671 if (isExpression) {
672 push(generateExpression(info.expression)); 672 push(generateExpression(info.expression));
673 } else { 673 } else {
674 use(info.expression.conditionExpression); 674 use(info.expression.conditionExpression);
675 } 675 }
676 js.Expression key = pop(); 676 js.Expression key = pop();
677 List<js.SwitchClause> cases = <js.SwitchClause>[]; 677 List<js.SwitchClause> cases = <js.SwitchClause>[];
678 HSwitch switchInstruction = info.expression.end.last;
679 List<HInstruction> inputs = switchInstruction.inputs;
680 List<HBasicBlock> successors = switchInstruction.block.successors;
678 681
679 js.Block oldContainer = currentContainer; 682 js.Block oldContainer = currentContainer;
680 for (int i = 0; i < info.matchExpressions.length; i++) { 683 for (int inputIndex = 1, statementIndex = 0;
681 for (Constant constant in info.matchExpressions[i]) { 684 inputIndex < inputs.length;
682 generateConstant(constant); 685 statementIndex++) {
686 HBasicBlock successor = successors[inputIndex - 1];
687 do {
688 visit(inputs[inputIndex]);
683 currentContainer = new js.Block.empty(); 689 currentContainer = new js.Block.empty();
684 cases.add(new js.Case(pop(), currentContainer)); 690 cases.add(new js.Case(pop(), currentContainer));
685 } 691 inputIndex++;
686 if (i == info.matchExpressions.length - 1) { 692 } while ((successors[inputIndex - 1] == successor)
687 currentContainer = new js.Block.empty(); 693 && (inputIndex < inputs.length));
688 cases.add(new js.Default(currentContainer)); 694
689 } 695 generateStatements(info.statements[statementIndex]);
690 generateStatements(info.statements[i]);
691 } 696 }
697
698 currentContainer = new js.Block.empty();
699 cases.add(new js.Default(currentContainer));
700 generateStatements(info.statements.last);
701
692 currentContainer = oldContainer; 702 currentContainer = oldContainer;
693 703
694 js.Statement result = new js.Switch(key, cases); 704 js.Statement result = new js.Switch(key, cases);
695 pushStatement(wrapIntoLabels(result, info.labels)); 705 pushStatement(wrapIntoLabels(result, info.labels));
696 return true; 706 return true;
697 } 707 }
698 708
699 bool visitSequenceInfo(HStatementSequenceInformation info) { 709 bool visitSequenceInfo(HStatementSequenceInformation info) {
700 return false; 710 return false;
701 } 711 }
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 if (left.isConstantNull() || right.isConstantNull() || 2568 if (left.isConstantNull() || right.isConstantNull() ||
2559 (left.isPrimitive(compiler) && 2569 (left.isPrimitive(compiler) &&
2560 left.instructionType == right.instructionType)) { 2570 left.instructionType == right.instructionType)) {
2561 return '=='; 2571 return '==';
2562 } 2572 }
2563 return null; 2573 return null;
2564 } else { 2574 } else {
2565 return '==='; 2575 return '===';
2566 } 2576 }
2567 } 2577 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698