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

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

Issue 2264403007: compile empty function to ssa from kernel (Closed)
Patch Set: also import 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 | « no previous file | tests/compiler/dart2js/dart2js.status » ('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 72f81606dec5fb142e2f68012154a04d1a7de506..a44ea376a478b666944a3f7bd1aec3ab81e01edc 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -39,31 +39,37 @@ class SsaKernelBuilderTask extends CompilerTask {
} catch (e) {
throw "Failed to convert to Kernel IR: $e";
}
- KernelSsaBuilder builder = new KernelSsaBuilder(function, element,
- work.resolvedAst, backend.compiler, sourceInformationFactory);
+ KernelSsaBuilder builder = new KernelSsaBuilder(
+ function,
+ element,
+ work.resolvedAst,
+ backend.compiler,
+ sourceInformationFactory,
+ visitor.nodeToElement);
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 ResolvedAst resolvedAst;
final Compiler compiler;
+ final Map<ir.Node, Element> nodeToElement;
JavaScriptBackend get backend => compiler.backend;
LocalsHandler localsHandler;
SourceInformationBuilder sourceInformationBuilder;
- KernelSsaBuilder(this.function, this.functionElement, this.resolvedAst,
- this.compiler, SourceInformationStrategy sourceInformationFactory) {
+ KernelSsaBuilder(
+ this.function,
+ this.functionElement,
+ this.resolvedAst,
+ this.compiler,
+ SourceInformationStrategy sourceInformationFactory,
+ this.nodeToElement) {
graph.element = functionElement;
// TODO(het): Should sourceInformationBuilder be in GraphBuilder?
this.sourceInformationBuilder =
@@ -75,6 +81,8 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
}
HGraph build() {
+ // TODO(het): no reason to do this here...
+ HInstruction.idCounter = 0;
if (function.kind == ir.ProcedureKind.Method) {
buildMethod(function, functionElement);
} else {
@@ -89,9 +97,9 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
/// Builds a SSA graph for [method].
void buildMethod(IrFunction method, FunctionElement functionElement) {
- // TODO(het): Determine whether or not this method is called in a loop and
- // set [graph.isCalledInLoop].
openFunction(method, functionElement);
+ method.node.body.accept(this);
+ closeFunction();
}
void openFunction(IrFunction method, FunctionElement functionElement) {
@@ -102,10 +110,10 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
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.
+ void closeFunction() {
+ if (!isAborted()) closeAndGotoExit(new HGoto());
+ graph.finalize();
}
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698