| 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 library js_backend.backend.impact_transformer; | 5 library js_backend.backend.impact_transformer; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common_elements.dart'; | 8 import '../common_elements.dart'; |
| 9 import '../common/backend_api.dart' show ImpactTransformer; | 9 import '../common/backend_api.dart' show ImpactTransformer; |
| 10 import '../common/codegen.dart' show CodegenImpact; | 10 import '../common/codegen.dart' show CodegenImpact; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 class JavaScriptImpactTransformer extends ImpactTransformer { | 38 class JavaScriptImpactTransformer extends ImpactTransformer { |
| 39 final CompilerOptions _options; | 39 final CompilerOptions _options; |
| 40 final Resolution _resolution; | 40 final Resolution _resolution; |
| 41 final ElementEnvironment _elementEnvironment; | 41 final ElementEnvironment _elementEnvironment; |
| 42 final CommonElements _commonElements; | 42 final CommonElements _commonElements; |
| 43 final BackendImpacts _impacts; | 43 final BackendImpacts _impacts; |
| 44 final NativeClassData _nativeClassData; | 44 final NativeClassData _nativeClassData; |
| 45 final NativeResolutionEnqueuer _nativeResolutionEnqueuer; | 45 final NativeResolutionEnqueuer _nativeResolutionEnqueuer; |
| 46 final BackendUsageBuilder _backendUsageBuider; | 46 final BackendUsageBuilder _backendUsageBuider; |
| 47 final MirrorsData _mirrorsData; | 47 final MirrorsDataBuilder _mirrorsDataBuilder; |
| 48 final CustomElementsResolutionAnalysis _customElementsResolutionAnalysis; | 48 final CustomElementsResolutionAnalysis _customElementsResolutionAnalysis; |
| 49 final RuntimeTypesNeedBuilder _rtiNeedBuilder; | 49 final RuntimeTypesNeedBuilder _rtiNeedBuilder; |
| 50 | 50 |
| 51 JavaScriptImpactTransformer( | 51 JavaScriptImpactTransformer( |
| 52 this._options, | 52 this._options, |
| 53 this._resolution, | 53 this._resolution, |
| 54 this._elementEnvironment, | 54 this._elementEnvironment, |
| 55 this._commonElements, | 55 this._commonElements, |
| 56 this._impacts, | 56 this._impacts, |
| 57 this._nativeClassData, | 57 this._nativeClassData, |
| 58 this._nativeResolutionEnqueuer, | 58 this._nativeResolutionEnqueuer, |
| 59 this._backendUsageBuider, | 59 this._backendUsageBuider, |
| 60 this._mirrorsData, | 60 this._mirrorsDataBuilder, |
| 61 this._customElementsResolutionAnalysis, | 61 this._customElementsResolutionAnalysis, |
| 62 this._rtiNeedBuilder); | 62 this._rtiNeedBuilder); |
| 63 | 63 |
| 64 @override | 64 @override |
| 65 WorldImpact transformResolutionImpact( | 65 WorldImpact transformResolutionImpact( |
| 66 ResolutionEnqueuer enqueuer, ResolutionImpact worldImpact) { | 66 ResolutionEnqueuer enqueuer, ResolutionImpact worldImpact) { |
| 67 TransformedWorldImpact transformed = | 67 TransformedWorldImpact transformed = |
| 68 new TransformedWorldImpact(worldImpact); | 68 new TransformedWorldImpact(worldImpact); |
| 69 | 69 |
| 70 void registerImpact(BackendImpact impact) { | 70 void registerImpact(BackendImpact impact) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // factory constructors are registered directly. | 219 // factory constructors are registered directly. |
| 220 transformed | 220 transformed |
| 221 .registerTypeUse(new TypeUse.instantiation(listLiteralUse.type)); | 221 .registerTypeUse(new TypeUse.instantiation(listLiteralUse.type)); |
| 222 ResolutionInterfaceType type = listLiteralUse.type; | 222 ResolutionInterfaceType type = listLiteralUse.type; |
| 223 registerRequiredType(type); | 223 registerRequiredType(type); |
| 224 } | 224 } |
| 225 | 225 |
| 226 if (worldImpact.constSymbolNames.isNotEmpty) { | 226 if (worldImpact.constSymbolNames.isNotEmpty) { |
| 227 registerImpact(_impacts.constSymbol); | 227 registerImpact(_impacts.constSymbol); |
| 228 for (String constSymbolName in worldImpact.constSymbolNames) { | 228 for (String constSymbolName in worldImpact.constSymbolNames) { |
| 229 _mirrorsData.registerConstSymbol(constSymbolName); | 229 _mirrorsDataBuilder.registerConstSymbol(constSymbolName); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 for (StaticUse staticUse in worldImpact.staticUses) { | 233 for (StaticUse staticUse in worldImpact.staticUses) { |
| 234 switch (staticUse.kind) { | 234 switch (staticUse.kind) { |
| 235 case StaticUseKind.CLOSURE: | 235 case StaticUseKind.CLOSURE: |
| 236 registerImpact(_impacts.closure); | 236 registerImpact(_impacts.closure); |
| 237 LocalFunctionElement closure = staticUse.element; | 237 LocalFunctionElement closure = staticUse.element; |
| 238 if (closure.type.containsTypeVariables) { | 238 if (closure.type.containsTypeVariables) { |
| 239 registerImpact(_impacts.computeSignature); | 239 registerImpact(_impacts.computeSignature); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 final CompilerOptions _options; | 337 final CompilerOptions _options; |
| 338 final ElementEnvironment _elementEnvironment; | 338 final ElementEnvironment _elementEnvironment; |
| 339 final BackendHelpers _helpers; | 339 final BackendHelpers _helpers; |
| 340 final BackendImpacts _impacts; | 340 final BackendImpacts _impacts; |
| 341 final CheckedModeHelpers _checkedModeHelpers; | 341 final CheckedModeHelpers _checkedModeHelpers; |
| 342 final NativeData _nativeData; | 342 final NativeData _nativeData; |
| 343 final BackendUsage _backendUsage; | 343 final BackendUsage _backendUsage; |
| 344 final RuntimeTypesNeed _rtiNeed; | 344 final RuntimeTypesNeed _rtiNeed; |
| 345 final NativeCodegenEnqueuer _nativeCodegenEnqueuer; | 345 final NativeCodegenEnqueuer _nativeCodegenEnqueuer; |
| 346 final Namer _namer; | 346 final Namer _namer; |
| 347 final MirrorsData _mirrorsData; | |
| 348 final OneShotInterceptorData _oneShotInterceptorData; | 347 final OneShotInterceptorData _oneShotInterceptorData; |
| 349 final LookupMapAnalysis _lookupMapAnalysis; | 348 final LookupMapAnalysis _lookupMapAnalysis; |
| 350 final RuntimeTypesChecksBuilder _rtiChecksBuilder; | 349 final RuntimeTypesChecksBuilder _rtiChecksBuilder; |
| 351 | 350 |
| 352 CodegenImpactTransformer( | 351 CodegenImpactTransformer( |
| 353 this._options, | 352 this._options, |
| 354 this._elementEnvironment, | 353 this._elementEnvironment, |
| 355 this._helpers, | 354 this._helpers, |
| 356 this._impacts, | 355 this._impacts, |
| 357 this._checkedModeHelpers, | 356 this._checkedModeHelpers, |
| 358 this._nativeData, | 357 this._nativeData, |
| 359 this._backendUsage, | 358 this._backendUsage, |
| 360 this._rtiNeed, | 359 this._rtiNeed, |
| 361 this._nativeCodegenEnqueuer, | 360 this._nativeCodegenEnqueuer, |
| 362 this._namer, | 361 this._namer, |
| 363 this._mirrorsData, | |
| 364 this._oneShotInterceptorData, | 362 this._oneShotInterceptorData, |
| 365 this._lookupMapAnalysis, | 363 this._lookupMapAnalysis, |
| 366 this._rtiChecksBuilder); | 364 this._rtiChecksBuilder); |
| 367 | 365 |
| 368 void onIsCheckForCodegen( | 366 void onIsCheckForCodegen( |
| 369 ResolutionDartType type, TransformedWorldImpact transformed) { | 367 ResolutionDartType type, TransformedWorldImpact transformed) { |
| 370 if (type.isDynamic) return; | 368 if (type.isDynamic) return; |
| 371 type = type.unaliased; | 369 type = type.unaliased; |
| 372 _impacts.typeCheck.registerImpact(transformed, _elementEnvironment); | 370 _impacts.typeCheck.registerImpact(transformed, _elementEnvironment); |
| 373 | 371 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 435 } |
| 438 break; | 436 break; |
| 439 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 437 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 440 case StaticUseKind.CONSTRUCTOR_INVOKE: | 438 case StaticUseKind.CONSTRUCTOR_INVOKE: |
| 441 _lookupMapAnalysis.registerInstantiatedType(staticUse.type); | 439 _lookupMapAnalysis.registerInstantiatedType(staticUse.type); |
| 442 break; | 440 break; |
| 443 default: | 441 default: |
| 444 } | 442 } |
| 445 } | 443 } |
| 446 | 444 |
| 447 for (String name in impact.constSymbols) { | |
| 448 _mirrorsData.registerConstSymbol(name); | |
| 449 } | |
| 450 | |
| 451 for (Set<ClassElement> classes in impact.specializedGetInterceptors) { | 445 for (Set<ClassElement> classes in impact.specializedGetInterceptors) { |
| 452 _oneShotInterceptorData.registerSpecializedGetInterceptor( | 446 _oneShotInterceptorData.registerSpecializedGetInterceptor( |
| 453 classes, _namer); | 447 classes, _namer); |
| 454 } | 448 } |
| 455 | 449 |
| 456 if (impact.usesInterceptor) { | 450 if (impact.usesInterceptor) { |
| 457 if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) { | 451 if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) { |
| 458 _impacts.interceptorUse | 452 _impacts.interceptorUse |
| 459 .registerImpact(transformed, _elementEnvironment); | 453 .registerImpact(transformed, _elementEnvironment); |
| 460 // TODO(johnniwinther): Avoid these workarounds. | 454 // TODO(johnniwinther): Avoid these workarounds. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 476 _impacts.asyncStarBody | 470 _impacts.asyncStarBody |
| 477 .registerImpact(transformed, _elementEnvironment); | 471 .registerImpact(transformed, _elementEnvironment); |
| 478 break; | 472 break; |
| 479 } | 473 } |
| 480 } | 474 } |
| 481 | 475 |
| 482 // TODO(johnniwinther): Remove eager registration. | 476 // TODO(johnniwinther): Remove eager registration. |
| 483 return transformed; | 477 return transformed; |
| 484 } | 478 } |
| 485 } | 479 } |
| OLD | NEW |