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

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

Issue 2936693002: Reapply "Separate out loop closure information." (Closed)
Patch Set: call with ast.node instead of ir.Node until we update that path. Created 3 years, 6 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/locals_handler.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 05a110549e099d5b08286bd775cba6c1de8fe893..05cb6cb3900731b10325efdd85564b7da9cdeeba 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -602,10 +602,14 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
ResolvedAst resolvedAst = astElement.resolvedAst;
localsHandler.closureData = newClosureData;
if (resolvedAst.kind == ResolvedAstKind.PARSED) {
- localsHandler.enterScope(
- newClosureData.capturingScopes[resolvedAst.node],
- forGenerativeConstructorBody:
- astElement.isGenerativeConstructorBody);
+ // TODO(efortuna): Take out the test below for null once we are no
+ // longer dealing with the ClosureClassMap interface directly.
+ if (newClosureData.capturingScopes[resolvedAst.node] != null) {
+ localsHandler.enterScope(
+ newClosureData.capturingScopes[resolvedAst.node],
+ forGenerativeConstructorBody:
+ astElement.isGenerativeConstructorBody);
+ }
}
}
inlinedFrom(astElement, () {
@@ -896,7 +900,13 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
}
loopHandler.handleLoop(
- forStatement, buildInitializer, buildCondition, buildUpdate, buildBody);
+ forStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(forStatement)),
+ buildInitializer,
+ buildCondition,
+ buildUpdate,
+ buildBody);
}
@override
@@ -1018,8 +1028,14 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
localsHandler.updateLocal(indexVariable, addInstruction);
}
- loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition,
- buildUpdate, buildBody);
+ loopHandler.handleLoop(
+ forInStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(forInStatement)),
+ buildInitializer,
+ buildCondition,
+ buildUpdate,
+ buildBody);
}
_buildForInIterator(ir.ForInStatement forInStatement) {
@@ -1064,7 +1080,13 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
}
loopHandler.handleLoop(
- forInStatement, buildInitializer, buildCondition, () {}, buildBody);
+ forInStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(forInStatement)),
+ buildInitializer,
+ buildCondition,
+ () {},
+ buildBody);
}
void _buildAsyncForIn(ir.ForInStatement forInStatement) {
@@ -1104,8 +1126,14 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
// Creates a synthetic try/finally block in case anything async goes amiss.
TryCatchFinallyBuilder tryBuilder = new TryCatchFinallyBuilder(this);
// Build fake try body:
- loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition,
- buildUpdate, buildBody);
+ loopHandler.handleLoop(
+ forInStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(forInStatement)),
+ buildInitializer,
+ buildCondition,
+ buildUpdate,
+ buildBody);
void finalizerFunction() {
_pushDynamicInvocation(forInStatement, null, [streamIterator],
@@ -1149,7 +1177,13 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
return popBoolified();
}
- loopHandler.handleLoop(whileStatement, () {}, buildCondition, () {}, () {
+ loopHandler.handleLoop(
+ whileStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(whileStatement)),
+ () {},
+ buildCondition,
+ () {}, () {
whileStatement.body.accept(this);
});
}
@@ -1159,7 +1193,9 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
// TODO(efortuna): I think this can be rewritten using
// LoopHandler.handleLoop with some tricks about when the "update" happens.
LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
- localsHandler.startLoop(astAdapter.getNode(doStatement));
+ var loopClosureInfo = closureToClassMapper
+ .getClosureRepresentationInfoForLoop(astAdapter.getNode(doStatement));
+ localsHandler.startLoop(loopClosureInfo);
JumpHandler jumpHandler = loopHandler.beginLoopHeader(doStatement);
HLoopInformation loopInfo = current.loopInformation;
HBasicBlock loopEntryBlock = current;
@@ -1176,7 +1212,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
// Using a separate block is just a simple workaround.
bodyEntryBlock = openNewBlock();
}
- localsHandler.enterLoopBody(astAdapter.getNode(doStatement));
+ localsHandler.enterLoopBody(loopClosureInfo);
doStatement.body.accept(this);
// If there are no continues we could avoid the creation of the condition
@@ -1677,7 +1713,13 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
void buildLoop() {
loopHandler.handleLoop(
- switchStatement, () {}, buildCondition, () {}, buildSwitch);
+ switchStatement,
+ closureToClassMapper.getClosureRepresentationInfoForLoop(
+ astAdapter.getNode(switchStatement)),
+ () {},
+ buildCondition,
+ () {},
+ buildSwitch);
}
if (hasDefault) {
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698