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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (revision 30610)
+++ sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (working copy)
@@ -675,20 +675,29 @@
}
js.Expression key = pop();
List<js.SwitchClause> cases = <js.SwitchClause>[];
+ HSwitch switchInstruction = info.expression.end.last;
+ List<HInstruction> inputs = switchInstruction.inputs;
+ List<HBasicBlock> successors = switchInstruction.block.successors;
js.Block oldContainer = currentContainer;
- for (int i = 0; i < info.matchExpressions.length; i++) {
- for (Constant constant in info.matchExpressions[i]) {
- generateConstant(constant);
+ for (int inputIndex = 1, statementIndex = 0;
+ inputIndex < inputs.length;
+ statementIndex++) {
+ HBasicBlock successor = successors[inputIndex - 1];
+ do {
+ visit(inputs[inputIndex]);
currentContainer = new js.Block.empty();
cases.add(new js.Case(pop(), currentContainer));
- }
- if (i == info.matchExpressions.length - 1) {
- currentContainer = new js.Block.empty();
- cases.add(new js.Default(currentContainer));
- }
- generateStatements(info.statements[i]);
+ inputIndex++;
+ } while (successors[inputIndex - 1] == successor);
+
+ generateStatements(info.statements[statementIndex]);
}
+
+ currentContainer = new js.Block.empty();
+ cases.add(new js.Default(currentContainer));
+ generateStatements(info.statements[info.statements.length - 1]);
kasperl 2013/11/25 11:35:20 info.statements.last?
ngeoffray 2013/11/25 13:40:21 Done.
+
currentContainer = oldContainer;
js.Statement result = new js.Switch(key, cases);
« 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