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

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

Issue 12226074: Cleanup universe to not have backend related things. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/js_backend/backend.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (revision 18239)
+++ sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (working copy)
@@ -621,6 +621,19 @@
SsaCodeGeneratorTask generator;
CodeEmitterTask emitter;
+ /**
+ * The generated code as a js AST for compiled methods.
karlklose 2013/02/08 11:44:53 'js' -> 'JavaScript' or 'JS'
+ */
+ Map<Element, js.Expression> get generatedCode {
+ return compiler.enqueuer.codegen.generatedCode;
+ }
+
+ /**
+ * The generated code as a js AST for compiled bailout methods.
karlklose 2013/02/08 11:44:53 ditto.
+ */
+ final Map<Element, js.Expression> generatedBailoutCode =
+ new Map<Element, js.Expression>();
+
ClassElement jsStringClass;
ClassElement jsArrayClass;
ClassElement jsNumberClass;
@@ -928,7 +941,8 @@
}
void codegen(CodegenWorkItem work) {
- if (work.element.kind.category == ElementCategory.VARIABLE) {
+ Element element = work.element;
+ if (element.kind.category == ElementCategory.VARIABLE) {
Constant initialValue = compiler.constantHandler.compileWorkItem(work);
if (initialValue != null) {
return;
@@ -946,13 +960,13 @@
if (work.allowSpeculativeOptimization
&& optimizer.trySpeculativeOptimizations(work, graph)) {
js.Expression code = generator.generateBailoutMethod(work, graph);
- compiler.codegenWorld.addBailoutCode(work, code);
+ generatedBailoutCode[element] = code;
optimizer.prepareForSpeculativeOptimizations(work, graph);
optimizer.optimize(work, graph, true);
}
js.Expression code = generator.generateCode(work, graph);
- compiler.codegenWorld.addGeneratedCode(work, code);
- invalidateAfterCodegen.forEach(compiler.enqueuer.codegen.eagerRecompile);
+ generatedCode[element] = code;
+ invalidateAfterCodegen.forEach(eagerRecompile);
invalidateAfterCodegen.clear();
}
@@ -964,6 +978,16 @@
return new native.NativeCodegenEnqueuer(world, compiler, emitter);
}
+ /**
+ * Unit test hook that returns code of an element as a String.
+ *
+ * Invariant: [element] must be a declaration element.
+ */
+ String assembleCode(Element element) {
+ assert(invariant(element, element.isDeclaration));
+ return js.prettyPrint(generatedCode[element], compiler).getText();
+ }
+
void assembleProgram() {
emitter.assembleProgram();
}
@@ -1222,4 +1246,17 @@
Element getGetRuntimeTypeInfo() {
return compiler.findHelper(const SourceString('getRuntimeTypeInfo'));
}
+
+ /**
+ * Remove [element] from the set of generated code, and put it back
+ * into the worklist.
+ *
+ * Invariant: [element] must be a declaration element.
+ */
+ void eagerRecompile(Element element) {
+ assert(invariant(element, element.isDeclaration));
+ generatedCode.remove(element);
+ generatedBailoutCode.remove(element);
+ compiler.enqueuer.codegen.addToWorkList(element);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698