| Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| index 4748a59621bc931528b63d1b7e8d45ce5417427c..73b2e63621a6b2c0f73f66ee84ef20387c0d4b54 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| @@ -984,6 +984,8 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| operator, <Primitive>[argument], node.sourceInformation));
|
| }
|
|
|
| + bool trustPrimitives = compiler.trustPrimitives;
|
| +
|
| if (node.selector.isOperator && node.arguments.length == 2) {
|
| Primitive leftArg = getDartReceiver(node);
|
| Primitive rightArg = getDartArgument(node, 0);
|
| @@ -1016,8 +1018,8 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| leftArg, rightArg);
|
| }
|
| } else {
|
| - if (lattice.isDefinitelyNum(left, allowNull: false) &&
|
| - lattice.isDefinitelyNum(right, allowNull: false)) {
|
| + if (lattice.isDefinitelyNum(left, allowNull: trustPrimitives) &&
|
| + lattice.isDefinitelyNum(right, allowNull: trustPrimitives)) {
|
| // Try to insert a numeric operator.
|
| BuiltinOperator operator = NumBinaryBuiltins[opname];
|
| if (operator != null) {
|
| @@ -1028,7 +1030,7 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| // shift count.
|
| // Try to insert a shift-left operator.
|
| if (opname == '<<' &&
|
| - lattice.isDefinitelyInt(left) &&
|
| + lattice.isDefinitelyInt(left, allowNull: trustPrimitives) &&
|
| lattice.isDefinitelyIntInRange(right, min: 0, max: 31)) {
|
| return replaceWithBinary(BuiltinOperator.NumShl, leftArg, rightArg);
|
| }
|
| @@ -1036,14 +1038,14 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| // consistent with Dart's only for left operands in the unsigned
|
| // 32-bit range.
|
| if (opname == '>>' &&
|
| - lattice.isDefinitelyUint32(left) &&
|
| + lattice.isDefinitelyUint32(left, allowNull: trustPrimitives) &&
|
| lattice.isDefinitelyIntInRange(right, min: 0, max: 31)) {
|
| return replaceWithBinary(BuiltinOperator.NumShr, leftArg, rightArg);
|
| }
|
| // Try to use remainder for '%'. Both operands must be non-negative
|
| // and the divisor must be non-zero.
|
| if (opname == '%' &&
|
| - lattice.isDefinitelyUint(left) &&
|
| + lattice.isDefinitelyUint(left, allowNull: trustPrimitives) &&
|
| lattice.isDefinitelyUint(right) &&
|
| lattice.isDefinitelyIntInRange(right, min: 1)) {
|
| return replaceWithBinary(
|
| @@ -1051,15 +1053,15 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| }
|
|
|
| if (opname == '~/' &&
|
| - lattice.isDefinitelyUint32(left) &&
|
| + lattice.isDefinitelyUint32(left, allowNull: trustPrimitives) &&
|
| lattice.isDefinitelyIntInRange(right, min: 2)) {
|
| return replaceWithBinary(
|
| BuiltinOperator.NumTruncatingDivideToSigned32,
|
| leftArg, rightArg);
|
| }
|
| }
|
| - if (lattice.isDefinitelyString(left, allowNull: false) &&
|
| - lattice.isDefinitelyString(right, allowNull: false) &&
|
| + if (lattice.isDefinitelyString(left, allowNull: trustPrimitives) &&
|
| + lattice.isDefinitelyString(right, allowNull: trustPrimitives) &&
|
| opname == '+') {
|
| return replaceWithBinary(BuiltinOperator.StringConcatenate,
|
| leftArg, rightArg);
|
| @@ -1173,6 +1175,9 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| Primitive index,
|
| SourceInformation sourceInfo) {
|
| CpsFragment cps = new CpsFragment(sourceInfo);
|
| + if (compiler.trustPrimitives) {
|
| + return cps;
|
| + }
|
| Continuation fail = cps.letCont();
|
| Primitive isTooSmall = cps.applyBuiltin(
|
| BuiltinOperator.NumLt,
|
| @@ -2971,7 +2976,7 @@ class TypePropagationVisitor implements Visitor {
|
| // own bounds-check elimination?
|
| setValue(node, constantValue(new IntConstantValue(length)));
|
| } else {
|
| - setValue(node, nonConstant(typeSystem.intType));
|
| + setValue(node, nonConstant(typeSystem.uint32Type));
|
| }
|
| }
|
|
|
|
|