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 0c48c62aa12213f45f47c9138b9cd4bb01970d46..340d3f031f2ee947534820d32495215106f8f715 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -86,7 +86,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
SourceInformationBuilder sourceInformationBuilder; |
final KernelToElementMap _elementMap; |
final KernelToTypeInferenceMap _typeInferenceMap; |
- final KernelToLocalsMap _localsMap; |
+ final KernelToLocalsMap localsMap; |
LoopHandler<ir.Node> loopHandler; |
TypeBuilder typeBuilder; |
@@ -104,7 +104,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
this.compiler, |
this._elementMap, |
this._typeInferenceMap, |
- this._localsMap, |
+ this.localsMap, |
this.closedWorld, |
this._worldBuilder, |
this.registry, |
@@ -130,7 +130,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
CommonElements get _commonElements => _elementMap.commonElements; |
HGraph build() { |
- return reporter.withCurrentElement(_localsMap.currentMember, () { |
+ return reporter.withCurrentElement(localsMap.currentMember, () { |
// TODO(het): no reason to do this here... |
HInstruction.idCounter = 0; |
if (target is ir.Procedure) { |
@@ -324,7 +324,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
closureToClassMapper.getMemberMap(constructorElement); |
void handleParameter(ir.VariableDeclaration node) { |
- Local parameter = _localsMap.getLocal(node); |
+ Local parameter = localsMap.getLocal(node); |
// If [parameter] is boxed, it will be a field in the box passed as the |
// last parameter. So no need to directly pass it. |
if (!localsHandler.isBoxed(parameter)) { |
@@ -390,12 +390,12 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
// sourceInformationBuilder = |
// sourceInformationBuilder.forContext(resolvedAst); |
- _localsMap.enterInlinedMember(inlinedTarget); |
+ localsMap.enterInlinedMember(inlinedTarget); |
_targetStack.add(inlinedTarget); |
var result = f(); |
sourceInformationBuilder = oldSourceInformationBuilder; |
_targetStack.removeLast(); |
- _localsMap.leaveInlinedMember(inlinedTarget); |
+ localsMap.leaveInlinedMember(inlinedTarget); |
return result; |
}); |
} |
@@ -428,7 +428,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
ir.Constructor constructor, |
List<ir.Constructor> constructorChain, |
Map<FieldEntity, HInstruction> fieldValues) { |
- assert(_elementMap.getConstructor(constructor) == _localsMap.currentMember); |
+ assert(_elementMap.getConstructor(constructor) == localsMap.currentMember); |
constructorChain.add(constructor); |
var foundSuperOrRedirectCall = false; |
@@ -580,7 +580,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
ir.Constructor caller) { |
var index = 0; |
void handleParameter(ir.VariableDeclaration node) { |
- Local parameter = _localsMap.getLocal(node); |
+ Local parameter = localsMap.getLocal(node); |
HInstruction argument = arguments[index++]; |
// Because we are inlining the initializer, we must update |
// what was given as parameter. This will be used in case |
@@ -680,7 +680,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
Map<Local, TypeMask> parameterMap = <Local, TypeMask>{}; |
if (function != null) { |
void handleParameter(ir.VariableDeclaration node) { |
- Local local = _localsMap.getLocal(node); |
+ Local local = localsMap.getLocal(node); |
parameterMap[local] = |
_typeInferenceMap.getInferredTypeOfParameter(local); |
} |
@@ -994,7 +994,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
HInstruction value = new HIndex(array, index, null, type); |
add(value); |
- Local loopVariableLocal = _localsMap.getLocal(forInStatement.variable); |
+ Local loopVariableLocal = localsMap.getLocal(forInStatement.variable); |
localsHandler.updateLocal(loopVariableLocal, value); |
// Hint to name loop value after name of loop variable. |
if (loopVariableLocal is! SyntheticLocal) { |
@@ -1055,7 +1055,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
TypeMask mask = _typeInferenceMap.typeOfIteratorCurrent(forInStatement); |
_pushDynamicInvocation(forInStatement, mask, [iterator], |
selector: Selectors.current); |
- Local loopVariableLocal = _localsMap.getLocal(forInStatement.variable); |
+ Local loopVariableLocal = localsMap.getLocal(forInStatement.variable); |
HInstruction value = pop(); |
localsHandler.updateLocal(loopVariableLocal, value); |
// Hint to name loop value after name of loop variable. |
@@ -1097,7 +1097,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
_pushDynamicInvocation(forInStatement, mask, [streamIterator], |
selector: Selectors.current); |
localsHandler.updateLocal( |
- _localsMap.getLocal(forInStatement.variable), pop()); |
+ localsMap.getLocal(forInStatement.variable), pop()); |
forInStatement.body.accept(this); |
} |
@@ -1161,12 +1161,14 @@ 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)); |
+ ClosureScope scopeData = localsMap.getClosureScopeForLoop( |
+ localsHandler.closureData, doStatement); |
+ localsHandler.startLoop(scopeData); |
JumpHandler jumpHandler = loopHandler.beginLoopHeader(doStatement); |
HLoopInformation loopInfo = current.loopInformation; |
HBasicBlock loopEntryBlock = current; |
HBasicBlock bodyEntryBlock = current; |
- JumpTarget target = _localsMap.getJumpTarget(doStatement); |
+ JumpTarget target = localsMap.getJumpTarget(doStatement); |
bool hasContinues = target != null && target.isContinueTarget; |
if (hasContinues) { |
// Add extra block to hang labels on. |
@@ -1178,7 +1180,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(scopeData); |
doStatement.body.accept(this); |
// If there are no continues we could avoid the creation of the condition |
@@ -1278,7 +1280,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
// Since the body of the loop has a break, we attach a synthesized label |
// to the body. |
SubGraph bodyGraph = new SubGraph(bodyEntryBlock, bodyExitBlock); |
- JumpTarget target = _localsMap.getJumpTarget(doStatement); |
+ JumpTarget target = localsMap.getJumpTarget(doStatement); |
LabelDefinition label = target.addLabel(null, 'loop'); |
label.setBreakTarget(); |
HLabeledBlockInformation info = new HLabeledBlockInformation( |
@@ -1403,14 +1405,14 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
/// to distinguish the synthesized loop created for a switch statement with |
/// continue statements from simple switch statements. |
JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump: false}) { |
- JumpTarget target = _localsMap.getJumpTarget(node); |
+ JumpTarget target = localsMap.getJumpTarget(node); |
assert(target is KernelJumpTarget); |
if (target == null) { |
// No breaks or continues to this node. |
return new NullJumpHandler(reporter); |
} |
if (isLoopJump && node is ir.SwitchStatement) { |
- return new KernelSwitchCaseJumpHandler(this, target, node, _localsMap); |
+ return new KernelSwitchCaseJumpHandler(this, target, node, localsMap); |
} |
return new JumpHandler(this, target); |
@@ -1420,7 +1422,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
void visitBreakStatement(ir.BreakStatement breakStatement) { |
assert(!isAborted()); |
handleInTryStatement(); |
- JumpTarget target = _localsMap.getJumpTarget(breakStatement.target); |
+ JumpTarget target = localsMap.getJumpTarget(breakStatement.target); |
assert(target != null); |
JumpHandler handler = jumpTargets[target]; |
assert(handler != null); |
@@ -1493,7 +1495,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
void visitContinueSwitchStatement( |
ir.ContinueSwitchStatement switchStatement) { |
handleInTryStatement(); |
- JumpTarget target = _localsMap.getJumpTarget(switchStatement.target); |
+ JumpTarget target = localsMap.getJumpTarget(switchStatement.target); |
assert(target != null); |
JumpHandler handler = jumpTargets[target]; |
assert(handler != null); |
@@ -1613,7 +1615,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
// This is because JS does not have this same "continue label" semantics so |
// we encode it in the form of a state machine. |
- JumpTarget switchTarget = _localsMap.getJumpTarget(switchStatement); |
+ JumpTarget switchTarget = localsMap.getJumpTarget(switchStatement); |
localsHandler.updateLocal(switchTarget, graph.addConstantNull(closedWorld)); |
var switchCases = switchStatement.cases; |
@@ -2085,7 +2087,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
return; |
} |
- Local local = _localsMap.getLocal(variableGet.variable); |
+ Local local = localsMap.getLocal(variableGet.variable); |
stack.add(localsHandler.readLocal(local)); |
} |
@@ -2133,7 +2135,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
@override |
void visitVariableDeclaration(ir.VariableDeclaration declaration) { |
- Local local = _localsMap.getLocal(declaration); |
+ Local local = localsMap.getLocal(declaration); |
if (declaration.initializer == null) { |
HInstruction initialValue = graph.addConstantNull(closedWorld); |
localsHandler.updateLocal(local, initialValue); |
@@ -2149,7 +2151,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
} |
void _visitLocalSetter(ir.VariableDeclaration variable, HInstruction value) { |
- Local local = _localsMap.getLocal(variable); |
+ Local local = localsMap.getLocal(variable); |
// Give the value a name if it doesn't have one already. |
if (value.sourceElement == null) { |
@@ -3374,7 +3376,7 @@ class TryCatchFinallyBuilder { |
catchesIndex++; |
if (catchBlock.exception != null) { |
LocalVariableElement exceptionVariable = |
- kernelBuilder._localsMap.getLocal(catchBlock.exception); |
+ kernelBuilder.localsMap.getLocal(catchBlock.exception); |
kernelBuilder.localsHandler |
.updateLocal(exceptionVariable, unwrappedException); |
} |
@@ -3386,7 +3388,7 @@ class TryCatchFinallyBuilder { |
kernelBuilder._commonElements.traceFromException)); |
HInstruction traceInstruction = kernelBuilder.pop(); |
LocalVariableElement traceVariable = |
- kernelBuilder._localsMap.getLocal(catchBlock.stackTrace); |
+ kernelBuilder.localsMap.getLocal(catchBlock.stackTrace); |
kernelBuilder.localsHandler |
.updateLocal(traceVariable, traceInstruction); |
} |