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

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

Issue 2274263002: skeleton Kernel -> SSA builder (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.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 5c82e26af290c5a9a171d9803643963b1b098197..1f338dcfdd1a1fe6d3feaf77d4096416fbf0e035 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -2,15 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:kernel/ast.dart' as ir;
+
import '../common/codegen.dart' show CodegenWorkItem;
import '../common/tasks.dart' show CompilerTask;
+import '../compiler.dart';
import '../elements/elements.dart';
import '../io/source_information.dart';
-import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
+import '../js_backend/backend.dart' show JavaScriptBackend;
import '../kernel/kernel.dart';
import '../kernel/kernel_visitor.dart';
import '../resolution/tree_elements.dart';
-
+import 'graph_builder.dart';
import 'nodes.dart';
class SsaKernelBuilderTask extends CompilerTask {
@@ -32,10 +35,60 @@ class SsaKernelBuilderTask extends CompilerTask {
IrFunction function;
try {
function = visitor.buildFunction();
- } catch(e) {
+ } catch (e) {
throw "Failed to convert to Kernel IR: $e";
}
- throw "Successfully converted to Kernel IR: $function";
+ KernelSsaBuilder builder =
+ new KernelSsaBuilder(function, element, backend.compiler);
+ return builder.build();
});
}
}
+
+// DESIGN NOTE: I am implementing this by essentially copying the methods in
+// [SsaBuilder], but trying to use Kernel IR instead of our AST nodes. In places
+// where there is functionality in the [SsaBuilder] that is not yet needed in
+// this builder, I am adding a comment that tells what the [SsaBuilder] does at
+// that location.
+class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
+ final IrFunction function;
+ final FunctionElement functionElement;
+ final Compiler compiler;
+
+ KernelSsaBuilder(this.function, this.functionElement, this.compiler);
+
+ HGraph build() {
+ if (function.kind == ir.ProcedureKind.Method) {
+ buildMethod(function);
+ } else {
+ compiler.reporter.internalError(
+ functionElement,
+ "Unable to convert this kind of Kernel "
+ "procedure to SSA: ${function.kind}");
+ }
+ assert(graph.isValid());
+ return graph;
+ }
+
+ /// Builds a SSA graph for [method].
+ void buildMethod(IrFunction method) {
+ // TODO(het): Determine whether or not this method is called in a loop and
+ // set [graph.isCalledInLoop].
+ openFunction(method);
+ }
+
+ void openFunction(IrFunction method) {
+ HBasicBlock block = graph.addNewBlock();
+ open(graph.entry);
+ // TODO(het): Register parameters with a locals handler
+ close(new HGoto()).addSuccessor(block);
+
+ open(block);
+
+ // TODO(het): If this is a constructor then add the type parameters of the
+ // enclosing class as parameters to the method. This must be done before
+ // adding normal parameters because their types may contain references to
+ // the class type parameters.
+
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698