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

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

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 }); 636 });
637 } 637 }
638 638
639 bool isForeign(Element element) => element.library == helpers.foreignLibrary; 639 bool isForeign(Element element) => element.library == helpers.foreignLibrary;
640 640
641 bool isBackendLibrary(LibraryElement library) { 641 bool isBackendLibrary(LibraryElement library) {
642 return library == helpers.interceptorsLibrary || 642 return library == helpers.interceptorsLibrary ||
643 library == helpers.jsHelperLibrary; 643 library == helpers.jsHelperLibrary;
644 } 644 }
645 645
646 Namer determineNamer(ClosedWorld closedWorld) { 646 Namer determineNamer(
647 ClosedWorld closedWorld, CodegenWorldBuilder codegenWorldBuilder) {
647 return compiler.options.enableMinification 648 return compiler.options.enableMinification
648 ? compiler.options.useFrequencyNamer 649 ? compiler.options.useFrequencyNamer
649 ? new FrequencyBasedNamer(this, closedWorld) 650 ? new FrequencyBasedNamer(this, closedWorld, codegenWorldBuilder)
650 : new MinifyNamer(this, closedWorld) 651 : new MinifyNamer(this, closedWorld, codegenWorldBuilder)
651 : new Namer(this, closedWorld); 652 : new Namer(this, closedWorld, codegenWorldBuilder);
652 } 653 }
653 654
654 /// The backend must *always* call this method when enqueuing an 655 /// The backend must *always* call this method when enqueuing an
655 /// element. Calls done by the backend are not seen by global 656 /// element. Calls done by the backend are not seen by global
656 /// optimizations, so they would make these optimizations unsound. 657 /// optimizations, so they would make these optimizations unsound.
657 /// Therefore we need to collect the list of helpers the backend may 658 /// Therefore we need to collect the list of helpers the backend may
658 /// use. 659 /// use.
659 // TODO(johnniwinther): Replace this with a more precise modelling; type 660 // TODO(johnniwinther): Replace this with a more precise modelling; type
660 // inference of these elements is disabled. 661 // inference of these elements is disabled.
661 Element registerBackendUse(Element element) { 662 Element registerBackendUse(Element element) {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 ResolutionDartType type = constant.getType(compiler.commonElements); 1075 ResolutionDartType type = constant.getType(compiler.commonElements);
1075 computeImpactForInstantiatedConstantType(type, impactBuilder); 1076 computeImpactForInstantiatedConstantType(type, impactBuilder);
1076 1077
1077 if (constant.isFunction) { 1078 if (constant.isFunction) {
1078 FunctionConstantValue function = constant; 1079 FunctionConstantValue function = constant;
1079 impactBuilder 1080 impactBuilder
1080 .registerStaticUse(new StaticUse.staticTearOff(function.element)); 1081 .registerStaticUse(new StaticUse.staticTearOff(function.element));
1081 } else if (constant.isInterceptor) { 1082 } else if (constant.isInterceptor) {
1082 // An interceptor constant references the class's prototype chain. 1083 // An interceptor constant references the class's prototype chain.
1083 InterceptorConstantValue interceptor = constant; 1084 InterceptorConstantValue interceptor = constant;
1084 computeImpactForInstantiatedConstantType( 1085 ClassElement cls = interceptor.cls;
1085 interceptor.dispatchedType, impactBuilder); 1086 computeImpactForInstantiatedConstantType(cls.thisType, impactBuilder);
1086 } else if (constant.isType) { 1087 } else if (constant.isType) {
1087 if (isForResolution) { 1088 if (isForResolution) {
1088 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( 1089 impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
1089 // TODO(johnniwinther): Find the right [CallStructure]. 1090 // TODO(johnniwinther): Find the right [CallStructure].
1090 helpers.createRuntimeType, 1091 helpers.createRuntimeType,
1091 null)); 1092 null));
1092 registerBackendUse(helpers.createRuntimeType); 1093 registerBackendUse(helpers.createRuntimeType);
1093 } 1094 }
1094 impactBuilder.registerTypeUse( 1095 impactBuilder.registerTypeUse(
1095 new TypeUse.instantiation(backendClasses.typeImplementation.rawType)); 1096 new TypeUse.instantiation(backendClasses.typeImplementation.rawType));
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 message: "ClosedWorld has not be set yet.")); 2387 message: "ClosedWorld has not be set yet."));
2387 return _closedWorldCache; 2388 return _closedWorldCache;
2388 } 2389 }
2389 2390
2390 void set _closedWorld(ClosedWorld value) { 2391 void set _closedWorld(ClosedWorld value) {
2391 _closedWorldCache = value; 2392 _closedWorldCache = value;
2392 } 2393 }
2393 2394
2394 WorldImpact onCodegenStart(ClosedWorld closedWorld) { 2395 WorldImpact onCodegenStart(ClosedWorld closedWorld) {
2395 _closedWorld = closedWorld; 2396 _closedWorld = closedWorld;
2396 _namer = determineNamer(_closedWorld); 2397 _namer = determineNamer(_closedWorld, compiler.codegenWorld);
2397 tracer = new Tracer(_closedWorld, namer, compiler.outputProvider); 2398 tracer = new Tracer(_closedWorld, namer, compiler.outputProvider);
2398 emitter.createEmitter(_namer, _closedWorld); 2399 emitter.createEmitter(_namer, _closedWorld);
2399 lookupMapAnalysis.onCodegenStart(); 2400 lookupMapAnalysis.onCodegenStart();
2400 if (hasIsolateSupport) { 2401 if (hasIsolateSupport) {
2401 return enableIsolateSupport(forResolution: false); 2402 return enableIsolateSupport(forResolution: false);
2402 } 2403 }
2403 return const WorldImpact(); 2404 return const WorldImpact();
2404 } 2405 }
2405 2406
2406 void onCodegenEnd() { 2407 void onCodegenEnd() {
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
3276 @override 3277 @override
3277 bool isNativeClass(ClassElement element) { 3278 bool isNativeClass(ClassElement element) {
3278 return helpers.backend.isNative(element); 3279 return helpers.backend.isNative(element);
3279 } 3280 }
3280 3281
3281 @override 3282 @override
3282 bool isNativeMember(MemberElement element) { 3283 bool isNativeMember(MemberElement element) {
3283 return helpers.backend.isNative(element); 3284 return helpers.backend.isNative(element);
3284 } 3285 }
3285 } 3286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698