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

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

Issue 10116023: Don't rely on any speculative type in the bailout version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cosmetic change (formatting). Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 class HCheck extends HInstruction { 1060 class HCheck extends HInstruction {
1061 HCheck(inputs) : super(inputs); 1061 HCheck(inputs) : super(inputs);
1062 1062
1063 // TODO(floitsch): make class abstract instead of adding an abstract method. 1063 // TODO(floitsch): make class abstract instead of adding an abstract method.
1064 abstract accept(HVisitor visitor); 1064 abstract accept(HVisitor visitor);
1065 1065
1066 bool isControlFlow() => true; 1066 bool isControlFlow() => true;
1067 } 1067 }
1068 1068
1069 class HTypeGuard extends HInstruction { 1069 class HTypeGuard extends HInstruction {
1070 int state; 1070 final int state;
1071 HTypeGuard(int this.state, List<HInstruction> env) : super(env); 1071 final HType guardedType;
1072 bool isActive = false;
ngeoffray 2012/04/18 12:05:09 Not sure, but for me isOn conveys more what this i
floitsch 2012/04/18 17:18:46 Done.
1073 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env);
1072 1074
1073 void prepareGvn() { 1075 void prepareGvn() {
1074 assert(!hasSideEffects()); 1076 assert(!hasSideEffects());
1075 setUseGvn(); 1077 setUseGvn();
1076 } 1078 }
1077 1079
1078 HInstruction get guarded() => inputs.last(); 1080 HInstruction get guarded() => inputs.last();
1079 1081
1082 HType computeTypeFromInputTypes() {
1083 if (isActive) return guardedType;
kasperl 2012/04/18 11:46:15 return isActive ? guardedType : guarded.propagated
floitsch 2012/04/18 17:18:46 Done.
1084 return guarded.propagatedType;
1085 }
1086
1087 HType get guaranteedType() => isActive ? guardedType : HType.UNKNOWN;
1088
1080 bool isControlFlow() => true; 1089 bool isControlFlow() => true;
1081 1090
1082 accept(HVisitor visitor) => visitor.visitTypeGuard(this); 1091 accept(HVisitor visitor) => visitor.visitTypeGuard(this);
1083 int typeCode() => 1; 1092 int typeCode() => 1;
1084 bool typeEquals(other) => other is HTypeGuard; 1093 bool typeEquals(other) => other is HTypeGuard;
1085 bool dataEquals(HTypeGuard other) => propagatedType == other.propagatedType; 1094 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType;
1086 } 1095 }
1087 1096
1088 class HBoundsCheck extends HCheck { 1097 class HBoundsCheck extends HCheck {
1089 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); 1098 HBoundsCheck(length, index) : super(<HInstruction>[length, index]);
1090 1099
1091 HInstruction get length() => inputs[0]; 1100 HInstruction get length() => inputs[0];
1092 HInstruction get index() => inputs[1]; 1101 HInstruction get index() => inputs[1];
1093 1102
1094 void prepareGvn() { 1103 void prepareGvn() {
1095 assert(!hasSideEffects()); 1104 assert(!hasSideEffects());
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 HType computeDesiredTypeForNonTargetInput(HInstruction input) { 1420 HType computeDesiredTypeForNonTargetInput(HInstruction input) {
1412 // If the desired output type should be an integer we want to get two 1421 // If the desired output type should be an integer we want to get two
1413 // integers as arguments. 1422 // integers as arguments.
1414 if (propagatedType.isInteger()) return HType.INTEGER; 1423 if (propagatedType.isInteger()) return HType.INTEGER;
1415 // If the outgoing type should be a number we can get that if both inputs 1424 // If the outgoing type should be a number we can get that if both inputs
1416 // are numbers. If we don't know the outgoing type we try to make it a 1425 // are numbers. If we don't know the outgoing type we try to make it a
1417 // number. 1426 // number.
1418 if (propagatedType.isUnknown() || propagatedType.isNumber()) { 1427 if (propagatedType.isUnknown() || propagatedType.isNumber()) {
1419 return HType.NUMBER; 1428 return HType.NUMBER;
1420 } 1429 }
1430 // Even if the desired outgoing type is not a number we still want the
1431 // second argument to be a number if the first one is a number. This will
1432 // not help for the outgoing type, but at least the binary arithmetic
1433 // operation will not have type problems.
1434 // TODO(floitsch): normally we shouldn't request a number, but simply
1435 // throw an IllegalArgumentException if it isn't. This would be similar
1436 // to the array case.
1437 if (input == right && left.isNumber()) return HType.NUMBER;
1421 return HType.UNKNOWN; 1438 return HType.UNKNOWN;
1422 } 1439 }
1423 1440
1424 HType get likelyType() { 1441 HType get likelyType() {
1425 if (left.isTypeUnknown()) return HType.NUMBER; 1442 if (left.isTypeUnknown()) return HType.NUMBER;
1426 return HType.UNKNOWN; 1443 return HType.UNKNOWN;
1427 } 1444 }
1428 1445
1429 // TODO(1603): The class should be marked as abstract. 1446 // TODO(1603): The class should be marked as abstract.
1430 abstract BinaryOperation get operation(); 1447 abstract BinaryOperation get operation();
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 class HIfBlockInformation { 2243 class HIfBlockInformation {
2227 final HIf branch; 2244 final HIf branch;
2228 final SubGraph thenGraph; 2245 final SubGraph thenGraph;
2229 final SubGraph elseGraph; 2246 final SubGraph elseGraph;
2230 final HBasicBlock joinBlock; 2247 final HBasicBlock joinBlock;
2231 HIfBlockInformation(this.branch, 2248 HIfBlockInformation(this.branch,
2232 this.thenGraph, 2249 this.thenGraph,
2233 this.elseGraph, 2250 this.elseGraph,
2234 this.joinBlock); 2251 this.joinBlock);
2235 } 2252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698