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

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: Rebaseline test expectations and fix a bug (typo). 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a5171030439a8595b9036b0789f368ce3ebdfd60..33430beac5f2ff503e9b1ec66500c89b587e0c36 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);
@@ -223,7 +234,6 @@ class CpsFunctionCompiler implements FunctionCompiler {
applyCpsPass(new BackwardNullCheckRemover(typeSystem), cpsFunction);
applyCpsPass(new ShrinkingReducer(), cpsFunction);
});
- return cpsFunction;
}
tree_ir.FunctionDefinition compileToTreeIr(cps.FunctionDefinition cpsNode) {
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698