| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 class SsaBuilderTask extends CompilerTask { | 134 class SsaBuilderTask extends CompilerTask { |
| 135 final Interceptors interceptors; | 135 final Interceptors interceptors; |
| 136 final CodeEmitterTask emitter; | 136 final CodeEmitterTask emitter; |
| 137 // Loop tracking information. | 137 // Loop tracking information. |
| 138 final Set<FunctionElement> functionsCalledInLoop; | 138 final Set<FunctionElement> functionsCalledInLoop; |
| 139 final Map<SourceString, Selector> selectorsCalledInLoop; | 139 final Map<SourceString, Selector> selectorsCalledInLoop; |
| 140 final JavaScriptBackend backend; | 140 final JavaScriptBackend backend; |
| 141 | 141 |
| 142 String get name() => 'SSA builder'; | 142 String get name => 'SSA builder'; |
| 143 | 143 |
| 144 SsaBuilderTask(JavaScriptBackend backend) | 144 SsaBuilderTask(JavaScriptBackend backend) |
| 145 : interceptors = new Interceptors(backend.compiler), | 145 : interceptors = new Interceptors(backend.compiler), |
| 146 emitter = backend.emitter, | 146 emitter = backend.emitter, |
| 147 functionsCalledInLoop = new Set<FunctionElement>(), | 147 functionsCalledInLoop = new Set<FunctionElement>(), |
| 148 selectorsCalledInLoop = new Map<SourceString, Selector>(), | 148 selectorsCalledInLoop = new Map<SourceString, Selector>(), |
| 149 backend = backend, | 149 backend = backend, |
| 150 super(backend.compiler); | 150 super(backend.compiler); |
| 151 | 151 |
| 152 HGraph build(WorkItem work) { | 152 HGraph build(WorkItem work) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 */ | 223 */ |
| 224 Map<Element, HInstruction> directLocals; | 224 Map<Element, HInstruction> directLocals; |
| 225 Map<Element, Element> redirectionMapping; | 225 Map<Element, Element> redirectionMapping; |
| 226 SsaBuilder builder; | 226 SsaBuilder builder; |
| 227 ClosureClassMap closureData; | 227 ClosureClassMap closureData; |
| 228 | 228 |
| 229 LocalsHandler(this.builder) | 229 LocalsHandler(this.builder) |
| 230 : directLocals = new Map<Element, HInstruction>(), | 230 : directLocals = new Map<Element, HInstruction>(), |
| 231 redirectionMapping = new Map<Element, Element>(); | 231 redirectionMapping = new Map<Element, Element>(); |
| 232 | 232 |
| 233 get typesTask() => builder.compiler.typesTask; | 233 get typesTask => builder.compiler.typesTask; |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * Creates a new [LocalsHandler] based on [other]. We only need to | 236 * Creates a new [LocalsHandler] based on [other]. We only need to |
| 237 * copy the [directLocals], since the other fields can be shared | 237 * copy the [directLocals], since the other fields can be shared |
| 238 * throughout the AST visit. | 238 * throughout the AST visit. |
| 239 */ | 239 */ |
| 240 LocalsHandler.from(LocalsHandler other) | 240 LocalsHandler.from(LocalsHandler other) |
| 241 : directLocals = new Map<Element, HInstruction>.from(other.directLocals), | 241 : directLocals = new Map<Element, HInstruction>.from(other.directLocals), |
| 242 redirectionMapping = other.redirectionMapping, | 242 redirectionMapping = other.redirectionMapping, |
| 243 builder = other.builder, | 243 builder = other.builder, |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 List<HInstruction> stack; | 816 List<HInstruction> stack; |
| 817 | 817 |
| 818 // The current block to add instructions to. Might be null, if we are | 818 // The current block to add instructions to. Might be null, if we are |
| 819 // visiting dead code. | 819 // visiting dead code. |
| 820 HBasicBlock current; | 820 HBasicBlock current; |
| 821 // The most recently opened block. Has the same value as [current] while | 821 // The most recently opened block. Has the same value as [current] while |
| 822 // the block is open, but unlike [current], it isn't cleared when the current | 822 // the block is open, but unlike [current], it isn't cleared when the current |
| 823 // block is closed. | 823 // block is closed. |
| 824 HBasicBlock lastOpenedBlock; | 824 HBasicBlock lastOpenedBlock; |
| 825 | 825 |
| 826 LibraryElement get currentLibrary() => work.element.getLibrary(); | 826 LibraryElement get currentLibrary => work.element.getLibrary(); |
| 827 Compiler get compiler() => builder.compiler; | 827 Compiler get compiler => builder.compiler; |
| 828 CodeEmitterTask get emitter() => builder.emitter; | 828 CodeEmitterTask get emitter => builder.emitter; |
| 829 | 829 |
| 830 SsaBuilder(SsaBuilderTask builder, WorkItem work) | 830 SsaBuilder(SsaBuilderTask builder, WorkItem work) |
| 831 : this.builder = builder, | 831 : this.builder = builder, |
| 832 this.work = work, | 832 this.work = work, |
| 833 interceptors = builder.interceptors, | 833 interceptors = builder.interceptors, |
| 834 methodInterceptionEnabled = true, | 834 methodInterceptionEnabled = true, |
| 835 graph = new HGraph(), | 835 graph = new HGraph(), |
| 836 stack = new List<HInstruction>(), | 836 stack = new List<HInstruction>(), |
| 837 activationVariables = new Map<Element, HLocalValue>(), | 837 activationVariables = new Map<Element, HLocalValue>(), |
| 838 jumpTargets = new Map<TargetElement, JumpHandler>(), | 838 jumpTargets = new Map<TargetElement, JumpHandler>(), |
| (...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3431 | 3431 |
| 3432 SsaBranch(this.branchBuilder) : block = new HBasicBlock(); | 3432 SsaBranch(this.branchBuilder) : block = new HBasicBlock(); |
| 3433 } | 3433 } |
| 3434 | 3434 |
| 3435 class SsaBranchBuilder { | 3435 class SsaBranchBuilder { |
| 3436 final SsaBuilder builder; | 3436 final SsaBuilder builder; |
| 3437 final Node diagnosticNode; | 3437 final Node diagnosticNode; |
| 3438 | 3438 |
| 3439 SsaBranchBuilder(this.builder, [this.diagnosticNode]); | 3439 SsaBranchBuilder(this.builder, [this.diagnosticNode]); |
| 3440 | 3440 |
| 3441 Compiler get compiler() => builder.compiler; | 3441 Compiler get compiler => builder.compiler; |
| 3442 | 3442 |
| 3443 void checkNotAborted() { | 3443 void checkNotAborted() { |
| 3444 if (builder.isAborted()) { | 3444 if (builder.isAborted()) { |
| 3445 compiler.unimplemented("aborted control flow", node: diagnosticNode); | 3445 compiler.unimplemented("aborted control flow", node: diagnosticNode); |
| 3446 } | 3446 } |
| 3447 } | 3447 } |
| 3448 | 3448 |
| 3449 void buildCondition(void visitCondition(), | 3449 void buildCondition(void visitCondition(), |
| 3450 SsaBranch conditionBranch, | 3450 SsaBranch conditionBranch, |
| 3451 SsaBranch thenBranch, | 3451 SsaBranch thenBranch, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 new HSubGraphBlockInformation(elseBranch.graph)); | 3647 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3648 | 3648 |
| 3649 HBasicBlock conditionStartBlock = conditionBranch.block; | 3649 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3650 conditionStartBlock.setBlockFlow(info, joinBlock); | 3650 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3651 SubGraph conditionGraph = conditionBranch.graph; | 3651 SubGraph conditionGraph = conditionBranch.graph; |
| 3652 HIf branch = conditionGraph.end.last; | 3652 HIf branch = conditionGraph.end.last; |
| 3653 assert(branch is HIf); | 3653 assert(branch is HIf); |
| 3654 branch.blockInformation = conditionStartBlock.blockFlow; | 3654 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3655 } | 3655 } |
| 3656 } | 3656 } |
| OLD | NEW |