Chromium Code Reviews| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 class SsaBuilderTask extends CompilerTask { | 134 class SsaBuilderTask extends CompilerTask { |
| 135 final Interceptors interceptors; | 135 final Interceptors interceptors; |
| 136 final Map<Node, ClosureData> closureDataCache; | 136 final Map<Node, ClosureData> closureDataCache; |
| 137 final CodeEmitterTask emitter; | 137 final CodeEmitterTask emitter; |
| 138 // Loop tracking information. | 138 // Loop tracking information. |
| 139 final Set<FunctionElement> functionsCalledInLoop; | 139 final Set<FunctionElement> functionsCalledInLoop; |
| 140 final Map<SourceString, Selector> selectorsCalledInLoop; | 140 final Map<SourceString, Selector> selectorsCalledInLoop; |
| 141 final JavaScriptBackend backend; | |
|
Lasse Reichstein Nielsen
2012/08/08 07:44:53
Is this used?
floitsch
2012/08/08 19:18:37
Done.
| |
| 141 | 142 |
| 142 String get name() => 'SSA builder'; | 143 String get name() => 'SSA builder'; |
| 143 | 144 |
| 144 SsaBuilderTask(JavaScriptBackend backend) | 145 SsaBuilderTask(JavaScriptBackend backend) |
| 145 : interceptors = new Interceptors(backend.compiler), | 146 : interceptors = new Interceptors(backend.compiler), |
| 146 closureDataCache = new HashMap<Node, ClosureData>(), | 147 closureDataCache = new HashMap<Node, ClosureData>(), |
| 147 emitter = backend.emitter, | 148 emitter = backend.emitter, |
| 148 functionsCalledInLoop = new Set<FunctionElement>(), | 149 functionsCalledInLoop = new Set<FunctionElement>(), |
| 149 selectorsCalledInLoop = new Map<SourceString, Selector>(), | 150 selectorsCalledInLoop = new Map<SourceString, Selector>(), |
| 151 this.backend = backend, | |
| 150 super(backend.compiler); | 152 super(backend.compiler); |
| 151 | 153 |
| 152 HGraph build(WorkItem work) { | 154 HGraph build(JavaScriptWorkItem work) { |
| 153 return measure(() { | 155 return measure(() { |
| 154 FunctionElement element = work.element; | 156 FunctionElement element = work.element; |
| 155 HInstruction.idCounter = 0; | 157 HInstruction.idCounter = 0; |
| 156 SsaBuilder builder = new SsaBuilder(this, work); | 158 SsaBuilder builder = new SsaBuilder(this, work); |
| 157 HGraph graph; | 159 HGraph graph; |
| 158 ElementKind kind = element.kind; | 160 ElementKind kind = element.kind; |
| 159 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR) { | 161 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 160 graph = compileConstructor(builder, work); | 162 graph = compileConstructor(builder, work); |
| 161 } else if (kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY || | 163 } else if (kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY || |
| 162 kind === ElementKind.FUNCTION || | 164 kind === ElementKind.FUNCTION || |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 177 element.enclosingElement.kind == ElementKind.CLASS) { | 179 element.enclosingElement.kind == ElementKind.CLASS) { |
| 178 String className = element.enclosingElement.name.slowToString(); | 180 String className = element.enclosingElement.name.slowToString(); |
| 179 String memberName = element.name.slowToString(); | 181 String memberName = element.name.slowToString(); |
| 180 name = "$className.$memberName"; | 182 name = "$className.$memberName"; |
| 181 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { | 183 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
| 182 name = "$name (body)"; | 184 name = "$name (body)"; |
| 183 } | 185 } |
| 184 } else { | 186 } else { |
| 185 name = "${element.name.slowToString()}"; | 187 name = "${element.name.slowToString()}"; |
| 186 } | 188 } |
| 187 compiler.tracer.traceCompilation(name); | 189 compiler.tracer.traceCompilation(name, work); |
| 188 compiler.tracer.traceGraph('builder', graph); | 190 compiler.tracer.traceGraph('builder', graph); |
| 189 } | 191 } |
| 190 return graph; | 192 return graph; |
| 191 }); | 193 }); |
| 192 } | 194 } |
| 193 | 195 |
| 194 HGraph compileConstructor(SsaBuilder builder, WorkItem work) { | 196 HGraph compileConstructor(SsaBuilder builder, WorkItem work) { |
| 195 // The body of the constructor will be generated in a separate function. | 197 // The body of the constructor will be generated in a separate function. |
| 196 final ClassElement classElement = work.element.enclosingElement; | 198 final ClassElement classElement = work.element.enclosingElement; |
| 197 return builder.buildFactory(classElement, work.element); | 199 return builder.buildFactory(classElement, work.element); |
| (...skipping 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3585 new HSubGraphBlockInformation(elseBranch.graph)); | 3587 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3586 | 3588 |
| 3587 HBasicBlock conditionStartBlock = conditionBranch.block; | 3589 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3588 conditionStartBlock.setBlockFlow(info, joinBlock); | 3590 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3589 SubGraph conditionGraph = conditionBranch.graph; | 3591 SubGraph conditionGraph = conditionBranch.graph; |
| 3590 HIf branch = conditionGraph.end.last; | 3592 HIf branch = conditionGraph.end.last; |
| 3591 assert(branch is HIf); | 3593 assert(branch is HIf); |
| 3592 branch.blockInformation = conditionStartBlock.blockFlow; | 3594 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3593 } | 3595 } |
| 3594 } | 3596 } |
| OLD | NEW |