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

Side by Side Diff: pkg/compiler/lib/src/inferrer/inferrer_engine.dart

Issue 2975053002: Encapsulate use of ast.Node in type_graph_nodes (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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) 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 : new ElementGraphBuilder(element, resolvedAst, compiler, this); 500 : new ElementGraphBuilder(element, resolvedAst, compiler, this);
501 TypeInformation type; 501 TypeInformation type;
502 reporter.withCurrentElement(element, () { 502 reporter.withCurrentElement(element, () {
503 // ignore: UNDEFINED_METHOD 503 // ignore: UNDEFINED_METHOD
504 type = visitor.run(); 504 type = visitor.run();
505 }); 505 });
506 addedInGraph++; 506 addedInGraph++;
507 507
508 if (element.isField) { 508 if (element.isField) {
509 FieldElement fieldElement = element; 509 FieldElement fieldElement = element;
510 ast.Node node = resolvedAst.node;
511 ast.Node initializer = resolvedAst.body; 510 ast.Node initializer = resolvedAst.body;
512 if (element.isFinal || element.isConst) { 511 if (element.isFinal || element.isConst) {
513 // If [element] is final and has an initializer, we record 512 // If [element] is final and has an initializer, we record
514 // the inferred type. 513 // the inferred type.
515 if (resolvedAst.body != null) { 514 if (resolvedAst.body != null) {
516 if (type is! ListTypeInformation && type is! MapTypeInformation) { 515 if (type is! ListTypeInformation && type is! MapTypeInformation) {
517 // For non-container types, the constant handler does 516 // For non-container types, the constant handler does
518 // constant folding that could give more precise results. 517 // constant folding that could give more precise results.
519 ConstantExpression constant = fieldElement.constant; 518 ConstantExpression constant = fieldElement.constant;
520 if (constant != null) { 519 if (constant != null) {
521 ConstantValue value = 520 ConstantValue value =
522 compiler.backend.constants.getConstantValue(constant); 521 compiler.backend.constants.getConstantValue(constant);
523 if (value != null) { 522 if (value != null) {
524 if (value.isFunction) { 523 if (value.isFunction) {
525 FunctionConstantValue functionConstant = value; 524 FunctionConstantValue functionConstant = value;
526 MethodElement function = functionConstant.element; 525 MethodElement function = functionConstant.element;
527 type = types.allocateClosure(node, function); 526 type = types.allocateClosure(function);
528 } else { 527 } else {
529 // Although we might find a better type, we have to keep 528 // Although we might find a better type, we have to keep
530 // the old type around to ensure that we get a complete view 529 // the old type around to ensure that we get a complete view
531 // of the type graph and do not drop any flow edges. 530 // of the type graph and do not drop any flow edges.
532 TypeMask refinedType = computeTypeMask(closedWorld, value); 531 TypeMask refinedType = computeTypeMask(closedWorld, value);
533 assert(TypeMask.assertIsNormalized(refinedType, closedWorld)); 532 assert(TypeMask.assertIsNormalized(refinedType, closedWorld));
534 type = new NarrowTypeInformation(type, refinedType); 533 type = new NarrowTypeInformation(type, refinedType);
535 types.allocatedTypes.add(type); 534 types.allocatedTypes.add(type);
536 } 535 }
537 } else { 536 } else {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 * [inLoop] tells whether the call happens in a loop. 906 * [inLoop] tells whether the call happens in a loop.
908 */ 907 */
909 TypeInformation registerCalledSelector( 908 TypeInformation registerCalledSelector(
910 ast.Node node, 909 ast.Node node,
911 Selector selector, 910 Selector selector,
912 TypeMask mask, 911 TypeMask mask,
913 TypeInformation receiverType, 912 TypeInformation receiverType,
914 MemberElement caller, 913 MemberElement caller,
915 ArgumentsTypes arguments, 914 ArgumentsTypes arguments,
916 SideEffects sideEffects, 915 SideEffects sideEffects,
917 bool inLoop) { 916 bool inLoop,
917 bool isConditional) {
918 if (selector.isClosureCall) { 918 if (selector.isClosureCall) {
919 return registerCalledClosure(node, selector, mask, receiverType, caller, 919 return registerCalledClosure(node, selector, mask, receiverType, caller,
920 arguments, sideEffects, inLoop); 920 arguments, sideEffects, inLoop);
921 } 921 }
922 922
923 closedWorld.locateMembers(selector, mask).forEach((_callee) { 923 closedWorld.locateMembers(selector, mask).forEach((_callee) {
924 MemberElement callee = _callee; 924 MemberElement callee = _callee;
925 updateSideEffects(sideEffects, selector, callee); 925 updateSideEffects(sideEffects, selector, callee);
926 }); 926 });
927 927
928 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation( 928 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation(
929 types.currentMember, 929 types.currentMember,
930 node, 930 node,
931 caller, 931 caller,
932 selector, 932 selector,
933 mask, 933 mask,
934 receiverType, 934 receiverType,
935 arguments, 935 arguments,
936 inLoop); 936 inLoop,
937 isConditional);
937 938
938 info.addToGraph(this); 939 info.addToGraph(this);
939 types.allocatedCalls.add(info); 940 types.allocatedCalls.add(info);
940 return info; 941 return info;
941 } 942 }
942 943
943 /** 944 /**
944 * Registers a call to await with an expression of type [argumentType] as 945 * Registers a call to await with an expression of type [argumentType] as
945 * argument. 946 * argument.
946 */ 947 */
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 /** 1116 /**
1116 * Records that the captured variable [local] is read. 1117 * Records that the captured variable [local] is read.
1117 */ 1118 */
1118 void recordCapturedLocalRead(Local local) {} 1119 void recordCapturedLocalRead(Local local) {}
1119 1120
1120 /** 1121 /**
1121 * Records that the variable [local] is being updated. 1122 * Records that the variable [local] is being updated.
1122 */ 1123 */
1123 void recordLocalUpdate(Local local, TypeInformation type) {} 1124 void recordLocalUpdate(Local local, TypeInformation type) {}
1124 } 1125 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/closure_tracer.dart ('k') | pkg/compiler/lib/src/inferrer/list_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698