| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
| 9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 trace(elements, new ClosureTracerVisitor(elements, info, this)); | 390 trace(elements, new ClosureTracerVisitor(elements, info, this)); |
| 391 } else if (info is CallSiteTypeInformation) { | 391 } else if (info is CallSiteTypeInformation) { |
| 392 if (info is StaticCallSiteTypeInformation && | 392 if (info is StaticCallSiteTypeInformation && |
| 393 info.selector != null && | 393 info.selector != null && |
| 394 info.selector.isCall) { | 394 info.selector.isCall) { |
| 395 // This is a constructor call to a class with a call method. So we | 395 // This is a constructor call to a class with a call method. So we |
| 396 // need to trace the call method here. | 396 // need to trace the call method here. |
| 397 assert(info.calledElement.isGenerativeConstructor); | 397 assert(info.calledElement.isGenerativeConstructor); |
| 398 ClassElement cls = info.calledElement.enclosingClass; | 398 ClassElement cls = info.calledElement.enclosingClass; |
| 399 FunctionElement callMethod = cls.lookupMember(Identifiers.call); | 399 FunctionElement callMethod = cls.lookupMember(Identifiers.call); |
| 400 assert(invariant(cls, callMethod != null)); | 400 assert(callMethod != null, failedAt(cls)); |
| 401 Iterable<FunctionElement> elements = [callMethod]; | 401 Iterable<FunctionElement> elements = [callMethod]; |
| 402 trace(elements, new ClosureTracerVisitor(elements, info, this)); | 402 trace(elements, new ClosureTracerVisitor(elements, info, this)); |
| 403 } else { | 403 } else { |
| 404 // We only are interested in functions here, as other targets | 404 // We only are interested in functions here, as other targets |
| 405 // of this closure call are not a root to trace but an intermediate | 405 // of this closure call are not a root to trace but an intermediate |
| 406 // for some other function. | 406 // for some other function. |
| 407 Iterable<FunctionElement> elements = new List<FunctionElement>.from( | 407 Iterable<FunctionElement> elements = new List<FunctionElement>.from( |
| 408 info.callees.where((e) => e.isFunction)); | 408 info.callees.where((e) => e.isFunction)); |
| 409 trace(elements, new ClosureTracerVisitor(elements, info, this)); | 409 trace(elements, new ClosureTracerVisitor(elements, info, this)); |
| 410 } | 410 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } else { | 519 } else { |
| 520 // Although we might find a better type, we have to keep | 520 // Although we might find a better type, we have to keep |
| 521 // the old type around to ensure that we get a complete view | 521 // the old type around to ensure that we get a complete view |
| 522 // of the type graph and do not drop any flow edges. | 522 // of the type graph and do not drop any flow edges. |
| 523 TypeMask refinedType = computeTypeMask(closedWorld, value); | 523 TypeMask refinedType = computeTypeMask(closedWorld, value); |
| 524 assert(TypeMask.assertIsNormalized(refinedType, closedWorld)); | 524 assert(TypeMask.assertIsNormalized(refinedType, closedWorld)); |
| 525 type = new NarrowTypeInformation(type, refinedType); | 525 type = new NarrowTypeInformation(type, refinedType); |
| 526 types.allocatedTypes.add(type); | 526 types.allocatedTypes.add(type); |
| 527 } | 527 } |
| 528 } else { | 528 } else { |
| 529 assert(invariant( | 529 assert( |
| 530 fieldElement, | |
| 531 fieldElement.isInstanceMember || | 530 fieldElement.isInstanceMember || |
| 532 constant.isImplicit || | 531 constant.isImplicit || |
| 533 constant.isPotential, | 532 constant.isPotential, |
| 534 message: "Constant expression without value: " | 533 failedAt( |
| 534 fieldElement, |
| 535 "Constant expression without value: " |
| 535 "${constant.toStructuredText()}.")); | 536 "${constant.toStructuredText()}.")); |
| 536 } | 537 } |
| 537 } | 538 } |
| 538 } | 539 } |
| 539 recordType(element, type); | 540 recordType(element, type); |
| 540 } else if (!element.isInstanceMember) { | 541 } else if (!element.isInstanceMember) { |
| 541 recordType(element, types.nullType); | 542 recordType(element, types.nullType); |
| 542 } | 543 } |
| 543 } else if (initializer == null) { | 544 } else if (initializer == null) { |
| 544 // Only update types of static fields if there is no | 545 // Only update types of static fields if there is no |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // to get the same results for [ListTracer] compared to the | 979 // to get the same results for [ListTracer] compared to the |
| 979 // [SimpleTypesInferrer]. | 980 // [SimpleTypesInferrer]. |
| 980 Iterable<ResolvedAst> sortResolvedAsts() { | 981 Iterable<ResolvedAst> sortResolvedAsts() { |
| 981 int max = 0; | 982 int max = 0; |
| 982 Map<int, Setlet<ResolvedAst>> methodSizes = <int, Setlet<ResolvedAst>>{}; | 983 Map<int, Setlet<ResolvedAst>> methodSizes = <int, Setlet<ResolvedAst>>{}; |
| 983 compiler.enqueuer.resolution.processedEntities | 984 compiler.enqueuer.resolution.processedEntities |
| 984 .forEach((MemberElement element) { | 985 .forEach((MemberElement element) { |
| 985 ResolvedAst resolvedAst = element.resolvedAst; | 986 ResolvedAst resolvedAst = element.resolvedAst; |
| 986 element = element.implementation; | 987 element = element.implementation; |
| 987 if (element.impliesType) return; | 988 if (element.impliesType) return; |
| 988 assert(invariant( | 989 assert( |
| 989 element, | |
| 990 element.isField || | 990 element.isField || |
| 991 element.isFunction || | 991 element.isFunction || |
| 992 element.isConstructor || | 992 element.isConstructor || |
| 993 element.isGetter || | 993 element.isGetter || |
| 994 element.isSetter, | 994 element.isSetter, |
| 995 message: 'Unexpected element kind: ${element.kind}')); | 995 failedAt(element, 'Unexpected element kind: ${element.kind}')); |
| 996 if (element.isAbstract) return; | 996 if (element.isAbstract) return; |
| 997 // Put the other operators in buckets by length, later to be added in | 997 // Put the other operators in buckets by length, later to be added in |
| 998 // length order. | 998 // length order. |
| 999 int length = 0; | 999 int length = 0; |
| 1000 if (resolvedAst.kind == ResolvedAstKind.PARSED) { | 1000 if (resolvedAst.kind == ResolvedAstKind.PARSED) { |
| 1001 TreeElementMapping mapping = resolvedAst.elements; | 1001 TreeElementMapping mapping = resolvedAst.elements; |
| 1002 length = mapping.getSelectorCount(); | 1002 length = mapping.getSelectorCount(); |
| 1003 } | 1003 } |
| 1004 max = length > max ? length : max; | 1004 max = length > max ? length : max; |
| 1005 Setlet<ResolvedAst> set = | 1005 Setlet<ResolvedAst> set = |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 /** | 1084 /** |
| 1085 * Records that the captured variable [local] is read. | 1085 * Records that the captured variable [local] is read. |
| 1086 */ | 1086 */ |
| 1087 void recordCapturedLocalRead(Local local) {} | 1087 void recordCapturedLocalRead(Local local) {} |
| 1088 | 1088 |
| 1089 /** | 1089 /** |
| 1090 * Records that the variable [local] is being updated. | 1090 * Records that the variable [local] is being updated. |
| 1091 */ | 1091 */ |
| 1092 void recordLocalUpdate(Local local, TypeInformation type) {} | 1092 void recordLocalUpdate(Local local, TypeInformation type) {} |
| 1093 } | 1093 } |
| OLD | NEW |