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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart

Issue 94303002: Add another type JSPositiveInt to show a range analysis in the inferrer would be very beneficial :-… (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/types_propagation.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart (revision 30754)
+++ sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart (working copy)
@@ -107,6 +107,24 @@
return backend.numType;
}
+ TypeMask checkPositiveInteger(HBinaryArithmetic instruction) {
+ HInstruction left = instruction.left;
+ HInstruction right = instruction.right;
+ JavaScriptBackend backend = compiler.backend;
+ if (left.isPositiveInteger(compiler) && right.isPositiveInteger(compiler)) {
+ return backend.positiveIntType;
+ }
+ return visitBinaryArithmetic(instruction);
+ }
+
+ TypeMask visitMultiply(HMultiply instruction) {
+ return checkPositiveInteger(instruction);
+ }
+
+ TypeMask visitAdd(HAdd instruction) {
+ return checkPositiveInteger(instruction);
+ }
+
TypeMask visitNegate(HNegate instruction) {
return instruction.operand.instructionType;
}
@@ -249,7 +267,7 @@
if (right.isNumber(compiler)) return false;
JavaScriptBackend backend = compiler.backend;
TypeMask type = right.isIntegerOrNull(compiler)
- ? backend.intType
+ ? right.instructionType.nonNullable()
: backend.numType;
// TODO(ngeoffray): Some number operations don't have a builtin
// variant and will do the check in their method anyway. We

Powered by Google App Engine
This is Rietveld 408576698