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

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

Issue 2713393002: dart2js: HGetLength may become fixed (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 | « no previous file | 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 '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 5 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
6 import '../common/names.dart' show Selectors; 6 import '../common/names.dart' show Selectors;
7 import '../common/tasks.dart' show CompilerTask; 7 import '../common/tasks.dart' show CompilerTask;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 if (receiver.inputs[0].isInteger(closedWorld)) { 896 if (receiver.inputs[0].isInteger(closedWorld)) {
897 return receiver.inputs[0]; 897 return receiver.inputs[0];
898 } 898 }
899 } else if (receiver.isConstantList() || receiver.isConstantString()) { 899 } else if (receiver.isConstantList() || receiver.isConstantString()) {
900 return graph.addConstantInt(receiver.constant.length, closedWorld); 900 return graph.addConstantInt(receiver.constant.length, closedWorld);
901 } else { 901 } else {
902 var type = receiver.instructionType; 902 var type = receiver.instructionType;
903 if (type.isContainer && type.length != null) { 903 if (type.isContainer && type.length != null) {
904 HInstruction constant = graph.addConstantInt(type.length, closedWorld); 904 HInstruction constant = graph.addConstantInt(type.length, closedWorld);
905 if (type.isNullable) { 905 if (type.isNullable) {
906 // If the container can be null, we update all uses of the 906 // If the container can be null, we update all uses of the length
907 // length access to use the constant instead, but keep the 907 // access to use the constant instead, but keep the length access in
908 // length access in the graph, to ensure we still have a 908 // the graph, to ensure we still have a null check.
909 // null check.
910 node.block.rewrite(node, constant); 909 node.block.rewrite(node, constant);
911 return node; 910 return node;
912 } else { 911 } else {
913 return constant; 912 return constant;
914 } 913 }
915 } 914 }
916 } 915 }
916
917 if (node.isAssignable &&
918 isFixedLength(receiver.instructionType, closedWorld)) {
919 // The input type has changed to fixed-length so change to an unassignable
920 // HGetLength to allow more GVN optimizations.
921 return new HGetLength(receiver, node.instructionType,
922 isAssignable: false);
923 }
917 return node; 924 return node;
918 } 925 }
919 926
920 HInstruction visitIndex(HIndex node) { 927 HInstruction visitIndex(HIndex node) {
921 if (node.receiver.isConstantList() && node.index.isConstantInteger()) { 928 if (node.receiver.isConstantList() && node.index.isConstantInteger()) {
922 var instruction = node.receiver; 929 var instruction = node.receiver;
923 List<ConstantValue> entries = instruction.constant.entries; 930 List<ConstantValue> entries = instruction.constant.entries;
924 instruction = node.index; 931 instruction = node.index;
925 int index = instruction.constant.primitiveValue; 932 int index = instruction.constant.primitiveValue;
926 if (index >= 0 && index < entries.length) { 933 if (index >= 0 && index < entries.length) {
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 2787
2781 keyedValues.forEach((receiver, values) { 2788 keyedValues.forEach((receiver, values) {
2782 result.keyedValues[receiver] = 2789 result.keyedValues[receiver] =
2783 new Map<HInstruction, HInstruction>.from(values); 2790 new Map<HInstruction, HInstruction>.from(values);
2784 }); 2791 });
2785 2792
2786 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2793 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2787 return result; 2794 return result;
2788 } 2795 }
2789 } 2796 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698