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

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

Issue 12525007: Record dependency information to implement first version of dependency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 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 side-by-side diff with in-line comments
Download patch
Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 50433d40edc17a048f8de9a1e5f7ab83ea73abc7..3ebe2984296daad12a9b4e777dc6370431846311 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -852,7 +852,8 @@ class JavaScriptBackend extends Backend {
},
includeSuperMembers: true);
}
- enqueuer.registerInstantiatedClass(cls);
+ // This is a true global dependency.
kasperl 2013/03/06 20:39:43 Extend comment to explain why? You could also add
ahe 2013/03/06 20:54:03 Actually, I need to think more about this. How ma
+ enqueuer.registerInstantiatedClass(cls, compiler.globalDependencies);
}
void registerSpecializedGetInterceptor(Set<ClassElement> classes) {
@@ -877,7 +878,9 @@ class JavaScriptBackend extends Backend {
argumentTypes.registerDynamicInvocation(types, new Selector.noSuchMethod());
}
- void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) {
+ void registerInstantiatedClass(ClassElement cls,
+ Enqueuer enqueuer,
+ TreeElements elements) {
if (!seenAnyClass) {
initializeNoSuchMethod();
seenAnyClass = true;
@@ -901,13 +904,13 @@ class JavaScriptBackend extends Backend {
enqueuer.registerStaticUse(
compiler.findHelper(const SourceString('iae')));
} else if (cls == compiler.functionClass) {
- enqueuer.registerInstantiatedClass(compiler.closureClass);
+ enqueuer.registerInstantiatedClass(compiler.closureClass, elements);
} else if (cls == compiler.mapClass) {
// The backend will use a literal list to initialize the entries
// of the map.
- enqueuer.registerInstantiatedClass(compiler.listClass);
- enqueuer.registerInstantiatedClass(compiler.mapLiteralClass);
- enqueueInResolution(getMapMaker());
+ enqueuer.registerInstantiatedClass(compiler.listClass, elements);
+ enqueuer.registerInstantiatedClass(compiler.mapLiteralClass, elements);
+ enqueueInResolution(getMapMaker(), elements);
}
}
ClassElement result = null;
@@ -939,7 +942,7 @@ class JavaScriptBackend extends Backend {
cls.forEachLocalMember((Element member) {
if (!member.isInstanceMember() || !member.isField()) return;
DartType type = member.computeType(compiler);
- enqueuer.registerIsCheck(type);
+ enqueuer.registerIsCheck(type, elements);
});
}
}
@@ -958,7 +961,9 @@ class JavaScriptBackend extends Backend {
jsIndexingBehaviorInterface =
compiler.findHelper(const SourceString('JavaScriptIndexingBehavior'));
if (jsIndexingBehaviorInterface != null) {
- world.registerIsCheck(jsIndexingBehaviorInterface.computeType(compiler));
+ world.registerIsCheck(jsIndexingBehaviorInterface.computeType(compiler),
+ // This is a true global dependency.
+ compiler.globalDependencies);
}
if (compiler.enableTypeAssertions) {
@@ -971,54 +976,57 @@ class JavaScriptBackend extends Backend {
}
}
- void registerStringInterpolation() {
- enqueueInResolution(getStringInterpolationHelper());
+ void registerStringInterpolation(TreeElements elements) {
+ enqueueInResolution(getStringInterpolationHelper(), elements);
}
- void registerCatchStatement() {
- enqueueInResolution(getExceptionUnwrapper());
+ void registerCatchStatement(TreeElements elements) {
+ enqueueInResolution(getExceptionUnwrapper(), elements);
}
- void registerThrow() {
- enqueueInResolution(getThrowHelper());
+ void registerThrow(TreeElements elements) {
+ enqueueInResolution(getThrowHelper(), elements);
}
- void registerLazyField() {
- enqueueInResolution(getCyclicThrowHelper());
+ void registerLazyField(TreeElements elements) {
+ enqueueInResolution(getCyclicThrowHelper(), elements);
}
- void registerTypeLiteral() {
- enqueueInResolution(getCreateRuntimeType());
+ void registerTypeLiteral(TreeElements elements) {
+ enqueueInResolution(getCreateRuntimeType(), elements);
}
- void registerStackTraceInCatch() {
- enqueueInResolution(getTraceFromException());
+ void registerStackTraceInCatch(TreeElements elements) {
+ enqueueInResolution(getTraceFromException(), elements);
}
- void registerSetRuntimeType() {
- enqueueInResolution(getSetRuntimeTypeInfo());
+ void registerSetRuntimeType(TreeElements elements) {
+ enqueueInResolution(getSetRuntimeTypeInfo(), elements);
}
- void registerGetRuntimeTypeArgument() {
- enqueueInResolution(getGetRuntimeTypeArgument());
+ void registerGetRuntimeTypeArgument(TreeElements elements) {
+ enqueueInResolution(getGetRuntimeTypeArgument(), elements);
}
- void registerRuntimeType() {
- enqueueInResolution(getSetRuntimeTypeInfo());
- enqueueInResolution(getGetRuntimeTypeInfo());
- enqueueInResolution(getGetRuntimeTypeArgument());
- compiler.enqueuer.resolution.registerInstantiatedClass(compiler.listClass);
+ void registerRuntimeType(TreeElements elements) {
+ enqueueInResolution(getSetRuntimeTypeInfo(), elements);
+ enqueueInResolution(getGetRuntimeTypeInfo(), elements);
+ enqueueInResolution(getGetRuntimeTypeArgument(), elements);
+ compiler.enqueuer.resolution.registerInstantiatedClass(
+ compiler.listClass, elements);
}
- void registerIsCheck(DartType type, Enqueuer world) {
+ void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
if (!type.isRaw || isTypeVariable) {
- enqueueInResolution(getSetRuntimeTypeInfo());
- enqueueInResolution(getGetRuntimeTypeInfo());
- enqueueInResolution(getGetRuntimeTypeArgument());
- enqueueInResolution(getCheckArguments());
- if (isTypeVariable) enqueueInResolution(getGetObjectIsSubtype());
- world.registerInstantiatedClass(compiler.listClass);
+ enqueueInResolution(getSetRuntimeTypeInfo(), elements);
+ enqueueInResolution(getGetRuntimeTypeInfo(), elements);
+ enqueueInResolution(getGetRuntimeTypeArgument(), elements);
+ enqueueInResolution(getCheckArguments(), elements);
+ if (isTypeVariable) {
+ enqueueInResolution(getGetObjectIsSubtype(), elements);
+ }
+ world.registerInstantiatedClass(compiler.listClass, elements);
}
// [registerIsCheck] is also called for checked mode checks, so we
// need to register checked mode helpers.
@@ -1031,46 +1039,55 @@ class JavaScriptBackend extends Backend {
}
}
- void registerAsCheck(DartType type) {
+ void registerAsCheck(DartType type, TreeElements elements) {
Element e = getCheckedModeHelper(type, typeCast: true);
- enqueueInResolution(e);
+ enqueueInResolution(e, elements);
// We also need the native variant of the check (for DOM types).
e = getNativeCheckedModeHelper(type, typeCast: true);
- enqueueInResolution(e);
+ enqueueInResolution(e, elements);
}
- void registerThrowNoSuchMethod() {
- enqueueInResolution(getThrowNoSuchMethod());
+ void registerThrowNoSuchMethod(TreeElements elements) {
+ enqueueInResolution(getThrowNoSuchMethod(), elements);
}
- void registerThrowRuntimeError() {
- enqueueInResolution(getThrowRuntimeError());
+ void registerThrowRuntimeError(TreeElements elements) {
+ enqueueInResolution(getThrowRuntimeError(), elements);
}
- void registerAbstractClassInstantiation() {
- enqueueInResolution(getThrowAbstractClassInstantiationError());
+ void registerAbstractClassInstantiation(TreeElements elements) {
+ enqueueInResolution(getThrowAbstractClassInstantiationError(), elements);
}
- void registerFallThroughError() {
- enqueueInResolution(getFallThroughError());
+ void registerFallThroughError(TreeElements elements) {
+ enqueueInResolution(getFallThroughError(), elements);
}
- void registerSuperNoSuchMethod() {
- enqueueInResolution(getCreateInvocationMirror());
+ void registerSuperNoSuchMethod(TreeElements elements) {
+ enqueueInResolution(getCreateInvocationMirror(), elements);
enqueueInResolution(
- compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD));
- compiler.enqueuer.resolution.registerInstantiatedClass(compiler.listClass);
+ compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD),
+ elements);
+ compiler.enqueuer.resolution.registerInstantiatedClass(
+ compiler.listClass, elements);
}
- void enqueueInResolution(Element e) {
- if (e != null) compiler.enqueuer.resolution.addToWorkList(e);
+ void enqueueInResolution(Element e, TreeElements elements) {
+ if (e == null) return;
+ ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
+ enqueuer.addToWorkList(e);
+ elements.registerBackendDependency(e);
}
- void registerConstantMap() {
+ void registerConstantMap(TreeElements elements) {
Element e = compiler.findHelper(const SourceString('ConstantMap'));
- if (e != null) compiler.enqueuer.resolution.registerInstantiatedClass(e);
+ if (e != null) {
+ compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
+ }
e = compiler.findHelper(const SourceString('ConstantProtoMap'));
- if (e != null) compiler.enqueuer.resolution.registerInstantiatedClass(e);
+ if (e != null) {
+ compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
+ }
}
void codegen(CodegenWorkItem work) {

Powered by Google App Engine
This is Rietveld 408576698