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

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

Issue 2814453005: Merge CommonElements and BackendHelpers! (Closed)
Patch Set: merge with head Created 3 years, 8 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;
11 import '../common/resolution.dart' show Resolution, ResolutionImpact; 11 import '../common/resolution.dart' show Resolution, ResolutionImpact;
12 import '../constants/expressions.dart'; 12 import '../constants/expressions.dart';
13 import '../common_elements.dart' show ElementEnvironment; 13 import '../common_elements.dart' show ElementEnvironment;
14 import '../elements/elements.dart'; 14 import '../elements/elements.dart';
15 import '../elements/entities.dart'; 15 import '../elements/entities.dart';
16 import '../elements/resolution_types.dart'; 16 import '../elements/resolution_types.dart';
17 import '../enqueue.dart' show ResolutionEnqueuer; 17 import '../enqueue.dart' show ResolutionEnqueuer;
18 import '../native/enqueue.dart'; 18 import '../native/enqueue.dart';
19 import '../native/native.dart' as native; 19 import '../native/native.dart' as native;
20 import '../options.dart'; 20 import '../options.dart';
21 import '../universe/feature.dart'; 21 import '../universe/feature.dart';
22 import '../universe/use.dart' 22 import '../universe/use.dart'
23 show StaticUse, StaticUseKind, TypeUse, TypeUseKind; 23 show StaticUse, StaticUseKind, TypeUse, TypeUseKind;
24 import '../universe/world_impact.dart' show TransformedWorldImpact, WorldImpact; 24 import '../universe/world_impact.dart' show TransformedWorldImpact, WorldImpact;
25 import '../util/util.dart'; 25 import '../util/util.dart';
26 import 'backend.dart'; 26 import 'backend.dart';
27 import 'backend_helpers.dart';
28 import 'backend_impact.dart'; 27 import 'backend_impact.dart';
29 import 'backend_usage.dart'; 28 import 'backend_usage.dart';
30 import 'checked_mode_helpers.dart'; 29 import 'checked_mode_helpers.dart';
31 import 'custom_elements_analysis.dart'; 30 import 'custom_elements_analysis.dart';
32 import 'interceptor_data.dart'; 31 import 'interceptor_data.dart';
33 import 'lookup_map_analysis.dart'; 32 import 'lookup_map_analysis.dart';
34 import 'mirrors_data.dart'; 33 import 'mirrors_data.dart';
35 import 'namer.dart'; 34 import 'namer.dart';
36 import 'native_data.dart'; 35 import 'native_data.dart';
37 36
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (type is ResolutionInterfaceType && 328 if (type is ResolutionInterfaceType &&
330 _nativeBasicData.isNativeClass(type.element)) { 329 _nativeBasicData.isNativeClass(type.element)) {
331 registerImpact(_impacts.nativeTypeCheck); 330 registerImpact(_impacts.nativeTypeCheck);
332 } 331 }
333 } 332 }
334 } 333 }
335 334
336 class CodegenImpactTransformer { 335 class CodegenImpactTransformer {
337 final CompilerOptions _options; 336 final CompilerOptions _options;
338 final ElementEnvironment _elementEnvironment; 337 final ElementEnvironment _elementEnvironment;
339 final BackendHelpers _helpers; 338 final CommonElements _commonElements;
340 final BackendImpacts _impacts; 339 final BackendImpacts _impacts;
341 final CheckedModeHelpers _checkedModeHelpers; 340 final CheckedModeHelpers _checkedModeHelpers;
342 final NativeData _nativeData; 341 final NativeData _nativeData;
343 final BackendUsage _backendUsage; 342 final BackendUsage _backendUsage;
344 final RuntimeTypesNeed _rtiNeed; 343 final RuntimeTypesNeed _rtiNeed;
345 final NativeCodegenEnqueuer _nativeCodegenEnqueuer; 344 final NativeCodegenEnqueuer _nativeCodegenEnqueuer;
346 final Namer _namer; 345 final Namer _namer;
347 final OneShotInterceptorData _oneShotInterceptorData; 346 final OneShotInterceptorData _oneShotInterceptorData;
348 final LookupMapAnalysis _lookupMapAnalysis; 347 final LookupMapAnalysis _lookupMapAnalysis;
349 final RuntimeTypesChecksBuilder _rtiChecksBuilder; 348 final RuntimeTypesChecksBuilder _rtiChecksBuilder;
350 349
351 CodegenImpactTransformer( 350 CodegenImpactTransformer(
352 this._options, 351 this._options,
353 this._elementEnvironment, 352 this._elementEnvironment,
354 this._helpers, 353 this._commonElements,
355 this._impacts, 354 this._impacts,
356 this._checkedModeHelpers, 355 this._checkedModeHelpers,
357 this._nativeData, 356 this._nativeData,
358 this._backendUsage, 357 this._backendUsage,
359 this._rtiNeed, 358 this._rtiNeed,
360 this._nativeCodegenEnqueuer, 359 this._nativeCodegenEnqueuer,
361 this._namer, 360 this._namer,
362 this._oneShotInterceptorData, 361 this._oneShotInterceptorData,
363 this._lookupMapAnalysis, 362 this._lookupMapAnalysis,
364 this._rtiChecksBuilder); 363 this._rtiChecksBuilder);
365 364
366 void onIsCheckForCodegen( 365 void onIsCheckForCodegen(
367 ResolutionDartType type, TransformedWorldImpact transformed) { 366 ResolutionDartType type, TransformedWorldImpact transformed) {
368 if (type.isDynamic) return; 367 if (type.isDynamic) return;
369 type = type.unaliased; 368 type = type.unaliased;
370 _impacts.typeCheck.registerImpact(transformed, _elementEnvironment); 369 _impacts.typeCheck.registerImpact(transformed, _elementEnvironment);
371 370
372 bool inCheckedMode = _options.enableTypeAssertions; 371 bool inCheckedMode = _options.enableTypeAssertions;
373 // [registerIsCheck] is also called for checked mode checks, so we 372 // [registerIsCheck] is also called for checked mode checks, so we
374 // need to register checked mode helpers. 373 // need to register checked mode helpers.
375 if (inCheckedMode) { 374 if (inCheckedMode) {
376 // All helpers are added to resolution queue in enqueueHelpers. These 375 // All helpers are added to resolution queue in enqueueHelpers. These
377 // calls to [enqueue] with the resolution enqueuer serve as assertions 376 // calls to [enqueue] with the resolution enqueuer serve as assertions
378 // that the helper was in fact added. 377 // that the helper was in fact added.
379 // TODO(13155): Find a way to enqueue helpers lazily. 378 // TODO(13155): Find a way to enqueue helpers lazily.
380 CheckedModeHelper helper = 379 CheckedModeHelper helper =
381 _checkedModeHelpers.getCheckedModeHelper(type, typeCast: false); 380 _checkedModeHelpers.getCheckedModeHelper(type, typeCast: false);
382 if (helper != null) { 381 if (helper != null) {
383 StaticUse staticUse = helper.getStaticUse(_helpers); 382 StaticUse staticUse = helper.getStaticUse(_commonElements);
384 transformed.registerStaticUse(staticUse); 383 transformed.registerStaticUse(staticUse);
385 } 384 }
386 // We also need the native variant of the check (for DOM types). 385 // We also need the native variant of the check (for DOM types).
387 helper = 386 helper =
388 _checkedModeHelpers.getNativeCheckedModeHelper(type, typeCast: false); 387 _checkedModeHelpers.getNativeCheckedModeHelper(type, typeCast: false);
389 if (helper != null) { 388 if (helper != null) {
390 StaticUse staticUse = helper.getStaticUse(_helpers); 389 StaticUse staticUse = helper.getStaticUse(_commonElements);
391 transformed.registerStaticUse(staticUse); 390 transformed.registerStaticUse(staticUse);
392 } 391 }
393 } 392 }
394 if (!type.treatAsRaw || type.containsTypeVariables) { 393 if (!type.treatAsRaw || type.containsTypeVariables) {
395 _impacts.genericIsCheck.registerImpact(transformed, _elementEnvironment); 394 _impacts.genericIsCheck.registerImpact(transformed, _elementEnvironment);
396 } 395 }
397 if (type is ResolutionInterfaceType && 396 if (type is ResolutionInterfaceType &&
398 _nativeData.isNativeClass(type.element)) { 397 _nativeData.isNativeClass(type.element)) {
399 // We will neeed to add the "$is" and "$as" properties on the 398 // We will neeed to add the "$is" and "$as" properties on the
400 // JavaScript object prototype, so we make sure 399 // JavaScript object prototype, so we make sure
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 _impacts.asyncStarBody 469 _impacts.asyncStarBody
471 .registerImpact(transformed, _elementEnvironment); 470 .registerImpact(transformed, _elementEnvironment);
472 break; 471 break;
473 } 472 }
474 } 473 }
475 474
476 // TODO(johnniwinther): Remove eager registration. 475 // TODO(johnniwinther): Remove eager registration.
477 return transformed; 476 return transformed;
478 } 477 }
479 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698