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

Unified Diff: pkg/compiler/lib/src/ssa/ssa.dart

Issue 2269783002: Add skeleton of SSAKernel function compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/ssa.dart
diff --git a/pkg/compiler/lib/src/ssa/ssa.dart b/pkg/compiler/lib/src/ssa/ssa.dart
index 555b82c14273844fc64d69659e08fe286faaaac7..587ce890e57ffeb7597a10a116bdb6ce024cc03b 100644
--- a/pkg/compiler/lib/src/ssa/ssa.dart
+++ b/pkg/compiler/lib/src/ssa/ssa.dart
@@ -4,4 +4,56 @@
library ssa;
-export 'builder.dart' show SsaFunctionCompiler;
+import '../common/codegen.dart' show CodegenWorkItem;
+import '../common/tasks.dart' show CompilerTask;
+import '../elements/elements.dart' show Element, FunctionElement;
+import '../io/source_information.dart';
+import '../js/js.dart' as js;
+import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
+
+import 'builder.dart';
+import 'builder_kernel.dart';
+import 'codegen.dart';
+import 'nodes.dart';
+import 'optimize.dart';
+import 'types.dart';
+
+class SsaFunctionCompiler implements FunctionCompiler {
+ final SsaCodeGeneratorTask generator;
+ final SsaBuilderTask builder;
+ final SsaKernelBuilderTask builderKernel;
+ final SsaOptimizerTask optimizer;
+ final JavaScriptBackend backend;
+ final bool useKernel;
+
+ SsaFunctionCompiler(JavaScriptBackend backend,
+ SourceInformationStrategy sourceInformationFactory, this.useKernel)
+ : generator = new SsaCodeGeneratorTask(backend, sourceInformationFactory),
+ builder = new SsaBuilderTask(backend, sourceInformationFactory),
+ builderKernel =
+ new SsaKernelBuilderTask(backend, sourceInformationFactory),
+ optimizer = new SsaOptimizerTask(backend),
+ backend = backend;
+
+ /// Generates JavaScript code for `work.element`.
+ /// Using the ssa builder, optimizer and codegenerator.
+ js.Fun compile(CodegenWorkItem work) {
+ HGraph graph = useKernel ? builderKernel.build(work) : builder.build(work);
+ optimizer.optimize(work, graph);
+ Element element = work.element;
+ js.Expression result = generator.generateCode(work, graph);
+ if (element is FunctionElement) {
+ // TODO(sigmund): replace by kernel transformer when `useKernel` is true.
+ result = backend.rewriteAsync(element, result);
+ }
+ return result;
+ }
+
+ Iterable<CompilerTask> get tasks {
+ return <CompilerTask>[
+ useKernel ? builderKernel : builder,
+ optimizer,
+ generator
+ ];
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698