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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart

Issue 73403003: Fix bug in type_variable_handler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart b/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
index 7ffe86251117f600914b31b6b47a3ada8d4372dd..564880b256f47a3899d22895d6c1fc3a8990689c 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
@@ -40,31 +40,15 @@ class TypeVariableHandler {
Compiler get compiler => backend.compiler;
void registerClassWithTypeVariables(ClassElement cls) {
- typeVariableClasses.add(cls);
- }
-
- void onResolutionQueueEmpty(Enqueuer enqueuer) {
- if (typeVariableConstructor == null) {
- if (!typeVariableClass.constructors.isEmpty &&
- !typeVariableClass.constructors.tail.isEmpty) {
- compiler.reportInternalError(
- typeVariableClass,
- 'Class $typeVariableClass should only have one constructor');
- }
- typeVariableConstructor = typeVariableClass.constructors.head;
- backend.enqueueClass(
- enqueuer, typeVariableClass, compiler.globalDependencies);
- backend.enqueueInResolution(
- typeVariableConstructor, compiler.globalDependencies);
+ if (!backend.isTreeShakingDisabled || typeVariableConstructor == null) {
+ typeVariableClasses.add(cls);
+ } else {
+ processTypeVariablesOf(cls);
}
}
- void onCodegenQueueEmpty() {
- evaluator = new CompileTimeConstantEvaluator(
- compiler.constantHandler, compiler.globalDependencies, compiler);
-
- for (ClassElement cls in typeVariableClasses) {
- // TODO(zarah): Running through all the members is suboptimal. Change this
+ void processTypeVariablesOf(ClassElement cls) {
+ //TODO(zarah): Running through all the members is suboptimal. Change this
// as part of marking elements for reflection.
bool hasMemberNeededForReflection(ClassElement cls) {
bool result = false;
@@ -75,10 +59,17 @@ class TypeVariableHandler {
}
if (!backend.isNeededForReflection(cls) &&
- !hasMemberNeededForReflection(cls)) continue;
+ !hasMemberNeededForReflection(cls)) {
+ return;
+ }
InterfaceType typeVariableType = typeVariableClass.computeType(compiler);
List<int> constants = <int>[];
+ evaluator = new CompileTimeConstantEvaluator(
+ compiler.constantHandler,
+ compiler.globalDependencies,
+ compiler);
+
for (TypeVariableType currentTypeVariable in cls.typeVariables) {
List<Constant> createArguments(FunctionElement constructor) {
if (constructor != typeVariableConstructor) {
@@ -104,8 +95,26 @@ class TypeVariableHandler {
reifyTypeVariableConstant(c, currentTypeVariable.element));
}
typeVariables[cls] = constants;
+ }
+
+ void onTreeShakingDisabled(Enqueuer enqueuer) {
ahe 2013/11/27 15:43:58 Perhaps this should be grouped with registerClassW
zarah 2013/11/28 09:29:25 Done.
+ if (!enqueuer.isResolutionQueue || typeVariableClasses == null) return;
+ backend.enqueueClass(
+ enqueuer, typeVariableClass, compiler.globalDependencies);
+ Link constructors = typeVariableClass.ensureResolved(compiler).constructors;
+ if (constructors.isEmpty && constructors.tail.isEmpty) {
+ compiler.reportInternalError(
+ typeVariableClass,
+ "Class '$typeVariableClass' should only have one constructor");
}
- typeVariableClasses.clear();
+ typeVariableConstructor = typeVariableClass.constructors.head;
+ backend.enqueueInResolution(typeVariableConstructor,
+ compiler.globalDependencies);
+ enqueuer.registerInstantiatedType(typeVariableClass.rawType,
+ compiler.globalDependencies);
+ List<ClassElement> worklist = typeVariableClasses;
+ typeVariableClasses = null;
+ worklist.forEach((cls) => processTypeVariablesOf(cls));
}
/**

Powered by Google App Engine
This is Rietveld 408576698