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

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

Issue 2750503003: Register type constants through ConstantUse (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) 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RuntimeTypesNeed _rtiNeed; 343 final RuntimeTypesNeed _rtiNeed;
344 final NativeCodegenEnqueuer _nativeCodegenEnqueuer; 344 final NativeCodegenEnqueuer _nativeCodegenEnqueuer;
345 final Namer _namer; 345 final Namer _namer;
346 final MirrorsData _mirrorsData; 346 final MirrorsData _mirrorsData;
347 final OneShotInterceptorData _oneShotInterceptorData; 347 final OneShotInterceptorData _oneShotInterceptorData;
348 final LookupMapAnalysis _lookupMapAnalysis; 348 final LookupMapAnalysis _lookupMapAnalysis;
349 final CustomElementsCodegenAnalysis _customElementsCodegenAnalysis;
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._rtiNeed, 358 this._rtiNeed,
360 this._nativeCodegenEnqueuer, 359 this._nativeCodegenEnqueuer,
361 this._namer, 360 this._namer,
362 this._mirrorsData, 361 this._mirrorsData,
363 this._oneShotInterceptorData, 362 this._oneShotInterceptorData,
364 this._lookupMapAnalysis, 363 this._lookupMapAnalysis,
365 this._customElementsCodegenAnalysis,
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
374 bool inCheckedMode = _options.enableTypeAssertions; 372 bool inCheckedMode = _options.enableTypeAssertions;
375 // [registerIsCheck] is also called for checked mode checks, so we 373 // [registerIsCheck] is also called for checked mode checks, so we
(...skipping 22 matching lines...) Expand all
398 } 396 }
399 if (type is ResolutionInterfaceType && 397 if (type is ResolutionInterfaceType &&
400 _nativeData.isNativeClass(type.element)) { 398 _nativeData.isNativeClass(type.element)) {
401 // We will neeed to add the "$is" and "$as" properties on the 399 // We will neeed to add the "$is" and "$as" properties on the
402 // JavaScript object prototype, so we make sure 400 // JavaScript object prototype, so we make sure
403 // [:defineProperty:] is compiled. 401 // [:defineProperty:] is compiled.
404 _impacts.nativeTypeCheck.registerImpact(transformed, _elementEnvironment); 402 _impacts.nativeTypeCheck.registerImpact(transformed, _elementEnvironment);
405 } 403 }
406 } 404 }
407 405
408 @override
409 WorldImpact transformCodegenImpact(CodegenImpact impact) { 406 WorldImpact transformCodegenImpact(CodegenImpact impact) {
410 TransformedWorldImpact transformed = new TransformedWorldImpact(impact); 407 TransformedWorldImpact transformed = new TransformedWorldImpact(impact);
411 408
412 for (TypeUse typeUse in impact.typeUses) { 409 for (TypeUse typeUse in impact.typeUses) {
413 ResolutionDartType type = typeUse.type; 410 ResolutionDartType type = typeUse.type;
414 switch (typeUse.kind) { 411 switch (typeUse.kind) {
415 case TypeUseKind.INSTANTIATION: 412 case TypeUseKind.INSTANTIATION:
416 _lookupMapAnalysis.registerInstantiatedType(type); 413 _lookupMapAnalysis.registerInstantiatedType(type);
417 break; 414 break;
418 case TypeUseKind.IS_CHECK: 415 case TypeUseKind.IS_CHECK:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 classes, _namer); 451 classes, _namer);
455 } 452 }
456 453
457 if (impact.usesInterceptor) { 454 if (impact.usesInterceptor) {
458 if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) { 455 if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) {
459 _impacts.interceptorUse 456 _impacts.interceptorUse
460 .registerImpact(transformed, _elementEnvironment); 457 .registerImpact(transformed, _elementEnvironment);
461 } 458 }
462 } 459 }
463 460
464 for (ClassElement element in impact.typeConstants) {
465 _customElementsCodegenAnalysis.registerTypeConstant(element);
466 _lookupMapAnalysis.registerTypeConstant(element);
467 }
468
469 for (FunctionElement element in impact.asyncMarkers) { 461 for (FunctionElement element in impact.asyncMarkers) {
470 switch (element.asyncMarker) { 462 switch (element.asyncMarker) {
471 case AsyncMarker.ASYNC: 463 case AsyncMarker.ASYNC:
472 _impacts.asyncBody.registerImpact(transformed, _elementEnvironment); 464 _impacts.asyncBody.registerImpact(transformed, _elementEnvironment);
473 break; 465 break;
474 case AsyncMarker.SYNC_STAR: 466 case AsyncMarker.SYNC_STAR:
475 _impacts.syncStarBody 467 _impacts.syncStarBody
476 .registerImpact(transformed, _elementEnvironment); 468 .registerImpact(transformed, _elementEnvironment);
477 break; 469 break;
478 case AsyncMarker.ASYNC_STAR: 470 case AsyncMarker.ASYNC_STAR:
479 _impacts.asyncStarBody 471 _impacts.asyncStarBody
480 .registerImpact(transformed, _elementEnvironment); 472 .registerImpact(transformed, _elementEnvironment);
481 break; 473 break;
482 } 474 }
483 } 475 }
484 476
485 // TODO(johnniwinther): Remove eager registration. 477 // TODO(johnniwinther): Remove eager registration.
486 return transformed; 478 return transformed;
487 } 479 }
488 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698