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

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

Issue 11270008: Add type annotations to remove warnings and fix a bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 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 /** 5 /**
6 * A [Value] represents both symbolic values like the value of a 6 * A [Value] represents both symbolic values like the value of a
7 * parameter, or the length of an array, and concrete values, like 7 * parameter, or the length of an array, and concrete values, like
8 * constants. 8 * constants.
9 */ 9 */
10 abstract class Value { 10 abstract class Value {
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 return indexRange; 648 return indexRange;
649 } 649 }
650 650
651 Range visitRelational(HRelational relational) { 651 Range visitRelational(HRelational relational) {
652 HInstruction right = relational.right; 652 HInstruction right = relational.right;
653 HInstruction left = relational.left; 653 HInstruction left = relational.left;
654 if (!left.isInteger(types)) return const Range.unbound(); 654 if (!left.isInteger(types)) return const Range.unbound();
655 if (!right.isInteger(types)) return const Range.unbound(); 655 if (!right.isInteger(types)) return const Range.unbound();
656 Operation operation = relational.operation(constantSystem); 656 BinaryOperation operation = relational.operation(constantSystem);
657 Range rightRange = ranges[relational.right]; 657 Range rightRange = ranges[relational.right];
658 Range leftRange = ranges[relational.left]; 658 Range leftRange = ranges[relational.left];
659 659
660 if (relational is HEquals || relational is HIdentity) { 660 if (relational is HEquals || relational is HIdentity) {
661 handleEqualityCheck(relational); 661 handleEqualityCheck(relational);
662 } else if (operation.apply(leftRange, rightRange)) { 662 } else if (operation.apply(leftRange, rightRange)) {
663 relational.block.rewrite( 663 relational.block.rewrite(
664 relational, graph.addConstantBool(true, constantSystem)); 664 relational, graph.addConstantBool(true, constantSystem));
665 relational.block.remove(relational); 665 relational.block.remove(relational);
666 } else if (reverseOperation(operation).apply(leftRange, rightRange)) { 666 } else if (reverseOperation(operation).apply(leftRange, rightRange)) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 cursor.block.addBefore(cursor, newInstruction); 735 cursor.block.addBefore(cursor, newInstruction);
736 // Update the users of the instruction dominated by [cursor] to 736 // Update the users of the instruction dominated by [cursor] to
737 // use the new instruction, that has an narrower range. 737 // use the new instruction, that has an narrower range.
738 Set<HInstruction> dominatedUsers = instruction.dominatedUsers(cursor); 738 Set<HInstruction> dominatedUsers = instruction.dominatedUsers(cursor);
739 for (HInstruction user in dominatedUsers) { 739 for (HInstruction user in dominatedUsers) {
740 user.changeUse(instruction, newInstruction); 740 user.changeUse(instruction, newInstruction);
741 } 741 }
742 return newInstruction; 742 return newInstruction;
743 } 743 }
744 744
745 static Operation reverseOperation(BinaryOperation operation) { 745 static BinaryOperation reverseOperation(BinaryOperation operation) {
746 if (operation == const LessOperation()) { 746 if (operation == const LessOperation()) {
747 return const GreaterEqualOperation(); 747 return const GreaterEqualOperation();
748 } else if (operation == const LessEqualOperation()) { 748 } else if (operation == const LessEqualOperation()) {
749 return const GreaterOperation(); 749 return const GreaterOperation();
750 } else if (operation == const GreaterOperation()) { 750 } else if (operation == const GreaterOperation()) {
751 return const LessEqualOperation(); 751 return const LessEqualOperation();
752 } else if (operation == const GreaterEqualOperation()) { 752 } else if (operation == const GreaterEqualOperation()) {
753 return const LessOperation(); 753 return const LessOperation();
754 } else { 754 } else {
755 return null; 755 return null;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 if (instruction is HPhi && !instruction.block.isLoopHeader()) { 937 if (instruction is HPhi && !instruction.block.isLoopHeader()) {
938 HInstruction result = unwrap(instruction.inputs[0]); 938 HInstruction result = unwrap(instruction.inputs[0]);
939 for (int i = 1; i < instruction.inputs.length; i++) { 939 for (int i = 1; i < instruction.inputs.length; i++) {
940 if (result != unwrap(instruction.inputs[i])) return instruction; 940 if (result != unwrap(instruction.inputs[i])) return instruction;
941 } 941 }
942 return result; 942 return result;
943 } 943 }
944 return instruction; 944 return instruction;
945 } 945 }
946 } 946 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698