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

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

Issue 2659883002: Use entities in BackendClasses (Closed)
Patch Set: Updated cf. comments. Created 3 years, 10 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
11 import '../closure.dart'; 11 import '../closure.dart';
12 import '../common.dart'; 12 import '../common.dart';
13 import '../common/backend_api.dart' 13 import '../common/backend_api.dart'
14 show 14 show
15 Backend, 15 Backend,
16 BackendClasses, 16 BackendClasses,
17 ImpactTransformer, 17 ImpactTransformer,
18 ForeignResolver, 18 ForeignResolver,
19 NativeRegistry; 19 NativeRegistry;
20 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; 20 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem;
21 import '../common/names.dart' show Identifiers, Uris; 21 import '../common/names.dart' show Identifiers, Uris;
22 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; 22 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact;
23 import '../common/tasks.dart' show CompilerTask; 23 import '../common/tasks.dart' show CompilerTask;
24 import '../compiler.dart' show Compiler; 24 import '../compiler.dart' show Compiler;
25 import '../constants/constant_system.dart'; 25 import '../constants/constant_system.dart';
26 import '../constants/expressions.dart'; 26 import '../constants/expressions.dart';
27 import '../constants/values.dart'; 27 import '../constants/values.dart';
28 import '../core_types.dart' show CommonElements; 28 import '../core_types.dart' show CommonElements;
29 import '../elements/resolution_types.dart';
30 import '../deferred_load.dart' show DeferredLoadTask; 29 import '../deferred_load.dart' show DeferredLoadTask;
31 import '../dump_info.dart' show DumpInfoTask; 30 import '../dump_info.dart' show DumpInfoTask;
32 import '../elements/elements.dart'; 31 import '../elements/elements.dart';
33 import '../elements/entities.dart'; 32 import '../elements/entities.dart';
33 import '../elements/resolution_types.dart';
34 import '../elements/types.dart';
34 import '../enqueue.dart' 35 import '../enqueue.dart'
35 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; 36 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy;
36 import '../io/position_information.dart' show PositionSourceInformationStrategy; 37 import '../io/position_information.dart' show PositionSourceInformationStrategy;
37 import '../io/source_information.dart' show SourceInformationStrategy; 38 import '../io/source_information.dart' show SourceInformationStrategy;
38 import '../io/start_end_information.dart' 39 import '../io/start_end_information.dart'
39 show StartEndSourceInformationStrategy; 40 show StartEndSourceInformationStrategy;
40 import '../js/js.dart' as jsAst; 41 import '../js/js.dart' as jsAst;
41 import '../js/js.dart' show js; 42 import '../js/js.dart' show js;
42 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; 43 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy;
43 import '../js/rewrite_async.dart'; 44 import '../js/rewrite_async.dart';
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 ClassElement cls = interceptor.cls; 1093 ClassElement cls = interceptor.cls;
1093 computeImpactForInstantiatedConstantType(cls.thisType, impactBuilder); 1094 computeImpactForInstantiatedConstantType(cls.thisType, impactBuilder);
1094 } else if (constant.isType) { 1095 } else if (constant.isType) {
1095 if (isForResolution) { 1096 if (isForResolution) {
1096 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( 1097 impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
1097 // TODO(johnniwinther): Find the right [CallStructure]. 1098 // TODO(johnniwinther): Find the right [CallStructure].
1098 helpers.createRuntimeType, 1099 helpers.createRuntimeType,
1099 null)); 1100 null));
1100 registerBackendUse(helpers.createRuntimeType); 1101 registerBackendUse(helpers.createRuntimeType);
1101 } 1102 }
1102 impactBuilder.registerTypeUse( 1103 impactBuilder
1103 new TypeUse.instantiation(backendClasses.typeImplementation.rawType)); 1104 .registerTypeUse(new TypeUse.instantiation(backendClasses.typeType));
1104 } 1105 }
1105 lookupMapAnalysis.registerConstantKey(constant); 1106 lookupMapAnalysis.registerConstantKey(constant);
1106 } 1107 }
1107 1108
1108 void computeImpactForInstantiatedConstantType( 1109 void computeImpactForInstantiatedConstantType(
1109 ResolutionDartType type, WorldImpactBuilder impactBuilder) { 1110 DartType type, WorldImpactBuilder impactBuilder) {
1110 if (type is ResolutionInterfaceType) { 1111 if (type is ResolutionInterfaceType) {
1111 impactBuilder.registerTypeUse(new TypeUse.instantiation(type)); 1112 impactBuilder.registerTypeUse(new TypeUse.instantiation(type));
1112 if (classNeedsRtiField(type.element)) { 1113 if (classNeedsRtiField(type.element)) {
1113 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( 1114 impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
1114 // TODO(johnniwinther): Find the right [CallStructure]. 1115 // TODO(johnniwinther): Find the right [CallStructure].
1115 helpers.setRuntimeTypeInfo, 1116 helpers.setRuntimeTypeInfo,
1116 null)); 1117 null));
1117 } 1118 }
1118 if (type.element == backendClasses.typeImplementation) { 1119 if (type.element == backendClasses.typeClass) {
1119 // If we use a type literal in a constant, the compile time 1120 // If we use a type literal in a constant, the compile time
1120 // constant emitter will generate a call to the createRuntimeType 1121 // constant emitter will generate a call to the createRuntimeType
1121 // helper so we register a use of that. 1122 // helper so we register a use of that.
1122 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( 1123 impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
1123 // TODO(johnniwinther): Find the right [CallStructure]. 1124 // TODO(johnniwinther): Find the right [CallStructure].
1124 helpers.createRuntimeType, 1125 helpers.createRuntimeType,
1125 null)); 1126 null));
1126 } 1127 }
1127 } 1128 }
1128 } 1129 }
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 resolution.emptyCache(); 3250 resolution.emptyCache();
3250 } 3251 }
3251 } 3252 }
3252 } 3253 }
3253 3254
3254 class JavaScriptBackendClasses implements BackendClasses { 3255 class JavaScriptBackendClasses implements BackendClasses {
3255 final BackendHelpers helpers; 3256 final BackendHelpers helpers;
3256 3257
3257 JavaScriptBackendClasses(this.helpers); 3258 JavaScriptBackendClasses(this.helpers);
3258 3259
3259 ClassElement get intImplementation => helpers.jsIntClass; 3260 ClassElement get intClass => helpers.jsIntClass;
3260 ClassElement get uint32Implementation => helpers.jsUInt32Class; 3261 ClassElement get uint32Class => helpers.jsUInt32Class;
3261 ClassElement get uint31Implementation => helpers.jsUInt31Class; 3262 ClassElement get uint31Class => helpers.jsUInt31Class;
3262 ClassElement get positiveIntImplementation => helpers.jsPositiveIntClass; 3263 ClassElement get positiveIntClass => helpers.jsPositiveIntClass;
3263 ClassElement get doubleImplementation => helpers.jsDoubleClass; 3264 ClassElement get doubleClass => helpers.jsDoubleClass;
3264 ClassElement get numImplementation => helpers.jsNumberClass; 3265 ClassElement get numClass => helpers.jsNumberClass;
3265 ClassElement get stringImplementation => helpers.jsStringClass; 3266 ClassElement get stringClass => helpers.jsStringClass;
3266 ClassElement get listImplementation => helpers.jsArrayClass; 3267 ClassElement get listClass => helpers.jsArrayClass;
3267 ClassElement get mutableListImplementation => helpers.jsMutableArrayClass; 3268 ClassElement get mutableListClass => helpers.jsMutableArrayClass;
3268 ClassElement get constListImplementation => helpers.jsUnmodifiableArrayClass; 3269 ClassElement get constListClass => helpers.jsUnmodifiableArrayClass;
3269 ClassElement get fixedListImplementation => helpers.jsFixedArrayClass; 3270 ClassElement get fixedListClass => helpers.jsFixedArrayClass;
3270 ClassElement get growableListImplementation => helpers.jsExtendableArrayClass; 3271 ClassElement get growableListClass => helpers.jsExtendableArrayClass;
3271 ClassElement get mapImplementation => helpers.mapLiteralClass; 3272 ClassElement get mapClass => helpers.mapLiteralClass;
3272 ClassElement get constMapImplementation => helpers.constMapLiteralClass; 3273 ClassElement get constMapClass => helpers.constMapLiteralClass;
3273 ClassElement get typeImplementation => helpers.typeLiteralClass; 3274 ClassElement get typeClass => helpers.typeLiteralClass;
3274 ClassElement get boolImplementation => helpers.jsBoolClass; 3275 ResolutionInterfaceType get typeType {
3275 ClassElement get nullImplementation => helpers.jsNullClass; 3276 return typeClass.computeType(helpers.backend.compiler.resolution);
3276 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; 3277 }
3277 ClassElement get asyncFutureImplementation => helpers.futureImplementation; 3278
3278 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; 3279 ClassElement get boolClass => helpers.jsBoolClass;
3279 ClassElement get functionImplementation => 3280 ClassElement get nullClass => helpers.jsNullClass;
3280 helpers.commonElements.functionClass; 3281 ClassElement get syncStarIterableClass => helpers.syncStarIterable;
3281 ClassElement get indexableImplementation => helpers.jsIndexableClass; 3282 ClassElement get asyncFutureClass => helpers.futureImplementation;
3282 ClassElement get mutableIndexableImplementation => 3283 ClassElement get asyncStarStreamClass => helpers.controllerStream;
3283 helpers.jsMutableIndexableClass; 3284 ClassElement get functionClass => helpers.commonElements.functionClass;
3284 ClassElement get indexingBehaviorImplementation => 3285 ClassElement get indexableClass => helpers.jsIndexableClass;
3285 helpers.jsIndexingBehaviorInterface; 3286 ClassElement get mutableIndexableClass => helpers.jsMutableIndexableClass;
3286 ClassElement get interceptorImplementation => helpers.jsInterceptorClass; 3287 ClassElement get indexingBehaviorClass => helpers.jsIndexingBehaviorInterface;
3288 ClassElement get interceptorClass => helpers.jsInterceptorClass;
3287 3289
3288 bool isDefaultEqualityImplementation(MemberElement element) { 3290 bool isDefaultEqualityImplementation(MemberElement element) {
3289 assert(element.name == '=='); 3291 assert(element.name == '==');
3290 ClassElement classElement = element.enclosingClass; 3292 ClassElement classElement = element.enclosingClass;
3291 return classElement == helpers.commonElements.objectClass || 3293 return classElement == helpers.commonElements.objectClass ||
3292 classElement == helpers.jsInterceptorClass || 3294 classElement == helpers.jsInterceptorClass ||
3293 classElement == helpers.jsNullClass; 3295 classElement == helpers.jsNullClass;
3294 } 3296 }
3295 3297
3296 @override 3298 @override
3297 bool isInterceptorClass(ClassElement cls) { 3299 bool isInterceptorClass(ClassElement cls) {
3298 return helpers.backend.isInterceptorClass(cls); 3300 return helpers.backend.isInterceptorClass(cls);
3299 } 3301 }
3300 3302
3301 @override 3303 @override
3302 bool isNativeClass(ClassElement element) { 3304 bool isNativeClass(ClassElement element) {
3303 return helpers.backend.isNative(element); 3305 return helpers.backend.isNative(element);
3304 } 3306 }
3305 3307
3306 @override 3308 @override
3307 bool isNativeMember(MemberElement element) { 3309 bool isNativeMember(MemberElement element) {
3308 return helpers.backend.isNative(element); 3310 return helpers.backend.isNative(element);
3309 } 3311 }
3310 } 3312 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/backend_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698