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

Side by Side Diff: pkg/compiler/lib/src/ssa/value_range_analyzer.dart

Issue 2673513003: dart2js: Introduce HGetLength to replace strange use of HFieldGet (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa_tracer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import '../constant_system_dart.dart'; 5 import '../constant_system_dart.dart';
6 import '../constants/constant_system.dart'; 6 import '../constants/constant_system.dart';
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../js_backend/backend_helpers.dart'; 8 import '../js_backend/backend_helpers.dart';
9 import '../world.dart' show ClosedWorld; 9 import '../world.dart' show ClosedWorld;
10 import 'nodes.dart'; 10 import 'nodes.dart';
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 691 }
692 if (constantNum.isPositiveInfinity || constantNum.isNegativeInfinity) { 692 if (constantNum.isPositiveInfinity || constantNum.isNegativeInfinity) {
693 return info.newUnboundRange(); 693 return info.newUnboundRange();
694 } 694 }
695 if (constantNum.isMinusZero) constantNum = new IntConstantValue(0); 695 if (constantNum.isMinusZero) constantNum = new IntConstantValue(0);
696 Value value = info.newIntValue(constantNum.primitiveValue); 696 Value value = info.newIntValue(constantNum.primitiveValue);
697 return info.newNormalizedRange(value, value); 697 return info.newNormalizedRange(value, value);
698 } 698 }
699 699
700 Range visitFieldGet(HFieldGet fieldGet) { 700 Range visitFieldGet(HFieldGet fieldGet) {
701 if (!fieldGet.isInteger(closedWorld)) return info.newUnboundRange(); 701 return visitInstruction(fieldGet);
Johnni Winther 2017/02/02 08:33:36 Why is this case removed?
702 if (!fieldGet.receiver.isIndexablePrimitive(closedWorld)) { 702 }
703 return visitInstruction(fieldGet); 703
704 } 704 Range visitGetLength(HGetLength node) {
705 assert(fieldGet.element == backendHelpers.jsIndexableLength); 705 PositiveValue value = info.newPositiveValue(node);
706 PositiveValue value = info.newPositiveValue(fieldGet);
707 // We know this range is above zero. To simplify the analysis, we 706 // We know this range is above zero. To simplify the analysis, we
708 // put the zero value as the lower bound of this range. This 707 // put the zero value as the lower bound of this range. This
709 // allows to easily remove the second bound check in the following 708 // allows to easily remove the second bound check in the following
710 // expression: a[1] + a[0]. 709 // expression: a[1] + a[0].
711 return info.newNormalizedRange(info.intZero, value); 710 return info.newNormalizedRange(info.intZero, value);
712 } 711 }
713 712
714 Range visitBoundsCheck(HBoundsCheck check) { 713 Range visitBoundsCheck(HBoundsCheck check) {
715 // Save the next instruction, in case the check gets removed. 714 // Save the next instruction, in case the check gets removed.
716 HInstruction next = check.next; 715 HInstruction next = check.next;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 } 1104 }
1106 1105
1107 Range handleBinaryOperation(HBinaryArithmetic instruction) { 1106 Range handleBinaryOperation(HBinaryArithmetic instruction) {
1108 Range leftRange = visit(instruction.left); 1107 Range leftRange = visit(instruction.left);
1109 Range rightRange = visit(instruction.right); 1108 Range rightRange = visit(instruction.right);
1110 if (leftRange == null || rightRange == null) return null; 1109 if (leftRange == null || rightRange == null) return null;
1111 BinaryOperation operation = instruction.operation(info.constantSystem); 1110 BinaryOperation operation = instruction.operation(info.constantSystem);
1112 return operation.apply(leftRange, rightRange); 1111 return operation.apply(leftRange, rightRange);
1113 } 1112 }
1114 } 1113 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa_tracer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698