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

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

Issue 2938193003: Revert "Towards compiling Hello World!" and "Compile and run Hello World!" (Closed)
Patch Set: Created 3 years, 6 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
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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 TypeMask receiverType = node.getDartReceiver(_closedWorld).instructionType; 475 TypeMask receiverType = node.getDartReceiver(_closedWorld).instructionType;
476 MemberEntity element = 476 MemberEntity element =
477 _closedWorld.locateSingleElement(node.selector, receiverType); 477 _closedWorld.locateSingleElement(node.selector, receiverType);
478 // TODO(ngeoffray): Also fold if it's a getter or variable. 478 // TODO(ngeoffray): Also fold if it's a getter or variable.
479 if (element != null && 479 if (element != null &&
480 element.isFunction 480 element.isFunction
481 // If we found out that the only target is an implicitly called 481 // If we found out that the only target is an implicitly called
482 // [:noSuchMethod:] we just ignore it. 482 // [:noSuchMethod:] we just ignore it.
483 && 483 &&
484 node.selector.applies(element)) { 484 node.selector.applies(element)) {
485 FunctionEntity method = element; 485 MethodElement method = element;
486 486
487 if (_nativeData.isNativeMember(method)) { 487 if (_nativeData.isNativeMember(method)) {
488 HInstruction folded = tryInlineNativeMethod(node, method); 488 HInstruction folded = tryInlineNativeMethod(node, method);
489 if (folded != null) return folded; 489 if (folded != null) return folded;
490 } else { 490 } else {
491 // TODO(ngeoffray): If the method has optional parameters, 491 // TODO(ngeoffray): If the method has optional parameters,
492 // we should pass the default values. 492 // we should pass the default values.
493 ParameterStructure parameters = method.parameterStructure; 493 ResolutionFunctionType type = method.type;
494 if (parameters.optionalParameters == 0 || 494 int optionalParameterCount =
495 parameters.requiredParameters + parameters.optionalParameters == 495 type.optionalParameterTypes.length + type.namedParameters.length;
496 if (optionalParameterCount == 0 ||
497 type.parameterTypes.length + optionalParameterCount ==
496 node.selector.argumentCount) { 498 node.selector.argumentCount) {
497 node.element = method; 499 node.element = method;
498 } 500 }
499 } 501 }
500 return node; 502 return node;
501 } 503 }
502 504
503 // Replace method calls through fields with a closure call on the value of 505 // Replace method calls through fields with a closure call on the value of
504 // the field. This usually removes the demand for the call-through stub and 506 // the field. This usually removes the demand for the call-through stub and
505 // makes the field load available to further optimization, e.g. LICM. 507 // makes the field load available to further optimization, e.g. LICM.
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 return new HFieldGet(field, receiver, type, isAssignable: isAssignable); 1018 return new HFieldGet(field, receiver, type, isAssignable: isAssignable);
1017 } 1019 }
1018 1020
1019 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { 1021 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) {
1020 if (node.isInterceptedCall) { 1022 if (node.isInterceptedCall) {
1021 HInstruction folded = handleInterceptedCall(node); 1023 HInstruction folded = handleInterceptedCall(node);
1022 if (folded != node) return folded; 1024 if (folded != node) return folded;
1023 } 1025 }
1024 1026
1025 HInstruction receiver = node.getDartReceiver(_closedWorld); 1027 HInstruction receiver = node.getDartReceiver(_closedWorld);
1026 FieldEntity field = 1028 FieldElement field =
1027 findConcreteFieldForDynamicAccess(receiver, node.selector); 1029 findConcreteFieldForDynamicAccess(receiver, node.selector);
1028 if (field == null || !field.isAssignable) return node; 1030 if (field == null || !field.isAssignable) return node;
1029 // Use `node.inputs.last` in case the call follows the interceptor calling 1031 // Use `node.inputs.last` in case the call follows the interceptor calling
1030 // convention, but is not a call on an interceptor. 1032 // convention, but is not a call on an interceptor.
1031 HInstruction value = node.inputs.last; 1033 HInstruction value = node.inputs.last;
1032 if (_options.enableTypeAssertions) { 1034 if (_options.enableTypeAssertions) {
1033 // TODO(johnniwinther): Support field entities. 1035 ResolutionDartType type = field.type;
1034 FieldElement element = field;
1035 DartType type = element.type;
1036 if (!type.treatAsRaw || 1036 if (!type.treatAsRaw ||
1037 type.isTypeVariable || 1037 type.isTypeVariable ||
1038 type.unaliased.isFunctionType) { 1038 type.unaliased.isFunctionType) {
1039 // We cannot generate the correct type representation here, so don't 1039 // We cannot generate the correct type representation here, so don't
1040 // inline this access. 1040 // inline this access.
1041 // TODO(sra): If the input is such that we don't need a type check, we 1041 // TODO(sra): If the input is such that we don't need a type check, we
1042 // can skip the test an generate the HFieldSet. 1042 // can skip the test an generate the HFieldSet.
1043 return node; 1043 return node;
1044 } 1044 }
1045 HInstruction other = value.convertType( 1045 HInstruction other = value.convertType(
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 2988
2989 keyedValues.forEach((receiver, values) { 2989 keyedValues.forEach((receiver, values) {
2990 result.keyedValues[receiver] = 2990 result.keyedValues[receiver] =
2991 new Map<HInstruction, HInstruction>.from(values); 2991 new Map<HInstruction, HInstruction>.from(values);
2992 }); 2992 });
2993 2993
2994 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2994 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2995 return result; 2995 return result;
2996 } 2996 }
2997 } 2997 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | pkg/compiler/lib/src/ssa/rasta_ssa_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698