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

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

Issue 2979813002: Use entities in the TypeSystem interface. (Closed)
Patch Set: 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (compiler.options.verbose) { 305 if (compiler.options.verbose) {
306 compiler.progress.reset(); 306 compiler.progress.reset();
307 } 307 }
308 sortResolvedAsts().forEach((ResolvedAst resolvedAst) { 308 sortResolvedAsts().forEach((ResolvedAst resolvedAst) {
309 if (compiler.shouldPrintProgress) { 309 if (compiler.shouldPrintProgress) {
310 reporter.log('Added $addedInGraph elements in inferencing graph.'); 310 reporter.log('Added $addedInGraph elements in inferencing graph.');
311 compiler.progress.reset(); 311 compiler.progress.reset();
312 } 312 }
313 // This also forces the creation of the [ElementTypeInformation] to ensure 313 // This also forces the creation of the [ElementTypeInformation] to ensure
314 // it is in the graph. 314 // it is in the graph.
315 types.withMember(resolvedAst.element, () => analyze(resolvedAst, null)); 315 MemberElement member = resolvedAst.element;
316 types.withMember(member, () => analyze(resolvedAst, null));
316 }); 317 });
317 reporter.log('Added $addedInGraph elements in inferencing graph.'); 318 reporter.log('Added $addedInGraph elements in inferencing graph.');
318 319
319 TypeGraphDump dump = debug.PRINT_GRAPH ? new TypeGraphDump(this) : null; 320 TypeGraphDump dump = debug.PRINT_GRAPH ? new TypeGraphDump(this) : null;
320 321
321 dump?.beforeAnalysis(); 322 dump?.beforeAnalysis();
322 buildWorkQueue(); 323 buildWorkQueue();
323 refine(); 324 refine();
324 325
325 // Try to infer element types of lists and compute their escape information. 326 // Try to infer element types of lists and compute their escape information.
(...skipping 15 matching lines...) Expand all
341 Iterable<FunctionEntity> elements, ClosureTracerVisitor tracer) { 342 Iterable<FunctionEntity> elements, ClosureTracerVisitor tracer) {
342 tracer.run(); 343 tracer.run();
343 if (!tracer.continueAnalyzing) { 344 if (!tracer.continueAnalyzing) {
344 elements.forEach((FunctionEntity _element) { 345 elements.forEach((FunctionEntity _element) {
345 MethodElement element = _element; 346 MethodElement element = _element;
346 MethodElement implementation = element.implementation; 347 MethodElement implementation = element.implementation;
347 closedWorldRefiner.registerMightBePassedToApply(element); 348 closedWorldRefiner.registerMightBePassedToApply(element);
348 if (debug.VERBOSE) { 349 if (debug.VERBOSE) {
349 print("traced closure $element as ${true} (bail)"); 350 print("traced closure $element as ${true} (bail)");
350 } 351 }
351 implementation.functionSignature.forEachParameter((parameter) { 352 implementation.functionSignature
353 .forEachParameter((FormalElement _parameter) {
354 ParameterElement parameter = _parameter;
352 types 355 types
353 .getInferredTypeOfParameter(parameter) 356 .getInferredTypeOfParameter(parameter)
354 .giveUp(this, clearAssignments: false); 357 .giveUp(this, clearAssignments: false);
355 }); 358 });
356 }); 359 });
357 bailedOutOn.addAll(elements); 360 bailedOutOn.addAll(elements);
358 return; 361 return;
359 } 362 }
360 elements 363 elements
361 .where((e) => !bailedOutOn.contains(e)) 364 .where((e) => !bailedOutOn.contains(e))
362 .forEach((FunctionEntity _element) { 365 .forEach((FunctionEntity _element) {
363 MethodElement element = _element; 366 MethodElement element = _element;
364 MethodElement implementation = element.implementation; 367 MethodElement implementation = element.implementation;
365 implementation.functionSignature.forEachParameter((parameter) { 368 implementation.functionSignature
366 var info = types.getInferredTypeOfParameter(parameter); 369 .forEachParameter((FormalElement _parameter) {
370 ParameterElement parameter = _parameter;
371 ParameterTypeInformation info =
372 types.getInferredTypeOfParameter(parameter);
367 info.maybeResume(); 373 info.maybeResume();
368 workQueue.add(info); 374 workQueue.add(info);
369 }); 375 });
370 if (tracer.tracedType.mightBePassedToFunctionApply) { 376 if (tracer.tracedType.mightBePassedToFunctionApply) {
371 closedWorldRefiner.registerMightBePassedToApply(element); 377 closedWorldRefiner.registerMightBePassedToApply(element);
372 } 378 }
373 if (debug.VERBOSE) { 379 if (debug.VERBOSE) {
374 print("traced closure $element as " 380 print("traced closure $element as "
375 "${closedWorldRefiner 381 "${closedWorldRefiner
376 .getCurrentlyKnownMightBePassedToApply(element)}"); 382 .getCurrentlyKnownMightBePassedToApply(element)}");
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (target is MethodElement) { 465 if (target is MethodElement) {
460 print( 466 print(
461 '${types.getInferredSignatureOfMethod(target)} for ${target}') ; 467 '${types.getInferredSignatureOfMethod(target)} for ${target}') ;
462 } else { 468 } else {
463 print( 469 print(
464 '${types.getInferredTypeOfMember(target).type} for ${target}') ; 470 '${types.getInferredTypeOfMember(target).type} for ${target}') ;
465 } 471 }
466 } 472 }
467 } else if (info is StaticCallSiteTypeInformation) { 473 } else if (info is StaticCallSiteTypeInformation) {
468 ClassElement cls = info.calledElement.enclosingClass; 474 ClassElement cls = info.calledElement.enclosingClass;
469 FunctionElement callMethod = cls.lookupMember(Identifiers.call); 475 MethodElement callMethod = cls.lookupMember(Identifiers.call);
470 print('${types.getInferredSignatureOfMethod(callMethod)} for ${cls}'); 476 print('${types.getInferredSignatureOfMethod(callMethod)} for ${cls}');
471 } else { 477 } else {
472 print('${info.type} for some unknown kind of closure'); 478 print('${info.type} for some unknown kind of closure');
473 } 479 }
474 }); 480 });
475 analyzedElements.forEach((MemberElement elem) { 481 analyzedElements.forEach((MemberElement elem) {
476 TypeInformation type = types.getInferredTypeOfMember(elem); 482 TypeInformation type = types.getInferredTypeOfMember(elem);
477 print('${elem} :: ${type} from ${type.assignments} '); 483 print('${elem} :: ${type} from ${type.assignments} ');
478 }); 484 });
479 } 485 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 info.closurizedCount++; 663 info.closurizedCount++;
658 if (Elements.isStaticOrTopLevel(method)) { 664 if (Elements.isStaticOrTopLevel(method)) {
659 types.allocatedClosures.add(info); 665 types.allocatedClosures.add(info);
660 } else { 666 } else {
661 // We add the call-site type information here so that we 667 // We add the call-site type information here so that we
662 // can benefit from further refinement of the selector. 668 // can benefit from further refinement of the selector.
663 types.allocatedClosures.add(caller); 669 types.allocatedClosures.add(caller);
664 } 670 }
665 FunctionElement function = method.implementation; 671 FunctionElement function = method.implementation;
666 FunctionSignature signature = function.functionSignature; 672 FunctionSignature signature = function.functionSignature;
667 signature.forEachParameter((Element parameter) { 673 signature.forEachParameter((FormalElement _parameter) {
674 ParameterElement parameter = _parameter;
668 ParameterTypeInformation info = 675 ParameterTypeInformation info =
669 types.getInferredTypeOfParameter(parameter); 676 types.getInferredTypeOfParameter(parameter);
670 info.tagAsTearOffClosureParameter(this); 677 info.tagAsTearOffClosureParameter(this);
671 if (addToQueue) workQueue.add(info); 678 if (addToQueue) workQueue.add(info);
672 }); 679 });
673 } 680 }
674 } else { 681 } else {
675 MethodElement method = callee; 682 MethodElement method = callee;
676 FunctionElement function = method.implementation; 683 FunctionElement function = method.implementation;
677 FunctionSignature signature = function.functionSignature; 684 FunctionSignature signature = function.functionSignature;
678 int parameterIndex = 0; 685 int parameterIndex = 0;
679 bool visitingRequiredParameter = true; 686 bool visitingRequiredParameter = true;
680 signature.forEachParameter((Element parameter) { 687 signature.forEachParameter((FormalElement _parameter) {
688 ParameterElement parameter = _parameter;
681 if (signature.hasOptionalParameters && 689 if (signature.hasOptionalParameters &&
682 parameter == signature.optionalParameters.first) { 690 parameter == signature.optionalParameters.first) {
683 visitingRequiredParameter = false; 691 visitingRequiredParameter = false;
684 } 692 }
685 TypeInformation type = visitingRequiredParameter 693 TypeInformation type = visitingRequiredParameter
686 ? arguments.positional[parameterIndex] 694 ? arguments.positional[parameterIndex]
687 : signature.optionalParametersAreNamed 695 : signature.optionalParametersAreNamed
688 ? arguments.named[parameter.name] 696 ? arguments.named[parameter.name]
689 : parameterIndex < arguments.positional.length 697 : parameterIndex < arguments.positional.length
690 ? arguments.positional[parameterIndex] 698 ? arguments.positional[parameterIndex]
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 /** 1115 /**
1108 * Records that the captured variable [local] is read. 1116 * Records that the captured variable [local] is read.
1109 */ 1117 */
1110 void recordCapturedLocalRead(Local local) {} 1118 void recordCapturedLocalRead(Local local) {}
1111 1119
1112 /** 1120 /**
1113 * Records that the variable [local] is being updated. 1121 * Records that the variable [local] is being updated.
1114 */ 1122 */
1115 void recordLocalUpdate(Local local, TypeInformation type) {} 1123 void recordLocalUpdate(Local local, TypeInformation type) {}
1116 } 1124 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/closure_tracer.dart ('k') | pkg/compiler/lib/src/inferrer/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698