| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import '../compiler.dart' show Compiler; | 5 import '../compiler.dart' show Compiler; |
| 6 import '../constants/constant_system.dart'; | 6 import '../constants/constant_system.dart'; |
| 7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
| 8 import '../elements/elements.dart' show Name; | 8 import '../elements/elements.dart' show Name; |
| 9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
| 10 import '../js_backend/js_backend.dart'; | 10 import '../js_backend/js_backend.dart'; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // All bitwise operations on primitive types either produce an | 532 // All bitwise operations on primitive types either produce an |
| 533 // integer or throw an error. | 533 // integer or throw an error. |
| 534 HInstruction left = instruction.inputs[1]; | 534 HInstruction left = instruction.inputs[1]; |
| 535 if (left.isPrimitiveOrNull(closedWorld)) { | 535 if (left.isPrimitiveOrNull(closedWorld)) { |
| 536 return closedWorld.commonMasks.uint32Type; | 536 return closedWorld.commonMasks.uint32Type; |
| 537 } | 537 } |
| 538 return super.computeTypeFromInputTypes(instruction, compiler, closedWorld); | 538 return super.computeTypeFromInputTypes(instruction, compiler, closedWorld); |
| 539 } | 539 } |
| 540 | 540 |
| 541 bool argumentLessThan32(HInstruction instruction) { | 541 bool argumentLessThan32(HInstruction instruction) { |
| 542 if (!instruction.isConstantInteger()) return false; | 542 return argumentInRange(instruction, 0, 31); |
| 543 HConstant rightConstant = instruction; | 543 } |
| 544 IntConstantValue intConstant = rightConstant.constant; | 544 |
| 545 int count = intConstant.primitiveValue; | 545 bool argumentInRange(HInstruction instruction, int low, int high) { |
| 546 return count >= 0 && count <= 31; | 546 if (instruction.isConstantInteger()) { |
| 547 HConstant rightConstant = instruction; |
| 548 IntConstantValue intConstant = rightConstant.constant; |
| 549 int value = intConstant.primitiveValue; |
| 550 return value >= low && value <= high; |
| 551 } |
| 552 // TODO(sra): Integrate with the bit-width analysis in codegen.dart. |
| 553 if (instruction is HBitAnd) { |
| 554 return low == 0 && |
| 555 (argumentInRange(instruction.inputs[0], low, high) || |
| 556 argumentInRange(instruction.inputs[1], low, high)); |
| 557 } |
| 558 return false; |
| 547 } | 559 } |
| 548 | 560 |
| 549 bool isPositive(HInstruction instruction, ClosedWorld closedWorld) { | 561 bool isPositive(HInstruction instruction, ClosedWorld closedWorld) { |
| 550 // TODO: We should use the value range analysis. Currently, ranges | 562 // TODO: We should use the value range analysis. Currently, ranges |
| 551 // are discarded just after the analysis. | 563 // are discarded just after the analysis. |
| 552 return instruction.isPositiveInteger(closedWorld); | 564 return instruction.isPositiveInteger(closedWorld); |
| 553 } | 565 } |
| 554 } | 566 } |
| 555 | 567 |
| 556 class ShiftLeftSpecializer extends BinaryBitOpSpecializer { | 568 class ShiftLeftSpecializer extends BinaryBitOpSpecializer { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { | 922 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { |
| 911 HInstruction receiver = instruction.getDartReceiver(closedWorld); | 923 HInstruction receiver = instruction.getDartReceiver(closedWorld); |
| 912 if (receiver.isNumberOrNull(closedWorld)) { | 924 if (receiver.isNumberOrNull(closedWorld)) { |
| 913 // Even if there is no builtin equivalent instruction, we know the | 925 // Even if there is no builtin equivalent instruction, we know the |
| 914 // instruction does not have any side effect, and that it can be GVN'ed. | 926 // instruction does not have any side effect, and that it can be GVN'ed. |
| 915 clearAllSideEffects(instruction); | 927 clearAllSideEffects(instruction); |
| 916 } | 928 } |
| 917 return null; | 929 return null; |
| 918 } | 930 } |
| 919 } | 931 } |
| OLD | NEW |