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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/task.dart

Issue 1537663002: dart2js: Initial implementation of inlining. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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/codegen/task.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/task.dart b/pkg/compiler/lib/src/js_backend/codegen/task.dart
index 78f61cb1bad41b528b5bc101473c4eeb6b551b65..8a98f4ffd775fd51c656a6f5ec1af1c2fa5dc7e0 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/task.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/task.dart
@@ -66,18 +66,22 @@ class CpsFunctionCompiler implements FunctionCompiler {
final GenericTask treeBuilderTask;
final GenericTask treeOptimizationTask;
+ Inliner inliner;
+
CpsFunctionCompiler(Compiler compiler, JavaScriptBackend backend,
SourceInformationStrategy sourceInformationFactory)
: fallbackCompiler =
new ssa.SsaFunctionCompiler(backend, sourceInformationFactory),
cpsBuilderTask = new IrBuilderTask(compiler, sourceInformationFactory),
- this.sourceInformationFactory = sourceInformationFactory,
+ sourceInformationFactory = sourceInformationFactory,
constantSystem = backend.constantSystem,
compiler = compiler,
glue = new Glue(compiler),
cpsOptimizationTask = new GenericTask('CPS optimization', compiler),
treeBuilderTask = new GenericTask('Tree builder', compiler),
- treeOptimizationTask = new GenericTask('Tree optimization', compiler);
+ treeOptimizationTask = new GenericTask('Tree optimization', compiler) {
+ inliner = new Inliner(this);
+ }
String get name => 'CPS Ir pipeline';
@@ -87,9 +91,9 @@ class CpsFunctionCompiler implements FunctionCompiler {
/// Generates JavaScript code for `work.element`.
js.Fun compile(CodegenWorkItem work) {
+ if (typeSystem == null) typeSystem = new TypeMaskSystem(compiler);
AstElement element = work.element;
return reporter.withCurrentElement(element, () {
- typeSystem = new TypeMaskSystem(compiler);
try {
// TODO(karlklose): remove this fallback when we do not need it for
// testing anymore.
@@ -102,7 +106,9 @@ class CpsFunctionCompiler implements FunctionCompiler {
tracer.traceCompilation(element.name, null);
}
cps.FunctionDefinition cpsFunction = compileToCpsIr(element);
- cpsFunction = optimizeCpsIr(cpsFunction);
+ optimizeCpsBeforeInlining(cpsFunction);
+ applyCpsPass(inliner, cpsFunction);
+ optimizeCpsAfterInlining(cpsFunction);
cpsIntegrityChecker = null;
tree_ir.FunctionDefinition treeFunction = compileToTreeIr(cpsFunction);
treeFunction = optimizeTreeIr(treeFunction);
@@ -200,14 +206,19 @@ class CpsFunctionCompiler implements FunctionCompiler {
return true; // So this can be used from assert().
}
- cps.FunctionDefinition optimizeCpsIr(cps.FunctionDefinition cpsFunction) {
+ void optimizeCpsBeforeInlining(cps.FunctionDefinition cpsFunction) {
cpsOptimizationTask.measure(() {
applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
applyCpsPass(new RedundantPhiEliminator(), cpsFunction);
applyCpsPass(new InsertRefinements(typeSystem), cpsFunction);
- applyCpsPass(new TypePropagator(compiler, typeSystem, this), cpsFunction);
+ applyCpsPass(new TypePropagator(this), cpsFunction);
applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
applyCpsPass(new ShrinkingReducer(), cpsFunction);
+ });
+ }
+
+ void optimizeCpsAfterInlining(cps.FunctionDefinition cpsFunction) {
+ cpsOptimizationTask.measure(() {
applyCpsPass(new RedundantRefinementEliminator(typeSystem), cpsFunction);
applyCpsPass(new EagerlyLoadStatics(), cpsFunction);
applyCpsPass(new GVN(compiler, typeSystem), cpsFunction);
@@ -222,7 +233,6 @@ class CpsFunctionCompiler implements FunctionCompiler {
applyCpsPass(new OptimizeInterceptors(backend), cpsFunction);
applyCpsPass(new ShrinkingReducer(), cpsFunction);
});
- return cpsFunction;
}
tree_ir.FunctionDefinition compileToTreeIr(cps.FunctionDefinition cpsNode) {

Powered by Google App Engine
This is Rietveld 408576698