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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 716823002: Set up a stub pipline for using the new cps-based ir to generate js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move IrEnabled to compiler Created 6 years, 1 month 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: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 0f01f9c86572926652e2c1bf78a4637cc4c23fd5..7317bd498173829c76c26ff8cee06537e1dd5957 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -6,11 +6,20 @@ part of js_backend;
const VERBOSE_OPTIMIZER_HINTS = false;
+const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR");
+
class JavaScriptItemCompilationContext extends ItemCompilationContext {
final Set<HInstruction> boundsChecked = new Set<HInstruction>();
final Set<HInstruction> allocatedFixedLists = new Set<HInstruction>();
}
+abstract class FunctionCompiler {
+ /// Generates JavaScript code for `work.element`.
+ jsAst.Fun compile(CodegenWorkItem work);
+
+ Iterable get tasks;
+}
+
/*
* Invariants:
* canInline(function) implies canInline(function, insideLoop:true)
@@ -97,9 +106,8 @@ class JavaScriptBackend extends Backend {
return [closureClass, jsIndexableClass];
}
- SsaBuilderTask builder;
- SsaOptimizerTask optimizer;
- SsaCodeGeneratorTask generator;
+ FunctionCompiler functionCompiler;
+
CodeEmitterTask emitter;
/**
@@ -330,7 +338,9 @@ class JavaScriptBackend extends Backend {
new Setlet<FunctionElement>();
List<CompilerTask> get tasks {
- return <CompilerTask>[builder, optimizer, generator, emitter];
+ List<CompilerTask> result = functionCompiler.tasks;
+ result.add(emitter);
+ return result;
}
final RuntimeTypes rti;
@@ -445,13 +455,13 @@ class JavaScriptBackend extends Backend {
specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
super(compiler) {
emitter = new CodeEmitterTask(compiler, namer, generateSourceMap);
- builder = new SsaBuilderTask(this);
- optimizer = new SsaOptimizerTask(this);
- generator = new SsaCodeGeneratorTask(this);
typeVariableHandler = new TypeVariableHandler(this);
customElementsAnalysis = new CustomElementsAnalysis(this);
constantCompilerTask = new JavaScriptConstantTask(compiler);
resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
+ functionCompiler = USE_CPS_IR
+ ? new CspFunctionCompiler(compiler, this)
+ : new SsaFunctionCompiler(this);
}
ConstantSystem get constantSystem => constants.constantSystem;
@@ -1187,7 +1197,8 @@ class JavaScriptBackend extends Backend {
return;
}
if (kind.category == ElementCategory.VARIABLE) {
- ConstantExpression initialValue = constants.getConstantForVariable(element);
+ ConstantExpression initialValue =
+ constants.getConstantForVariable(element);
if (initialValue != null) {
registerCompileTimeConstant(initialValue.value, work.registry);
constants.addCompileTimeConstantForEmission(initialValue.value);
@@ -1203,10 +1214,7 @@ class JavaScriptBackend extends Backend {
compiler.enqueuer.codegen.registerStaticUse(getCyclicThrowHelper());
}
}
- HGraph graph = builder.build(work);
- optimizer.optimize(work, graph);
- jsAst.Expression code = generator.generateCode(work, graph);
- generatedCode[element] = code;
+ generatedCode[element] = functionCompiler.compile(work);
}
native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) {
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/tree_ir_tracer.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698