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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 2743243003: Split MirrorsData (Closed)
Patch Set: Created 3 years, 9 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 library js_backend.backend; 5 library js_backend.backend;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
10 10
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 RuntimeTypesNeed _rtiNeed; 373 RuntimeTypesNeed _rtiNeed;
374 final _RuntimeTypes _rti; 374 final _RuntimeTypes _rti;
375 RuntimeTypesChecks _rtiChecks; 375 RuntimeTypesChecks _rtiChecks;
376 376
377 RuntimeTypesEncoder _rtiEncoder; 377 RuntimeTypesEncoder _rtiEncoder;
378 378
379 /// True if the html library has been loaded. 379 /// True if the html library has been loaded.
380 bool htmlLibraryIsLoaded = false; 380 bool htmlLibraryIsLoaded = false;
381 381
382 /// Resolution analysis for tracking reflective access to type variables. 382 /// Resolution analysis for tracking reflective access to type variables.
383 TypeVariableAnalysis typeVariableAnalysis; 383 TypeVariableAnalysis _typeVariableAnalysis;
384 384
385 /// Codegen handler for reflective access to type variables. 385 /// Codegen handler for reflective access to type variables.
386 TypeVariableHandler typeVariableHandler; 386 TypeVariableHandler _typeVariableHandler;
387 387
388 /// Resolution support for generating table of interceptors and 388 /// Resolution support for generating table of interceptors and
389 /// constructors for custom elements. 389 /// constructors for custom elements.
390 CustomElementsResolutionAnalysis customElementsResolutionAnalysis; 390 CustomElementsResolutionAnalysis customElementsResolutionAnalysis;
391 391
392 /// Codegen support for generating table of interceptors and 392 /// Codegen support for generating table of interceptors and
393 /// constructors for custom elements. 393 /// constructors for custom elements.
394 CustomElementsCodegenAnalysis customElementsCodegenAnalysis; 394 CustomElementsCodegenAnalysis customElementsCodegenAnalysis;
395 395
396 /// Resolution support for tree-shaking entries of `LookupMap`. 396 /// Resolution support for tree-shaking entries of `LookupMap`.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 NativeClassData get nativeClassData => _nativeClassData; 433 NativeClassData get nativeClassData => _nativeClassData;
434 NativeData get nativeData => _nativeData; 434 NativeData get nativeData => _nativeData;
435 NativeClassDataBuilder get nativeClassDataBuilder => _nativeClassData; 435 NativeClassDataBuilder get nativeClassDataBuilder => _nativeClassData;
436 NativeDataBuilder get nativeDataBuilder => _nativeData; 436 NativeDataBuilder get nativeDataBuilder => _nativeData;
437 final NativeDataResolver _nativeDataResolver; 437 final NativeDataResolver _nativeDataResolver;
438 InterceptorDataBuilder _interceptorDataBuilder; 438 InterceptorDataBuilder _interceptorDataBuilder;
439 InterceptorData _interceptorData; 439 InterceptorData _interceptorData;
440 OneShotInterceptorData _oneShotInterceptorData; 440 OneShotInterceptorData _oneShotInterceptorData;
441 BackendUsage _backendUsage; 441 BackendUsage _backendUsage;
442 BackendUsageBuilder _backendUsageBuilder; 442 BackendUsageBuilder _backendUsageBuilder;
443 MirrorsData mirrorsData; 443 MirrorsDataImpl _mirrorsData;
444 CheckedModeHelpers _checkedModeHelpers; 444 CheckedModeHelpers _checkedModeHelpers;
445 445
446 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; 446 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer;
447 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer; 447 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer;
448 448
449 BackendHelpers helpers; 449 BackendHelpers helpers;
450 BackendImpacts impacts; 450 BackendImpacts impacts;
451 451
452 /// Common classes used by the backend. 452 /// Common classes used by the backend.
453 BackendClasses backendClasses; 453 BackendClasses backendClasses;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 useNewSourceInfo: useNewSourceInfo), 497 useNewSourceInfo: useNewSourceInfo),
498 frontend = new JSFrontendAccess(compiler), 498 frontend = new JSFrontendAccess(compiler),
499 constantCompilerTask = new JavaScriptConstantTask(compiler), 499 constantCompilerTask = new JavaScriptConstantTask(compiler),
500 _nativeDataResolver = new NativeDataResolverImpl(compiler) { 500 _nativeDataResolver = new NativeDataResolverImpl(compiler) {
501 _nativeData = new NativeDataImpl(nativeClassData); 501 _nativeData = new NativeDataImpl(nativeClassData);
502 _target = new JavaScriptBackendTarget(this); 502 _target = new JavaScriptBackendTarget(this);
503 helpers = new BackendHelpers(compiler.elementEnvironment, commonElements); 503 helpers = new BackendHelpers(compiler.elementEnvironment, commonElements);
504 impacts = new BackendImpacts(compiler.options, commonElements, helpers); 504 impacts = new BackendImpacts(compiler.options, commonElements, helpers);
505 backendClasses = new JavaScriptBackendClasses( 505 backendClasses = new JavaScriptBackendClasses(
506 compiler.elementEnvironment, helpers, nativeClassData); 506 compiler.elementEnvironment, helpers, nativeClassData);
507 mirrorsData = new MirrorsData( 507 _mirrorsData = new MirrorsDataImpl(
508 compiler, compiler.options, commonElements, helpers, constants); 508 compiler, compiler.options, commonElements, helpers, constants);
509 _backendUsageBuilder = new BackendUsageBuilderImpl( 509 _backendUsageBuilder = new BackendUsageBuilderImpl(
510 compiler.elementEnvironment, commonElements, helpers); 510 compiler.elementEnvironment, commonElements, helpers);
511 _checkedModeHelpers = new CheckedModeHelpers(commonElements, helpers); 511 _checkedModeHelpers = new CheckedModeHelpers(commonElements, helpers);
512 emitter = 512 emitter =
513 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); 513 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter);
514 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer(compiler); 514 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer(compiler);
515 _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer( 515 _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer(
516 compiler, emitter, _nativeResolutionEnqueuer); 516 compiler, emitter, _nativeResolutionEnqueuer);
517 517
518 typeVariableAnalysis = new TypeVariableAnalysis( 518 _typeVariableAnalysis = new TypeVariableAnalysis(
519 compiler.elementEnvironment, impacts, backendUsageBuilder); 519 compiler.elementEnvironment, impacts, backendUsageBuilder);
520 typeVariableHandler = new TypeVariableHandler(this, helpers, mirrorsData);
521 customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( 520 customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis(
522 compiler.resolution, 521 compiler.resolution,
523 constantSystem, 522 constantSystem,
524 commonElements, 523 commonElements,
525 backendClasses, 524 backendClasses,
526 helpers, 525 helpers,
527 nativeClassData, 526 nativeClassData,
528 backendUsageBuilder); 527 backendUsageBuilder);
529 customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis( 528 customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis(
530 compiler.resolution, 529 compiler.resolution,
(...skipping 11 matching lines...) Expand all
542 kernelTask = new KernelTask(compiler); 541 kernelTask = new KernelTask(compiler);
543 impactTransformer = new JavaScriptImpactTransformer( 542 impactTransformer = new JavaScriptImpactTransformer(
544 compiler.options, 543 compiler.options,
545 compiler.resolution, 544 compiler.resolution,
546 compiler.elementEnvironment, 545 compiler.elementEnvironment,
547 commonElements, 546 commonElements,
548 impacts, 547 impacts,
549 nativeClassData, 548 nativeClassData,
550 nativeResolutionEnqueuer, 549 nativeResolutionEnqueuer,
551 backendUsageBuilder, 550 backendUsageBuilder,
552 mirrorsData, 551 mirrorsDataBuilder,
553 customElementsResolutionAnalysis, 552 customElementsResolutionAnalysis,
554 rtiNeedBuilder); 553 rtiNeedBuilder);
555 patchResolverTask = new PatchResolverTask(compiler); 554 patchResolverTask = new PatchResolverTask(compiler);
556 functionCompiler = 555 functionCompiler =
557 new SsaFunctionCompiler(this, sourceInformationStrategy, useKernel); 556 new SsaFunctionCompiler(this, sourceInformationStrategy, useKernel);
558 serialization = 557 serialization =
559 new JavaScriptBackendSerialization(nativeClassData, nativeData); 558 new JavaScriptBackendSerialization(nativeClassData, nativeData);
560 _interceptorDataBuilder = new InterceptorDataBuilderImpl( 559 _interceptorDataBuilder = new InterceptorDataBuilderImpl(
561 nativeClassData, helpers, commonElements, compiler.resolution); 560 nativeClassData, helpers, commonElements, compiler.resolution);
562 } 561 }
563 562
564 /// The [ConstantSystem] used to interpret compile-time constants for this 563 /// The [ConstantSystem] used to interpret compile-time constants for this
565 /// backend. 564 /// backend.
566 ConstantSystem get constantSystem => constants.constantSystem; 565 ConstantSystem get constantSystem => constants.constantSystem;
567 566
568 DiagnosticReporter get reporter => compiler.reporter; 567 DiagnosticReporter get reporter => compiler.reporter;
569 568
570 CommonElements get commonElements => compiler.commonElements; 569 CommonElements get commonElements => compiler.commonElements;
571 570
572 Resolution get resolution => compiler.resolution; 571 Resolution get resolution => compiler.resolution;
573 572
574 Target get target => _target; 573 Target get target => _target;
575 574
575 /// Resolution analysis for tracking reflective access to type variables.
576 TypeVariableAnalysis get typeVariableAnalysis {
577 assert(invariant(NO_LOCATION_SPANNABLE, _typeVariableHandler == null,
578 message: "TypeVariableHandler has already been created."));
579 return _typeVariableAnalysis;
580 }
581
582 /// Codegen handler for reflective access to type variables.
583 TypeVariableHandler get typeVariableHandler {
584 assert(invariant(NO_LOCATION_SPANNABLE, _typeVariableHandler != null,
585 message: "TypeVariableHandler has not been created yet."));
586 return _typeVariableHandler;
587 }
588
589 MirrorsData get mirrorsData => _mirrorsData;
590
591 MirrorsDataBuilder get mirrorsDataBuilder => _mirrorsData;
592
576 /// Codegen support for tree-shaking entries of `LookupMap`. 593 /// Codegen support for tree-shaking entries of `LookupMap`.
577 LookupMapAnalysis get lookupMapAnalysis { 594 LookupMapAnalysis get lookupMapAnalysis {
578 assert(invariant(NO_LOCATION_SPANNABLE, _lookupMapAnalysis != null, 595 assert(invariant(NO_LOCATION_SPANNABLE, _lookupMapAnalysis != null,
579 message: "LookupMapAnalysis has not been created yet.")); 596 message: "LookupMapAnalysis has not been created yet."));
580 return _lookupMapAnalysis; 597 return _lookupMapAnalysis;
581 } 598 }
582 599
583 InterceptorData get interceptorData { 600 InterceptorData get interceptorData {
584 assert(invariant(NO_LOCATION_SPANNABLE, _interceptorData != null, 601 assert(invariant(NO_LOCATION_SPANNABLE, _interceptorData != null,
585 message: "InterceptorData has not been computed yet.")); 602 message: "InterceptorData has not been computed yet."));
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 validateInterceptorImplementsAllObjectMethods(helpers.jsInterceptorClass); 791 validateInterceptorImplementsAllObjectMethods(helpers.jsInterceptorClass);
775 // The null-interceptor must also implement *all* methods. 792 // The null-interceptor must also implement *all* methods.
776 validateInterceptorImplementsAllObjectMethods(helpers.jsNullClass); 793 validateInterceptorImplementsAllObjectMethods(helpers.jsNullClass);
777 } 794 }
778 795
779 void onResolutionComplete( 796 void onResolutionComplete(
780 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) { 797 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) {
781 for (Entity entity in compiler.enqueuer.resolution.processedEntities) { 798 for (Entity entity in compiler.enqueuer.resolution.processedEntities) {
782 processAnnotations(entity, closedWorldRefiner); 799 processAnnotations(entity, closedWorldRefiner);
783 } 800 }
784 mirrorsData.computeMembersNeededForReflection( 801 mirrorsDataBuilder.computeMembersNeededForReflection(
785 compiler.enqueuer.resolution.worldBuilder, closedWorld); 802 compiler.enqueuer.resolution.worldBuilder, closedWorld);
786 _backendUsage = _backendUsageBuilder.close(); 803 _backendUsage = _backendUsageBuilder.close();
787 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( 804 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed(
788 compiler.enqueuer.resolution.worldBuilder, 805 compiler.enqueuer.resolution.worldBuilder,
789 closedWorld, 806 closedWorld,
790 compiler.types, 807 compiler.types,
791 commonElements, 808 commonElements,
792 helpers, 809 helpers,
793 _backendUsage, 810 _backendUsage,
794 enableTypeAssertions: compiler.options.enableTypeAssertions); 811 enableTypeAssertions: compiler.options.enableTypeAssertions);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 compiler.options, 884 compiler.options,
868 compiler.elementEnvironment, 885 compiler.elementEnvironment,
869 commonElements, 886 commonElements,
870 helpers, 887 helpers,
871 impacts, 888 impacts,
872 backendClasses, 889 backendClasses,
873 nativeClassData, 890 nativeClassData,
874 _interceptorDataBuilder, 891 _interceptorDataBuilder,
875 _backendUsageBuilder, 892 _backendUsageBuilder,
876 _rtiNeedBuilder, 893 _rtiNeedBuilder,
877 mirrorsData, 894 mirrorsDataBuilder,
878 noSuchMethodRegistry, 895 noSuchMethodRegistry,
879 customElementsResolutionAnalysis, 896 customElementsResolutionAnalysis,
880 lookupMapLibraryAccess, 897 lookupMapLibraryAccess,
881 mirrorsAnalysis, 898 mirrorsAnalysis,
882 typeVariableAnalysis, 899 typeVariableAnalysis,
883 _nativeResolutionEnqueuer), 900 _nativeResolutionEnqueuer),
884 new ElementResolutionWorldBuilder( 901 new ElementResolutionWorldBuilder(
885 this, compiler.resolution, const OpenWorldStrategy()), 902 this, compiler.resolution, const OpenWorldStrategy()),
886 new ResolutionWorkItemBuilder(compiler.resolution)); 903 new ResolutionWorkItemBuilder(compiler.resolution));
887 } 904 }
888 905
889 /// Creates an [Enqueuer] for code generation specific to this backend. 906 /// Creates an [Enqueuer] for code generation specific to this backend.
890 CodegenEnqueuer createCodegenEnqueuer( 907 CodegenEnqueuer createCodegenEnqueuer(
891 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { 908 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) {
909 _typeVariableHandler = new TypeVariableHandler(this, helpers, mirrorsData);
892 _lookupMapAnalysis = new LookupMapAnalysis( 910 _lookupMapAnalysis = new LookupMapAnalysis(
893 reporter, 911 reporter,
894 constantSystem, 912 constantSystem,
895 constants, 913 constants,
896 compiler.elementEnvironment, 914 compiler.elementEnvironment,
897 commonElements, 915 commonElements,
898 helpers, 916 helpers,
899 backendClasses, 917 backendClasses,
900 lookupMapLibraryAccess); 918 lookupMapLibraryAccess);
901 return new CodegenEnqueuer( 919 return new CodegenEnqueuer(
902 task, 920 task,
903 compiler.options, 921 compiler.options,
904 const TreeShakingEnqueuerStrategy(), 922 const TreeShakingEnqueuerStrategy(),
905 new CodegenWorldBuilderImpl( 923 new CodegenWorldBuilderImpl(
906 nativeClassData, closedWorld, constants, const TypeMaskStrategy()), 924 nativeClassData, closedWorld, constants, const TypeMaskStrategy()),
907 new CodegenWorkItemBuilder(this, compiler.options), 925 new CodegenWorkItemBuilder(this, compiler.options),
908 new CodegenEnqueuerListener( 926 new CodegenEnqueuerListener(
909 compiler.dumpInfoTask, 927 compiler.dumpInfoTask,
910 compiler.elementEnvironment, 928 compiler.elementEnvironment,
911 commonElements, 929 commonElements,
912 helpers, 930 helpers,
913 impacts, 931 impacts,
914 backendClasses, 932 backendClasses,
915 backendUsage, 933 backendUsage,
916 rtiNeed, 934 rtiNeed,
917 mirrorsData,
918 customElementsCodegenAnalysis, 935 customElementsCodegenAnalysis,
919 typeVariableHandler, 936 typeVariableHandler,
920 lookupMapAnalysis, 937 lookupMapAnalysis,
921 mirrorsAnalysis, 938 mirrorsAnalysis,
922 _nativeCodegenEnqueuer)); 939 _nativeCodegenEnqueuer));
923 } 940 }
924 941
925 WorldImpact codegen(CodegenWorkItem work) { 942 WorldImpact codegen(CodegenWorkItem work) {
926 Element element = work.element; 943 Element element = work.element;
927 if (compiler.elementHasCompileTimeError(element)) { 944 if (compiler.elementHasCompileTimeError(element)) {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 _codegenImpactTransformer = new CodegenImpactTransformer( 1201 _codegenImpactTransformer = new CodegenImpactTransformer(
1185 compiler.options, 1202 compiler.options,
1186 compiler.elementEnvironment, 1203 compiler.elementEnvironment,
1187 helpers, 1204 helpers,
1188 impacts, 1205 impacts,
1189 checkedModeHelpers, 1206 checkedModeHelpers,
1190 nativeData, 1207 nativeData,
1191 rtiNeed, 1208 rtiNeed,
1192 nativeCodegenEnqueuer, 1209 nativeCodegenEnqueuer,
1193 namer, 1210 namer,
1194 mirrorsData,
1195 oneShotInterceptorData, 1211 oneShotInterceptorData,
1196 lookupMapAnalysis, 1212 lookupMapAnalysis,
1197 rtiChecksBuilder); 1213 rtiChecksBuilder);
1198 return const WorldImpact(); 1214 return const WorldImpact();
1199 } 1215 }
1200 1216
1201 /// Called when code generation has been completed. 1217 /// Called when code generation has been completed.
1202 void onCodegenEnd() { 1218 void onCodegenEnd() {
1203 sourceInformationStrategy.onComplete(); 1219 sourceInformationStrategy.onComplete();
1204 tracer.close(); 1220 tracer.close();
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 return _backend.defaultSuperclass(element); 1600 return _backend.defaultSuperclass(element);
1585 } 1601 }
1586 1602
1587 @override 1603 @override
1588 bool isNativeClass(ClassEntity element) => 1604 bool isNativeClass(ClassEntity element) =>
1589 _backend.nativeClassData.isNativeClass(element); 1605 _backend.nativeClassData.isNativeClass(element);
1590 1606
1591 @override 1607 @override
1592 bool isForeign(Element element) => _backend.isForeign(element); 1608 bool isForeign(Element element) => _backend.isForeign(element);
1593 } 1609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698