mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Support reusing source library builders
Change-Id: Idc884e9c733bad0cb3e15be3cbaf248e8371196a Reviewed-on: https://dart-review.googlesource.com/28663 Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
891e591415
commit
0cad7e3168
|
@ -187,7 +187,7 @@ class KernelTarget extends TargetImplementation {
|
|||
List<ClassBuilder> result = <ClassBuilder>[];
|
||||
loader.builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
library.forEach((String name, Builder member) {
|
||||
if (member is KernelClassBuilder) {
|
||||
if (member is ClassBuilder) {
|
||||
result.add(member);
|
||||
}
|
||||
});
|
||||
|
@ -380,20 +380,22 @@ class KernelTarget extends TargetImplementation {
|
|||
void installDefaultSupertypes() {
|
||||
Class objectClass = this.objectClass;
|
||||
loader.builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
library.forEach((String name, Builder builder) {
|
||||
if (builder is SourceClassBuilder) {
|
||||
Class cls = builder.target;
|
||||
if (cls != objectClass) {
|
||||
cls.supertype ??= objectClass.asRawSupertype;
|
||||
builder.supertype ??= new KernelNamedTypeBuilder("Object", null)
|
||||
..bind(objectClassBuilder);
|
||||
if (library.loader == loader) {
|
||||
library.forEach((String name, Builder builder) {
|
||||
if (builder is SourceClassBuilder) {
|
||||
Class cls = builder.target;
|
||||
if (cls != objectClass) {
|
||||
cls.supertype ??= objectClass.asRawSupertype;
|
||||
builder.supertype ??= new KernelNamedTypeBuilder("Object", null)
|
||||
..bind(objectClassBuilder);
|
||||
}
|
||||
if (builder.isMixinApplication) {
|
||||
cls.mixedInType = builder.mixedInType
|
||||
.buildSupertype(library, builder.charOffset, builder.fileUri);
|
||||
}
|
||||
}
|
||||
if (builder.isMixinApplication) {
|
||||
cls.mixedInType = builder.mixedInType
|
||||
.buildSupertype(library, builder.charOffset, builder.fileUri);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
ticker.logMs("Installed Object as implicit superclass");
|
||||
}
|
||||
|
|
|
@ -142,8 +142,10 @@ abstract class Loader<L> {
|
|||
Future<Null> buildBodies() async {
|
||||
assert(coreLibrary != null);
|
||||
for (LibraryBuilder library in builders.values) {
|
||||
currentUriForCrashReporting = library.uri;
|
||||
await buildBody(library);
|
||||
if (library.loader == this) {
|
||||
currentUriForCrashReporting = library.uri;
|
||||
await buildBody(library);
|
||||
}
|
||||
}
|
||||
currentUriForCrashReporting = null;
|
||||
logSummary(templateSourceBodySummary);
|
||||
|
|
|
@ -209,12 +209,13 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void resolveParts() {
|
||||
List<Uri> parts = <Uri>[];
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
if (library.isPart) {
|
||||
library.validatePart();
|
||||
if (library.loader == this) {
|
||||
SourceLibraryBuilder sourceLibrary = library;
|
||||
if (sourceLibrary.isPart) {
|
||||
sourceLibrary.validatePart();
|
||||
parts.add(uri);
|
||||
} else {
|
||||
library.includeParts();
|
||||
sourceLibrary.includeParts();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -222,7 +223,7 @@ class SourceLoader<L> extends Loader<L> {
|
|||
ticker.logMs("Resolved parts");
|
||||
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
if (library.loader == this) {
|
||||
library.applyPatches();
|
||||
}
|
||||
});
|
||||
|
@ -233,8 +234,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
Set<LibraryBuilder> exporters = new Set<LibraryBuilder>();
|
||||
Set<LibraryBuilder> exportees = new Set<LibraryBuilder>();
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
library.buildInitialScopes();
|
||||
if (library.loader == this) {
|
||||
SourceLibraryBuilder sourceLibrary = library;
|
||||
sourceLibrary.buildInitialScopes();
|
||||
}
|
||||
if (library.exporters.isNotEmpty) {
|
||||
exportees.add(library);
|
||||
|
@ -266,10 +268,18 @@ class SourceLoader<L> extends Loader<L> {
|
|||
}
|
||||
} while (wasChanged);
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
library.addImportsToScope();
|
||||
if (library.loader == this) {
|
||||
SourceLibraryBuilder sourceLibrary = library;
|
||||
sourceLibrary.addImportsToScope();
|
||||
}
|
||||
});
|
||||
for (LibraryBuilder exportee in exportees) {
|
||||
// TODO(ahe): Change how we track exporters. Currently, when a library
|
||||
// (exporter) exports another library (exportee) we add a reference to
|
||||
// exporter to exportee. This creates a reference in the wrong direction
|
||||
// and can lead to memory leaks.
|
||||
exportee.exporters.clear();
|
||||
}
|
||||
ticker.logMs("Computed library scopes");
|
||||
// debugPrintExports();
|
||||
}
|
||||
|
@ -314,7 +324,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void finishDeferredLoadTearoffs() {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.finishDeferredLoadTearoffs();
|
||||
if (library.loader == this) {
|
||||
count += library.finishDeferredLoadTearoffs();
|
||||
}
|
||||
});
|
||||
ticker.logMs("Finished deferred load tearoffs $count");
|
||||
}
|
||||
|
@ -322,7 +334,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void finishStaticInvocations() {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.finishStaticInvocations();
|
||||
if (library.loader == this) {
|
||||
count += library.finishStaticInvocations();
|
||||
}
|
||||
});
|
||||
ticker.logMs("Finished static invocations $count");
|
||||
}
|
||||
|
@ -330,7 +344,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void resolveConstructors() {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.resolveConstructors(null);
|
||||
if (library.loader == this) {
|
||||
count += library.resolveConstructors(null);
|
||||
}
|
||||
});
|
||||
ticker.logMs("Resolved $count constructors");
|
||||
}
|
||||
|
@ -338,7 +354,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void finishTypeVariables(ClassBuilder object) {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.finishTypeVariables(object);
|
||||
if (library.loader == this) {
|
||||
count += library.finishTypeVariables(object);
|
||||
}
|
||||
});
|
||||
ticker.logMs("Resolved $count type-variable bounds");
|
||||
}
|
||||
|
@ -346,7 +364,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void finishNativeMethods() {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.finishNativeMethods();
|
||||
if (library.loader == this) {
|
||||
count += library.finishNativeMethods();
|
||||
}
|
||||
});
|
||||
ticker.logMs("Finished $count native methods");
|
||||
}
|
||||
|
@ -354,7 +374,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void finishPatchMethods() {
|
||||
int count = 0;
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
count += library.finishPatchMethods();
|
||||
if (library.loader == this) {
|
||||
count += library.finishPatchMethods();
|
||||
}
|
||||
});
|
||||
ticker.logMs("Finished $count patch methods");
|
||||
}
|
||||
|
@ -497,8 +519,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
|
||||
void buildProgram() {
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
L target = library.build(coreLibrary);
|
||||
if (library.loader == this) {
|
||||
SourceLibraryBuilder sourceLibrary = library;
|
||||
L target = sourceLibrary.build(coreLibrary);
|
||||
if (!library.isPatch) {
|
||||
libraries.add(target);
|
||||
}
|
||||
|
@ -517,7 +540,9 @@ class SourceLoader<L> extends Loader<L> {
|
|||
void checkOverrides(List<SourceClassBuilder> sourceClasses) {
|
||||
assert(hierarchy != null);
|
||||
for (SourceClassBuilder builder in sourceClasses) {
|
||||
builder.checkOverrides(hierarchy);
|
||||
if (builder.library.loader == this) {
|
||||
builder.checkOverrides(hierarchy);
|
||||
}
|
||||
}
|
||||
ticker.logMs("Checked overrides");
|
||||
}
|
||||
|
@ -539,7 +564,7 @@ class SourceLoader<L> extends Loader<L> {
|
|||
instrumentation,
|
||||
target.strongMode);
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
if (library.loader == this) {
|
||||
library.prepareTopLevelInference(library, null);
|
||||
}
|
||||
});
|
||||
|
@ -574,7 +599,7 @@ class SourceLoader<L> extends Loader<L> {
|
|||
typeInferenceEngine.finishTopLevelInitializingFormals();
|
||||
if (instrumentation != null) {
|
||||
builders.forEach((Uri uri, LibraryBuilder library) {
|
||||
if (library is SourceLibraryBuilder) {
|
||||
if (library.loader == this) {
|
||||
library.instrumentTopLevelInference(instrumentation);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue