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

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

Issue 2815403004: dart2js: Avoid inserting redundant HTypeKnown (Closed)
Patch Set: Created 3 years, 8 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/nodes.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 '../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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 return removeIfCheckAlwaysSucceeds(node, node.knownType); 898 return removeIfCheckAlwaysSucceeds(node, node.knownType);
899 } 899 }
900 900
901 HInstruction removeIfCheckAlwaysSucceeds(HCheck node, TypeMask checkedType) { 901 HInstruction removeIfCheckAlwaysSucceeds(HCheck node, TypeMask checkedType) {
902 if (checkedType.containsAll(_closedWorld)) return node; 902 if (checkedType.containsAll(_closedWorld)) return node;
903 HInstruction input = node.checkedInput; 903 HInstruction input = node.checkedInput;
904 TypeMask inputType = input.instructionType; 904 TypeMask inputType = input.instructionType;
905 return inputType.isInMask(checkedType, _closedWorld) ? input : node; 905 return inputType.isInMask(checkedType, _closedWorld) ? input : node;
906 } 906 }
907 907
908 HInstruction removeCheck(HCheck node) => node.checkedInput;
909
910 FieldEntity findConcreteFieldForDynamicAccess( 908 FieldEntity findConcreteFieldForDynamicAccess(
911 HInstruction receiver, Selector selector) { 909 HInstruction receiver, Selector selector) {
912 TypeMask receiverType = receiver.instructionType; 910 TypeMask receiverType = receiver.instructionType;
913 return _closedWorld.locateSingleField(selector, receiverType); 911 return _closedWorld.locateSingleField(selector, receiverType);
914 } 912 }
915 913
916 HInstruction visitFieldGet(HFieldGet node) { 914 HInstruction visitFieldGet(HFieldGet node) {
917 if (node.isNullCheck) return node; 915 if (node.isNullCheck) return node;
918 var receiver = node.receiver; 916 var receiver = node.receiver;
919 917
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 2192
2195 // Update users of [input] that are dominated by [:dominator.first:] 2193 // Update users of [input] that are dominated by [:dominator.first:]
2196 // to use [TypeKnown] of [input] instead. As the type information depends 2194 // to use [TypeKnown] of [input] instead. As the type information depends
2197 // on the control flow, we mark the inserted [HTypeKnown] nodes as 2195 // on the control flow, we mark the inserted [HTypeKnown] nodes as
2198 // non-movable. 2196 // non-movable.
2199 void insertTypePropagationForDominatedUsers( 2197 void insertTypePropagationForDominatedUsers(
2200 HBasicBlock dominator, HInstruction input, TypeMask convertedType) { 2198 HBasicBlock dominator, HInstruction input, TypeMask convertedType) {
2201 DominatedUses dominatedUses = DominatedUses.of(input, dominator.first); 2199 DominatedUses dominatedUses = DominatedUses.of(input, dominator.first);
2202 if (dominatedUses.isEmpty) return; 2200 if (dominatedUses.isEmpty) return;
2203 2201
2202 // Check to avoid adding a duplicate HTypeKnown node.
2203 if (dominatedUses.isSingleton) {
2204 HInstruction user = dominatedUses.single;
2205 if (user is HTypeKnown &&
2206 user.isPinned &&
2207 user.knownType == convertedType &&
2208 user.checkedInput == input) {
2209 return;
2210 }
2211 }
2212
2204 HTypeKnown newInput = new HTypeKnown.pinned(convertedType, input); 2213 HTypeKnown newInput = new HTypeKnown.pinned(convertedType, input);
2205 dominator.addBefore(dominator.first, newInput); 2214 dominator.addBefore(dominator.first, newInput);
2206 dominatedUses.replaceWith(newInput); 2215 dominatedUses.replaceWith(newInput);
2207 } 2216 }
2208 2217
2209 void visitIs(HIs instruction) { 2218 void visitIs(HIs instruction) {
2210 ResolutionDartType type = instruction.typeExpression; 2219 ResolutionDartType type = instruction.typeExpression;
2211 if (!instruction.isRawCheck) { 2220 if (!instruction.isRawCheck) {
2212 return; 2221 return;
2213 } else if (type.isTypedef) { 2222 } else if (type.isTypedef) {
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 2870
2862 keyedValues.forEach((receiver, values) { 2871 keyedValues.forEach((receiver, values) {
2863 result.keyedValues[receiver] = 2872 result.keyedValues[receiver] =
2864 new Map<HInstruction, HInstruction>.from(values); 2873 new Map<HInstruction, HInstruction>.from(values);
2865 }); 2874 });
2866 2875
2867 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2876 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2868 return result; 2877 return result;
2869 } 2878 }
2870 } 2879 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698