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

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

Issue 1259553002: Emit program and dependency information as relations in a Prolog database. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 5 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/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 8ee164d98418ac27c4a751eccd5205663a32f80f..0677e952af2c6692ac12b9b7ac8d5a4f7aec0739 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -4,6 +4,20 @@
part of dart2js;
+// TODO(karlklose): move this to own library.
+
+class CallSite {
+ final TreeElements context;
+ final Send node;
+ CallSite(this.context, this.node);
+}
+
+class Dependency {
+ final CallSite site;
+ final Element target;
+ Dependency(this.site, this.target);
+}
+
/**
* If true, print a warning for each method that was resolved, but not
* compiled.
@@ -57,6 +71,8 @@ class CodegenRegistry extends Registry {
bool get isForResolution => false;
+ Element get currentElement => treeElements.currentElement;
+
// TODO(johnniwinther): Remove this getter when [Registry] creates a
// dependency node.
Setlet<Element> get otherDependencies => treeElements.otherDependencies;
@@ -81,15 +97,15 @@ class CodegenRegistry extends Registry {
}
void registerDynamicInvocation(Selector selector) {
- world.registerDynamicInvocation(selector);
+ world.registerDynamicInvocation(currentElement, selector);
}
void registerDynamicSetter(Selector selector) {
- world.registerDynamicSetter(selector);
+ world.registerDynamicSetter(currentElement, selector);
}
void registerDynamicGetter(Selector selector) {
- world.registerDynamicGetter(selector);
+ world.registerDynamicGetter(currentElement, selector);
}
void registerGetterForSuperMethod(Element element) {
@@ -128,7 +144,7 @@ class CodegenRegistry extends Registry {
}
void registerSelectorUse(Selector selector) {
- world.registerSelectorUse(selector);
+ world.registerSelectorUse(currentElement, selector);
}
void registerFactoryWithTypeArguments() {
@@ -239,7 +255,8 @@ abstract class Backend {
void assembleProgram();
List<CompilerTask> get tasks;
- void onResolutionComplete() {}
+ void onResolutionComplete() {
+ }
ItemCompilationContext createItemCompilationContext() {
return new ItemCompilationContext();
@@ -351,8 +368,9 @@ abstract class Backend {
* Call this method to enable [noSuchMethod] handling in the
* backend.
*/
- void enableNoSuchMethod(Enqueuer enqueuer) {
- enqueuer.registerInvocation(compiler.noSuchMethodSelector);
+ void enableNoSuchMethod(context, Enqueuer enqueuer) {
+ // TODO(karlklose): add a context here.
+ enqueuer.registerInvocation(null, compiler.noSuchMethodSelector);
}
void registerRequiredType(DartType type, Element enclosingElement) {}
@@ -1319,7 +1337,7 @@ abstract class Compiler implements DiagnosticListener {
enqueuer.codegen.registerGetOfStaticFunction(main);
}
if (enabledNoSuchMethod) {
- backend.enableNoSuchMethod(enqueuer.codegen);
+ backend.enableNoSuchMethod(null, enqueuer.codegen);
}
if (compileAll) {
libraries.forEach((_, lib) => fullyEnqueueLibrary(lib,
@@ -1959,3 +1977,47 @@ class SuppressionInfo {
int warnings = 0;
int hints = 0;
}
+
+// TODO(karlklose): rename to [CompilationInformation].
+class Relations {
+ final String prefix;
+
+ Relations(Enqueuer enqueuer)
+ : prefix = enqueuer.isResolutionQueue ? 'resolution' : 'codegen';
+
+ // General binary relations. Relation X Target -> Source
+ Map<String, Map<dynamic, Set>> links = {};
+
+ Set<CallSite> callSites = new Set<CallSite>();
+
+ put(String relation, target, source) {
+ links.putIfAbsent(relation, () => {})
+ .putIfAbsent(target, () => new Set())
+ .add(source);
+ }
+
+ instantiates(InterfaceType type, Element source) {
+ assert(source is FunctionElement || source is VariableElement);
+ put('instantiates', type, source);
+ }
+
+ registerCallSite(TreeElements context, Send node) {
+ callSites.add(new CallSite(context, node));
+ }
+
+ enqueues(Element function, Element source) {
+ assert(source is Element || source is Element);
+ put('enqueues', function, source);
+ }
+
+ void finalizeInformation(Compiler compiler) {
+ for (CallSite callSite in callSites) {
+ TreeElements context = callSite.context;
+ Selector selector = context.getSelector(callSite.node);
+ Element source = context.currentElement;
+ for (Element target in compiler.world.allFunctions.filter(selector)) {
+ put('calls', source, target);
+ }
+ }
+ }
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/common.dart ('k') | sdk/lib/_internal/compiler/implementation/dart2jslib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698