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

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

Issue 2732663002: Late creation of CodegenEnqueuer (Closed)
Patch Set: Remove eager creation 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) 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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 reporter.reportErrorMessage( 959 reporter.reportErrorMessage(
960 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); 960 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
961 } 961 }
962 // No native behavior for this call. 962 // No native behavior for this call.
963 return null; 963 return null;
964 } 964 }
965 965
966 bool isComplexNoSuchMethod(FunctionElement element) => 966 bool isComplexNoSuchMethod(FunctionElement element) =>
967 noSuchMethodRegistry.isComplex(element); 967 noSuchMethodRegistry.isComplex(element);
968 968
969 CodegenEnqueuer get codegenEnqueuer => compiler.enqueuer.codegen;
970
971 /// Creates an [Enqueuer] for code generation specific to this backend. 969 /// Creates an [Enqueuer] for code generation specific to this backend.
972 CodegenEnqueuer createCodegenEnqueuer(CompilerTask task, Compiler compiler) { 970 CodegenEnqueuer createCodegenEnqueuer(CompilerTask task, Compiler compiler) {
973 return new CodegenEnqueuer( 971 return new CodegenEnqueuer(
974 task, this, compiler.options, const TreeShakingEnqueuerStrategy()); 972 task, this, compiler.options, const TreeShakingEnqueuerStrategy());
975 } 973 }
976 974
977 WorldImpact codegen(CodegenWorkItem work) { 975 WorldImpact codegen(CodegenWorkItem work) {
978 Element element = work.element; 976 Element element = work.element;
979 if (compiler.elementHasCompileTimeError(element)) { 977 if (compiler.elementHasCompileTimeError(element)) {
980 DiagnosticMessage message = 978 DiagnosticMessage message =
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 element == commonElements.numClass || 1122 element == commonElements.numClass ||
1125 element == commonElements.intClass || 1123 element == commonElements.intClass ||
1126 element == commonElements.doubleClass || 1124 element == commonElements.doubleClass ||
1127 element == helpers.jsArrayClass || 1125 element == helpers.jsArrayClass ||
1128 element == helpers.jsMutableArrayClass || 1126 element == helpers.jsMutableArrayClass ||
1129 element == helpers.jsExtendableArrayClass || 1127 element == helpers.jsExtendableArrayClass ||
1130 element == helpers.jsFixedArrayClass || 1128 element == helpers.jsFixedArrayClass ||
1131 element == helpers.jsUnmodifiableArrayClass; 1129 element == helpers.jsUnmodifiableArrayClass;
1132 } 1130 }
1133 1131
1134 bool mayGenerateInstanceofCheck(ResolutionDartType type) {
1135 // We can use an instanceof check for raw types that have no subclass that
1136 // is mixed-in or in an implements clause.
1137
1138 if (!type.isRaw) return false;
1139 ClassElement classElement = type.element;
1140 if (interceptorData.isInterceptedClass(classElement)) return false;
1141 return _closedWorld.hasOnlySubclasses(classElement);
1142 }
1143
1144 /// This method is called immediately after the [library] and its parts have 1132 /// This method is called immediately after the [library] and its parts have
1145 /// been scanned. 1133 /// been scanned.
1146 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { 1134 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) {
1147 if (!compiler.serialization.isDeserialized(library)) { 1135 if (!compiler.serialization.isDeserialized(library)) {
1148 if (canLibraryUseNative(library)) { 1136 if (canLibraryUseNative(library)) {
1149 library.forEachLocalMember((Element element) { 1137 library.forEachLocalMember((Element element) {
1150 if (element.isClass) { 1138 if (element.isClass) {
1151 checkNativeAnnotation(compiler, element); 1139 checkNativeAnnotation(compiler, element);
1152 } 1140 }
1153 }); 1141 });
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 message: "ClosedWorld has not be set yet.")); 1232 message: "ClosedWorld has not be set yet."));
1245 return _closedWorldCache; 1233 return _closedWorldCache;
1246 } 1234 }
1247 1235
1248 void set _closedWorld(ClosedWorld value) { 1236 void set _closedWorld(ClosedWorld value) {
1249 _closedWorldCache = value; 1237 _closedWorldCache = value;
1250 } 1238 }
1251 1239
1252 /// Called when the compiler starts running the codegen enqueuer. The 1240 /// Called when the compiler starts running the codegen enqueuer. The
1253 /// [WorldImpact] of enabled backend features is returned. 1241 /// [WorldImpact] of enabled backend features is returned.
1254 WorldImpact onCodegenStart(ClosedWorld closedWorld) { 1242 WorldImpact onCodegenStart(
1243 ClosedWorld closedWorld, CodegenWorldBuilder codegenWorldBuilder) {
1255 _closedWorld = closedWorld; 1244 _closedWorld = closedWorld;
1256 _namer = determineNamer(_closedWorld, compiler.codegenWorldBuilder); 1245 _namer = determineNamer(closedWorld, codegenWorldBuilder);
1257 tracer = new Tracer(_closedWorld, namer, compiler); 1246 tracer = new Tracer(closedWorld, namer, compiler);
1258 emitter.createEmitter(_namer, _closedWorld); 1247 emitter.createEmitter(_namer, closedWorld);
1259 _rtiEncoder = 1248 _rtiEncoder =
1260 _namer.rtiEncoder = new _RuntimeTypesEncoder(_namer, emitter, helpers); 1249 _namer.rtiEncoder = new _RuntimeTypesEncoder(_namer, emitter, helpers);
1261 1250
1262 lookupMapAnalysis.onCodegenStart(lookupMapLibraryAccess); 1251 lookupMapAnalysis.onCodegenStart(lookupMapLibraryAccess);
1263 return const WorldImpact(); 1252 return const WorldImpact();
1264 } 1253 }
1265 1254
1266 /// Called when code generation has been completed. 1255 /// Called when code generation has been completed.
1267 void onCodegenEnd() { 1256 void onCodegenEnd() {
1268 sourceInformationStrategy.onComplete(); 1257 sourceInformationStrategy.onComplete();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 return _backend.defaultSuperclass(element); 1643 return _backend.defaultSuperclass(element);
1655 } 1644 }
1656 1645
1657 @override 1646 @override
1658 bool isNativeClass(ClassEntity element) => 1647 bool isNativeClass(ClassEntity element) =>
1659 _backend.nativeData.isNativeClass(element); 1648 _backend.nativeData.isNativeClass(element);
1660 1649
1661 @override 1650 @override
1662 bool isForeign(Element element) => _backend.isForeign(element); 1651 bool isForeign(Element element) => _backend.isForeign(element);
1663 } 1652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698