Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common/codegen.dart' show CodegenRegistry; | 7 import '../common/codegen.dart' show CodegenRegistry; |
| 8 import '../compiler.dart'; | 8 import '../compiler.dart'; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../elements/resolution_types.dart'; | 10 import '../elements/resolution_types.dart'; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 /// This contains helpers for building the graph and tracking information about | 28 /// This contains helpers for building the graph and tracking information about |
| 29 /// the current state of the graph being built. | 29 /// the current state of the graph being built. |
| 30 abstract class GraphBuilder { | 30 abstract class GraphBuilder { |
| 31 /// Holds the resulting SSA graph. | 31 /// Holds the resulting SSA graph. |
| 32 final HGraph graph = new HGraph(); | 32 final HGraph graph = new HGraph(); |
| 33 | 33 |
| 34 // TODO(het): remove this | 34 // TODO(het): remove this |
| 35 /// A reference to the compiler. | 35 /// A reference to the compiler. |
| 36 Compiler compiler; | 36 Compiler compiler; |
| 37 | 37 |
| 38 /// True if the builder is processing nodes inside a try statement. This is | |
| 39 /// important for unexpected control flow analysis (returns, breaks, etc | |
|
sra1
2017/01/14 03:18:22
I would not call it 'unexpected'.
Perhaps say 'Use
Emily Fortuna
2017/01/17 23:33:09
Good point. Updated.
| |
| 40 /// outside of a try block). | |
| 41 bool inTryStatement = false; | |
| 42 | |
| 38 /// The JavaScript backend we are targeting in this compilation. | 43 /// The JavaScript backend we are targeting in this compilation. |
| 39 JavaScriptBackend get backend; | 44 JavaScriptBackend get backend; |
| 40 | 45 |
| 41 /// The tree elements for the element being built into an SSA graph. | 46 /// The tree elements for the element being built into an SSA graph. |
| 42 TreeElements get elements; | 47 TreeElements get elements; |
| 43 | 48 |
| 44 CodegenRegistry get registry; | 49 CodegenRegistry get registry; |
| 45 | 50 |
| 46 ClosedWorld get closedWorld; | 51 ClosedWorld get closedWorld; |
| 47 | 52 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 HParameterValue result = new HParameterValue(parameter, type); | 178 HParameterValue result = new HParameterValue(parameter, type); |
| 174 if (lastAddedParameter == null) { | 179 if (lastAddedParameter == null) { |
| 175 graph.entry.addBefore(graph.entry.first, result); | 180 graph.entry.addBefore(graph.entry.first, result); |
| 176 } else { | 181 } else { |
| 177 graph.entry.addAfter(lastAddedParameter, result); | 182 graph.entry.addAfter(lastAddedParameter, result); |
| 178 } | 183 } |
| 179 lastAddedParameter = result; | 184 lastAddedParameter = result; |
| 180 return result; | 185 return result; |
| 181 } | 186 } |
| 182 | 187 |
| 183 void handleIf( | |
| 184 {ast.Node node, | |
| 185 void visitCondition(), | |
| 186 void visitThen(), | |
| 187 void visitElse(), | |
| 188 SourceInformation sourceInformation}) { | |
| 189 SsaBranchBuilder branchBuilder = new SsaBranchBuilder(this, compiler, node); | |
| 190 branchBuilder.handleIf(visitCondition, visitThen, visitElse, | |
| 191 sourceInformation: sourceInformation); | |
| 192 } | |
| 193 | |
| 194 HSubGraphBlockInformation wrapStatementGraph(SubGraph statements) { | 188 HSubGraphBlockInformation wrapStatementGraph(SubGraph statements) { |
| 195 if (statements == null) return null; | 189 if (statements == null) return null; |
| 196 return new HSubGraphBlockInformation(statements); | 190 return new HSubGraphBlockInformation(statements); |
| 197 } | 191 } |
| 198 | 192 |
| 199 HSubExpressionBlockInformation wrapExpressionGraph(SubExpression expression) { | 193 HSubExpressionBlockInformation wrapExpressionGraph(SubExpression expression) { |
| 200 if (expression == null) return null; | 194 if (expression == null) return null; |
| 201 return new HSubExpressionBlockInformation(expression); | 195 return new HSubExpressionBlockInformation(expression); |
| 202 } | 196 } |
| 203 | 197 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 230 | 224 |
| 231 HInstruction typeInfo = new HTypeInfoExpression( | 225 HInstruction typeInfo = new HTypeInfoExpression( |
| 232 TypeInfoExpressionKind.INSTANCE, | 226 TypeInfoExpressionKind.INSTANCE, |
| 233 (type.element as ClassElement).thisType, | 227 (type.element as ClassElement).thisType, |
| 234 rtiInputs, | 228 rtiInputs, |
| 235 closedWorld.commonMasks.dynamicType); | 229 closedWorld.commonMasks.dynamicType); |
| 236 add(typeInfo); | 230 add(typeInfo); |
| 237 return callSetRuntimeTypeInfo(typeInfo, newObject); | 231 return callSetRuntimeTypeInfo(typeInfo, newObject); |
| 238 } | 232 } |
| 239 | 233 |
| 234 /// Called when control flow is about to change, in which case we need to | |
| 235 /// specify special successors if we are already in a try/catch/finally block. | |
| 236 void handleInTryStatement() { | |
| 237 if (!inTryStatement) return; | |
| 238 HBasicBlock block = close(new HExitTry()); | |
| 239 HBasicBlock newBlock = graph.addNewBlock(); | |
| 240 block.addSuccessor(newBlock); | |
| 241 open(newBlock); | |
| 242 } | |
| 243 | |
| 240 HInstruction callSetRuntimeTypeInfo( | 244 HInstruction callSetRuntimeTypeInfo( |
| 241 HInstruction typeInfo, HInstruction newObject); | 245 HInstruction typeInfo, HInstruction newObject); |
| 242 | 246 |
| 243 /// The element for which this SSA builder is being used. | 247 /// The element for which this SSA builder is being used. |
| 244 Element get targetElement; | 248 Element get targetElement; |
| 245 TypeBuilder get typeBuilder; | 249 TypeBuilder get typeBuilder; |
| 246 } | 250 } |
| 247 | 251 |
| 248 class ReifiedTypeRepresentationBuilder | 252 class ReifiedTypeRepresentationBuilder |
| 249 implements DartTypeVisitor<dynamic, GraphBuilder> { | 253 implements DartTypeVisitor<dynamic, GraphBuilder> { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type'; | 343 if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type'; |
| 340 unaliased.accept(this, builder); | 344 unaliased.accept(this, builder); |
| 341 } | 345 } |
| 342 | 346 |
| 343 void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) { | 347 void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) { |
| 344 JavaScriptBackend backend = builder.compiler.backend; | 348 JavaScriptBackend backend = builder.compiler.backend; |
| 345 ClassElement cls = backend.helpers.DynamicRuntimeType; | 349 ClassElement cls = backend.helpers.DynamicRuntimeType; |
| 346 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); | 350 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); |
| 347 } | 351 } |
| 348 } | 352 } |
| OLD | NEW |