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

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

Issue 2272923002: Fold HTypeInfoReadVariable of instance creation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 3 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 CodegenWorkItem; 5 import '../common/codegen.dart' show CodegenWorkItem;
6 import '../common/tasks.dart' show CompilerTask; 6 import '../common/tasks.dart' show CompilerTask;
7 import '../compiler.dart' show Compiler; 7 import '../compiler.dart' show Compiler;
8 import '../constants/constant_system.dart'; 8 import '../constants/constant_system.dart';
9 import '../constants/values.dart'; 9 import '../constants/values.dart';
10 import '../core_types.dart' show CoreClasses; 10 import '../core_types.dart' show CoreClasses;
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 HInstruction replacement = new HTypeInfoExpression( 1050 HInstruction replacement = new HTypeInfoExpression(
1051 TypeInfoExpressionKind.COMPLETE, 1051 TypeInfoExpressionKind.COMPLETE,
1052 typeArgument, 1052 typeArgument,
1053 const <HInstruction>[], 1053 const <HInstruction>[],
1054 backend.dynamicType); 1054 backend.dynamicType);
1055 return replacement; 1055 return replacement;
1056 } 1056 }
1057 return node; 1057 return node;
1058 } 1058 }
1059 1059
1060 HInstruction finishSubstituted(
1061 ClassElement createdClass, HInstruction select(int index)) {
Siggi Cherem (dart-lang) 2016/08/29 19:48:57 I'm not sure what 'select' means in this context.
sra1 2016/08/29 21:27:41 It is a 'select' because it picks an existing thin
1062 HInstruction instructionForTypeVariable(TypeVariableType tv) {
1063 return select(createdClass.thisType.typeArguments.indexOf(tv));
1064 }
1065
1066 DartType type = createdClass.thisType
1067 .asInstanceOf(variable.element.enclosingClass)
1068 .typeArguments[variable.element.index];
1069 if (type is TypeVariableType) {
1070 return instructionForTypeVariable(type);
1071 }
1072 List<HInstruction> arguments = <HInstruction>[];
1073 type.forEachTypeVariable((v) {
1074 arguments.add(instructionForTypeVariable(v));
1075 });
1076 HInstruction replacement = new HTypeInfoExpression(
1077 TypeInfoExpressionKind.COMPLETE,
1078 type,
1079 arguments,
1080 backend.dynamicType);
1081 return replacement;
1082 }
1083
1060 // Type variable evaluated in the context of a constant can be replaced with 1084 // Type variable evaluated in the context of a constant can be replaced with
1061 // a ground term type. 1085 // a ground term type.
1062 if (object is HConstant) { 1086 if (object is HConstant) {
1063 ConstantValue value = object.constant; 1087 ConstantValue value = object.constant;
1064 if (value is ConstructedConstantValue) { 1088 if (value is ConstructedConstantValue) {
1065 return finishGroundType(value.type); 1089 return finishGroundType(value.type);
1066 } 1090 }
1067 return node; 1091 return node;
1068 } 1092 }
1069 1093
1070 // TODO(sra): HTypeInfoReadVariable on an instance creation can be replaced 1094 // Store-forward and index into reified type on an instance creation.
1071 // with an input of the instance creation's HTypeInfoExpression (or a 1095 //
1072 // HTypeInfoExpression of an input). This would in effect store-forward the 1096 // Look for an allocation with type information, or allocation of a
1073 // type parameters. 1097 // non-generic type (which extends or mixes in a generic type).
1098
1099 if (object is HForeignNew) {
1100 return finishGroundType(object.element.thisType);
1101 }
1102 if (object is HInvokeStatic) {
1103 if (object.element == helpers.setRuntimeTypeInfo) {
1104 HInstruction allocation = object.inputs[0];
1105 if (allocation is HForeignNew) {
1106 HInstruction typeInfo = object.inputs[1];
1107 if (typeInfo is HTypeInfoExpression) {
1108 return finishSubstituted(
1109 allocation.element, (int index) => typeInfo.inputs[index]);
1110 }
1111 }
1112 return node;
1113 }
1114 // TODO(sra): Factory constructors pass type arguments after the value
1115 // arguments. The [select] argument indexes into these type arguments.
1116 }
1074 1117
1075 return node; 1118 return node;
1076 } 1119 }
1077 } 1120 }
1078 1121
1079 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { 1122 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
1080 final Set<HInstruction> boundsChecked; 1123 final Set<HInstruction> boundsChecked;
1081 final CodegenWorkItem work; 1124 final CodegenWorkItem work;
1082 final bool trustPrimitives; 1125 final bool trustPrimitives;
1083 final JavaScriptBackend backend; 1126 final JavaScriptBackend backend;
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 2508
2466 keyedValues.forEach((receiver, values) { 2509 keyedValues.forEach((receiver, values) {
2467 result.keyedValues[receiver] = 2510 result.keyedValues[receiver] =
2468 new Map<HInstruction, HInstruction>.from(values); 2511 new Map<HInstruction, HInstruction>.from(values);
2469 }); 2512 });
2470 2513
2471 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2514 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2472 return result; 2515 return result;
2473 } 2516 }
2474 } 2517 }
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