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

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

Issue 2732633002: Remove Enqueuer.nativeEnqueuer (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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 InterceptorData _interceptorData; 437 InterceptorData _interceptorData;
438 OneShotInterceptorData _oneShotInterceptorData; 438 OneShotInterceptorData _oneShotInterceptorData;
439 BackendUsage _backendUsage; 439 BackendUsage _backendUsage;
440 BackendUsageBuilder _backendUsageBuilder; 440 BackendUsageBuilder _backendUsageBuilder;
441 MirrorsData mirrorsData; 441 MirrorsData mirrorsData;
442 CheckedModeHelpers _checkedModeHelpers; 442 CheckedModeHelpers _checkedModeHelpers;
443 443
444 ResolutionEnqueuerListener _resolutionEnqueuerListener; 444 ResolutionEnqueuerListener _resolutionEnqueuerListener;
445 CodegenEnqueuerListener _codegenEnqueuerListener; 445 CodegenEnqueuerListener _codegenEnqueuerListener;
446 446
447 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer;
448 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer;
449
447 BackendHelpers helpers; 450 BackendHelpers helpers;
448 BackendImpacts impacts; 451 BackendImpacts impacts;
449 452
450 /// Common classes used by the backend. 453 /// Common classes used by the backend.
451 BackendClasses backendClasses; 454 BackendClasses backendClasses;
452 455
453 /// Backend access to the front-end. 456 /// Backend access to the front-end.
454 final JSFrontendAccess frontend; 457 final JSFrontendAccess frontend;
455 458
456 Target _target; 459 Target _target;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 impacts = new BackendImpacts(compiler.options, commonElements, helpers); 504 impacts = new BackendImpacts(compiler.options, commonElements, helpers);
502 backendClasses = new JavaScriptBackendClasses( 505 backendClasses = new JavaScriptBackendClasses(
503 compiler.elementEnvironment, helpers, nativeData); 506 compiler.elementEnvironment, helpers, nativeData);
504 mirrorsData = new MirrorsData( 507 mirrorsData = new MirrorsData(
505 compiler, compiler.options, commonElements, helpers, constants); 508 compiler, compiler.options, commonElements, helpers, constants);
506 _backendUsageBuilder = new BackendUsageBuilderImpl( 509 _backendUsageBuilder = new BackendUsageBuilderImpl(
507 compiler.elementEnvironment, commonElements, helpers); 510 compiler.elementEnvironment, commonElements, helpers);
508 _checkedModeHelpers = new CheckedModeHelpers(commonElements, helpers); 511 _checkedModeHelpers = new CheckedModeHelpers(commonElements, helpers);
509 emitter = 512 emitter =
510 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); 513 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter);
514 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer(compiler);
515 _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer(
516 compiler, emitter, _nativeResolutionEnqueuer);
517
511 typeVariableAnalysis = new TypeVariableAnalysis( 518 typeVariableAnalysis = new TypeVariableAnalysis(
512 compiler.elementEnvironment, impacts, backendUsageBuilder); 519 compiler.elementEnvironment, impacts, backendUsageBuilder);
513 typeVariableHandler = new TypeVariableHandler(this, helpers, mirrorsData); 520 typeVariableHandler = new TypeVariableHandler(this, helpers, mirrorsData);
514 customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( 521 customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis(
515 this, 522 this,
516 compiler.resolution, 523 compiler.resolution,
517 commonElements, 524 commonElements,
518 backendClasses, 525 backendClasses,
519 helpers, 526 helpers,
520 nativeData, 527 nativeData,
(...skipping 29 matching lines...) Expand all
550 helpers, 557 helpers,
551 impacts, 558 impacts,
552 nativeData, 559 nativeData,
553 _interceptorDataBuilder, 560 _interceptorDataBuilder,
554 _backendUsageBuilder, 561 _backendUsageBuilder,
555 _rtiNeedBuilder, 562 _rtiNeedBuilder,
556 mirrorsData, 563 mirrorsData,
557 noSuchMethodRegistry, 564 noSuchMethodRegistry,
558 customElementsResolutionAnalysis, 565 customElementsResolutionAnalysis,
559 lookupMapLibraryAccess, 566 lookupMapLibraryAccess,
560 mirrorsAnalysis); 567 mirrorsAnalysis,
568 _nativeResolutionEnqueuer);
561 _codegenEnqueuerListener = new CodegenEnqueuerListener( 569 _codegenEnqueuerListener = new CodegenEnqueuerListener(
562 this, 570 this,
563 compiler.elementEnvironment, 571 compiler.elementEnvironment,
564 commonElements, 572 commonElements,
565 helpers, 573 helpers,
566 impacts, 574 impacts,
567 mirrorsData, 575 mirrorsData,
568 customElementsCodegenAnalysis, 576 customElementsCodegenAnalysis,
569 typeVariableHandler, 577 typeVariableHandler,
570 lookupMapAnalysis, 578 lookupMapAnalysis,
571 mirrorsAnalysis); 579 mirrorsAnalysis,
580 _nativeCodegenEnqueuer);
572 } 581 }
573 582
574 /// The [ConstantSystem] used to interpret compile-time constants for this 583 /// The [ConstantSystem] used to interpret compile-time constants for this
575 /// backend. 584 /// backend.
576 ConstantSystem get constantSystem => constants.constantSystem; 585 ConstantSystem get constantSystem => constants.constantSystem;
577 586
578 DiagnosticReporter get reporter => compiler.reporter; 587 DiagnosticReporter get reporter => compiler.reporter;
579 588
580 CommonElements get commonElements => compiler.commonElements; 589 CommonElements get commonElements => compiler.commonElements;
581 590
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 */ 744 */
736 bool isAliasedSuperMember(FunctionElement member) { 745 bool isAliasedSuperMember(FunctionElement member) {
737 return aliasedSuperMembers.contains(member); 746 return aliasedSuperMembers.contains(member);
738 } 747 }
739 748
740 void resolveNativeElement(MemberElement element, NativeRegistry registry) { 749 void resolveNativeElement(MemberElement element, NativeRegistry registry) {
741 if (element.isFunction || 750 if (element.isFunction ||
742 element.isConstructor || 751 element.isConstructor ||
743 element.isGetter || 752 element.isGetter ||
744 element.isSetter) { 753 element.isSetter) {
745 compiler.enqueuer.resolution.nativeEnqueuer 754 _nativeResolutionEnqueuer.handleMethodAnnotations(element);
746 .handleMethodAnnotations(element);
747 if (nativeData.isNativeMember(element)) { 755 if (nativeData.isNativeMember(element)) {
748 native.NativeBehavior behavior = 756 native.NativeBehavior behavior =
749 native.NativeBehavior.ofMethodElement(element, compiler); 757 native.NativeBehavior.ofMethodElement(element, compiler);
750 nativeDataBuilder.setNativeMethodBehavior(element, behavior); 758 nativeDataBuilder.setNativeMethodBehavior(element, behavior);
751 registry.registerNativeData(behavior); 759 registry.registerNativeData(behavior);
752 } 760 }
753 } else if (element.isField) { 761 } else if (element.isField) {
754 compiler.enqueuer.resolution.nativeEnqueuer 762 _nativeResolutionEnqueuer.handleFieldAnnotations(element);
755 .handleFieldAnnotations(element);
756 if (nativeData.isNativeMember(element)) { 763 if (nativeData.isNativeMember(element)) {
757 native.NativeBehavior fieldLoadBehavior = 764 native.NativeBehavior fieldLoadBehavior =
758 native.NativeBehavior.ofFieldElementLoad(element, compiler); 765 native.NativeBehavior.ofFieldElementLoad(element, compiler);
759 native.NativeBehavior fieldStoreBehavior = 766 native.NativeBehavior fieldStoreBehavior =
760 native.NativeBehavior.ofFieldElementStore(element, compiler); 767 native.NativeBehavior.ofFieldElementStore(element, compiler);
761 nativeDataBuilder.setNativeFieldLoadBehavior( 768 nativeDataBuilder.setNativeFieldLoadBehavior(
762 element, fieldLoadBehavior); 769 element, fieldLoadBehavior);
763 nativeDataBuilder.setNativeFieldStoreBehavior( 770 nativeDataBuilder.setNativeFieldStoreBehavior(
764 element, fieldStoreBehavior); 771 element, fieldStoreBehavior);
765 772
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 926
920 /// Returns the [WorldImpact] of enabling deferred loading. 927 /// Returns the [WorldImpact] of enabling deferred loading.
921 WorldImpact computeDeferredLoadingImpact() { 928 WorldImpact computeDeferredLoadingImpact() {
922 backendUsageBuilder.processBackendImpact(impacts.deferredLoading); 929 backendUsageBuilder.processBackendImpact(impacts.deferredLoading);
923 return impacts.deferredLoading.createImpact(compiler.elementEnvironment); 930 return impacts.deferredLoading.createImpact(compiler.elementEnvironment);
924 } 931 }
925 932
926 /// Called when resolving a call to a foreign function. 933 /// Called when resolving a call to a foreign function.
927 native.NativeBehavior resolveForeignCall(Send node, Element element, 934 native.NativeBehavior resolveForeignCall(Send node, Element element,
928 CallStructure callStructure, ForeignResolver resolver) { 935 CallStructure callStructure, ForeignResolver resolver) {
929 native.NativeResolutionEnqueuer nativeEnqueuer =
930 compiler.enqueuer.resolution.nativeEnqueuer;
931 if (element.name == BackendHelpers.JS) { 936 if (element.name == BackendHelpers.JS) {
932 return nativeEnqueuer.resolveJsCall(node, resolver); 937 return _nativeResolutionEnqueuer.resolveJsCall(node, resolver);
933 } else if (element.name == BackendHelpers.JS_EMBEDDED_GLOBAL) { 938 } else if (element.name == BackendHelpers.JS_EMBEDDED_GLOBAL) {
934 return nativeEnqueuer.resolveJsEmbeddedGlobalCall(node, resolver); 939 return _nativeResolutionEnqueuer.resolveJsEmbeddedGlobalCall(
940 node, resolver);
935 } else if (element.name == BackendHelpers.JS_BUILTIN) { 941 } else if (element.name == BackendHelpers.JS_BUILTIN) {
936 return nativeEnqueuer.resolveJsBuiltinCall(node, resolver); 942 return _nativeResolutionEnqueuer.resolveJsBuiltinCall(node, resolver);
937 } else if (element.name == BackendHelpers.JS_INTERCEPTOR_CONSTANT) { 943 } else if (element.name == BackendHelpers.JS_INTERCEPTOR_CONSTANT) {
938 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names 944 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
939 // a class that will be instantiated outside the program by attaching a 945 // a class that will be instantiated outside the program by attaching a
940 // native class dispatch record referencing the interceptor. 946 // native class dispatch record referencing the interceptor.
941 if (!node.argumentsNode.isEmpty) { 947 if (!node.argumentsNode.isEmpty) {
942 Node argument = node.argumentsNode.nodes.head; 948 Node argument = node.argumentsNode.nodes.head;
943 ConstantExpression constant = resolver.getConstant(argument); 949 ConstantExpression constant = resolver.getConstant(argument);
944 if (constant != null && constant.kind == ConstantExpressionKind.TYPE) { 950 if (constant != null && constant.kind == ConstantExpressionKind.TYPE) {
945 TypeConstantExpression typeConstant = constant; 951 TypeConstantExpression typeConstant = constant;
946 if (typeConstant.type is ResolutionInterfaceType) { 952 if (typeConstant.type is ResolutionInterfaceType) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 function = function.withSourceInformation( 1039 function = function.withSourceInformation(
1034 sourceInformationStrategy.buildSourceMappedMarker()); 1040 sourceInformationStrategy.buildSourceMappedMarker());
1035 } 1041 }
1036 generatedCode[element] = function; 1042 generatedCode[element] = function;
1037 WorldImpact worldImpact = 1043 WorldImpact worldImpact =
1038 impactTransformer.transformCodegenImpact(work.registry.worldImpact); 1044 impactTransformer.transformCodegenImpact(work.registry.worldImpact);
1039 compiler.dumpInfoTask.registerImpact(element, worldImpact); 1045 compiler.dumpInfoTask.registerImpact(element, worldImpact);
1040 return worldImpact; 1046 return worldImpact;
1041 } 1047 }
1042 1048
1043 native.NativeEnqueuer nativeResolutionEnqueuer() { 1049 native.NativeEnqueuer get nativeResolutionEnqueuer =>
1044 return new native.NativeResolutionEnqueuer(compiler); 1050 _nativeResolutionEnqueuer;
1045 }
1046 1051
1047 native.NativeEnqueuer nativeCodegenEnqueuer() { 1052 native.NativeEnqueuer get nativeCodegenEnqueuer => _nativeCodegenEnqueuer;
1048 return new native.NativeCodegenEnqueuer(compiler, emitter);
1049 }
1050 1053
1051 ClassElement defaultSuperclass(ClassElement element) { 1054 ClassElement defaultSuperclass(ClassElement element) {
1052 if (nativeData.isJsInterop(element)) { 1055 if (nativeData.isJsInterop(element)) {
1053 return helpers.jsJavaScriptObjectClass; 1056 return helpers.jsJavaScriptObjectClass;
1054 } 1057 }
1055 // Native classes inherit from Interceptor. 1058 // Native classes inherit from Interceptor.
1056 return nativeData.isNativeClass(element) 1059 return nativeData.isNativeClass(element)
1057 ? helpers.jsInterceptorClass 1060 ? helpers.jsInterceptorClass
1058 : commonElements.objectClass; 1061 : commonElements.objectClass;
1059 } 1062 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 return _backend.defaultSuperclass(element); 1654 return _backend.defaultSuperclass(element);
1652 } 1655 }
1653 1656
1654 @override 1657 @override
1655 bool isNativeClass(ClassEntity element) => 1658 bool isNativeClass(ClassEntity element) =>
1656 _backend.nativeData.isNativeClass(element); 1659 _backend.nativeData.isNativeClass(element);
1657 1660
1658 @override 1661 @override
1659 bool isForeign(Element element) => _backend.isForeign(element); 1662 bool isForeign(Element element) => _backend.isForeign(element);
1660 } 1663 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698