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

Unified Diff: sdk/lib/_internal/compiler/implementation/deferred_load.dart

Issue 221873002: Compute frontend/backend specific constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes Created 6 years, 8 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: sdk/lib/_internal/compiler/implementation/deferred_load.dart
diff --git a/sdk/lib/_internal/compiler/implementation/deferred_load.dart b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
index 8585c4825134d354927f55558c5f9eff19717d6f..294fb34711d5617e3d287a62db580380720d297f 100644
--- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart
+++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
@@ -5,6 +5,7 @@
library deferred_load;
import 'dart2jslib.dart' show
+ Backend,
Compiler,
CompilerTask,
Constant,
@@ -150,6 +151,8 @@ class DeferredLoadTask extends CompilerTask {
DeferredLoadTask(Compiler compiler) : super(compiler);
+ Backend get backend => compiler.backend;
+
/// Returns the [OutputUnit] where [element] belongs.
OutputUnit outputUnitForElement(Element element) {
if (!splitProgram) return mainOutputUnit;
@@ -292,7 +295,11 @@ class DeferredLoadTask extends CompilerTask {
if (dependency.isStatement()) continue;
elementDependencies.add(dependency);
}
- constantDependencies.addAll(elements.allConstants);
+ elements.forEachConstantNode((Node n, _) {
+ // Explicitly depend on the backend constants.
+ constantDependencies.add(
+ backend.constants.getConstantForNode(n, elements));
+ });
elementDependencies.addAll(elements.otherDependencies);
}
@@ -305,9 +312,10 @@ class DeferredLoadTask extends CompilerTask {
Set<Constant> constants) {
// TODO(sigurdm): How is metadata on a patch-class handled?
for (MetadataAnnotation metadata in element.metadata) {
- if (metadata.value != null) {
- constants.add(metadata.value);
- elements.add(metadata.value.computeType(compiler).element);
+ Constant constant = backend.constants.getConstantForMetadata(metadata);
+ if (constant != null) {
+ constants.add(constant);
+ elements.add(constant.computeType(compiler).element);
}
}
if (element.isClass()) {
@@ -419,15 +427,19 @@ class DeferredLoadTask extends CompilerTask {
// TODO(sigurdm): The metadata should go to the right output unit.
// For now they all go to the main output unit.
for (MetadataAnnotation metadata in library.metadata) {
- if (metadata.value != null) {
- _mapDependencies(metadata.value.computeType(compiler).element,
+ Constant constant =
+ backend.constants.getConstantForMetadata(metadata);
+ if (constant != null) {
+ _mapDependencies(constant.computeType(compiler).element,
_fakeMainImport);
}
}
for (LibraryTag tag in library.tags) {
for (MetadataAnnotation metadata in tag.metadata) {
- if (metadata.value != null) {
- _mapDependencies(metadata.value.computeType(compiler).element,
+ Constant constant =
+ backend.constants.getConstantForMetadata(metadata);
+ if (constant != null) {
+ _mapDependencies(constant.computeType(compiler).element,
_fakeMainImport);
}
}
@@ -596,8 +608,7 @@ class DeferredLoadTask extends CompilerTask {
for (MetadataAnnotation metadata in metadatas) {
metadata.ensureResolved(compiler);
Element element = metadata.value.computeType(compiler).element;
- if (metadata.value.computeType(compiler).element ==
- deferredLibraryClass) {
+ if (element == deferredLibraryClass) {
ConstructedConstant constant = metadata.value;
StringConstant s = constant.fields[0];
result = s.value.slowToString();
@@ -766,7 +777,7 @@ class DeferredLoadTask extends CompilerTask {
}
});
}
- if (splitProgram && compiler.backend is DartBackend) {
+ if (splitProgram && backend is DartBackend) {
// TODO(sigurdm): Implement deferred loading for dart2dart.
splitProgram = false;
compiler.reportInfo(

Powered by Google App Engine
This is Rietveld 408576698