| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
| 8 final SsaCodeGeneratorTask generator; | 8 final SsaCodeGeneratorTask generator; |
| 9 final SsaBuilderTask builder; | 9 final SsaBuilderTask builder; |
| 10 final SsaOptimizerTask optimizer; | 10 final SsaOptimizerTask optimizer; |
| (...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2600 void visit(ast.Node node) { | 2600 void visit(ast.Node node) { |
| 2601 if (node != null) node.accept(this); | 2601 if (node != null) node.accept(this); |
| 2602 } | 2602 } |
| 2603 | 2603 |
| 2604 /// Visit [node] and pop the resulting [HInstruction]. | 2604 /// Visit [node] and pop the resulting [HInstruction]. |
| 2605 HInstruction visitAndPop(ast.Node node) { | 2605 HInstruction visitAndPop(ast.Node node) { |
| 2606 node.accept(this); | 2606 node.accept(this); |
| 2607 return pop(); | 2607 return pop(); |
| 2608 } | 2608 } |
| 2609 | 2609 |
| 2610 visitAssert(ast.Assert node) { |
| 2611 if (!compiler.enableTypeAssertions) return; |
| 2612 |
| 2613 if (!node.hasMessage) { |
| 2614 visit(node.condition); |
| 2615 pushInvokeStatic(node, backend.assertHelperMethod, [pop()]); |
| 2616 pop(); |
| 2617 return; |
| 2618 } |
| 2619 // Assert had message. |
| 2620 void buildCondition() { |
| 2621 visit(node.condition); |
| 2622 pushInvokeStatic(node, backend.assertTestMethod, [pop()]); |
| 2623 } |
| 2624 void fail() { |
| 2625 visit(node.message); |
| 2626 pushInvokeStatic(node, backend.assertThrowMethod, [pop()]); |
| 2627 pop(); |
| 2628 } |
| 2629 handleIf(node, |
| 2630 visitCondition: buildCondition, |
| 2631 visitThen: fail); |
| 2632 } |
| 2633 |
| 2610 visitBlock(ast.Block node) { | 2634 visitBlock(ast.Block node) { |
| 2611 assert(!isAborted()); | 2635 assert(!isAborted()); |
| 2612 if (!isReachable) return; // This can only happen when inlining. | 2636 if (!isReachable) return; // This can only happen when inlining. |
| 2613 for (Link<ast.Node> link = node.statements.nodes; | 2637 for (Link<ast.Node> link = node.statements.nodes; |
| 2614 !link.isEmpty; | 2638 !link.isEmpty; |
| 2615 link = link.tail) { | 2639 link = link.tail) { |
| 2616 visit(link.head); | 2640 visit(link.head); |
| 2617 if (!isReachable) { | 2641 if (!isReachable) { |
| 2618 // The block has been aborted by a return or a throw. | 2642 // The block has been aborted by a return or a throw. |
| 2619 if (!stack.isEmpty) { | 2643 if (!stack.isEmpty) { |
| (...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5175 DartType instance = type.asInstanceOf(supertype.element); | 5199 DartType instance = type.asInstanceOf(supertype.element); |
| 5176 compiler.types.checkTypeVariableBounds(instance, | 5200 compiler.types.checkTypeVariableBounds(instance, |
| 5177 addTypeVariableBoundCheck); | 5201 addTypeVariableBoundCheck); |
| 5178 if (definitelyFails) { | 5202 if (definitelyFails) { |
| 5179 return true; | 5203 return true; |
| 5180 } | 5204 } |
| 5181 } | 5205 } |
| 5182 return false; | 5206 return false; |
| 5183 } | 5207 } |
| 5184 | 5208 |
| 5185 @override | |
| 5186 visitAssert(ast.Send node, ast.Node expression, _) { | |
| 5187 if (!compiler.enableUserAssertions) { | |
| 5188 stack.add(graph.addConstantNull(compiler)); | |
| 5189 return; | |
| 5190 } | |
| 5191 assert(invariant(node, node.arguments.tail.isEmpty, | |
| 5192 message: "Invalid assertion: $node")); | |
| 5193 generateStaticFunctionInvoke( | |
| 5194 node, backend.assertMethod, CallStructure.ONE_ARG); | |
| 5195 } | |
| 5196 | |
| 5197 visitStaticSend(ast.Send node) { | 5209 visitStaticSend(ast.Send node) { |
| 5198 internalError(node, "Unexpected visitStaticSend"); | 5210 internalError(node, "Unexpected visitStaticSend"); |
| 5199 } | 5211 } |
| 5200 | 5212 |
| 5201 /// Generate an invocation to the static or top level [function]. | 5213 /// Generate an invocation to the static or top level [function]. |
| 5202 void generateStaticFunctionInvoke( | 5214 void generateStaticFunctionInvoke( |
| 5203 ast.Send node, | 5215 ast.Send node, |
| 5204 FunctionElement function, | 5216 FunctionElement function, |
| 5205 CallStructure callStructure) { | 5217 CallStructure callStructure) { |
| 5206 List<HInstruction> inputs = makeStaticArgumentList( | 5218 List<HInstruction> inputs = makeStaticArgumentList( |
| (...skipping 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8303 void visitConstantInvoke( | 8315 void visitConstantInvoke( |
| 8304 ast.Send node, | 8316 ast.Send node, |
| 8305 ConstantExpression constant, | 8317 ConstantExpression constant, |
| 8306 ast.NodeList arguments, | 8318 ast.NodeList arguments, |
| 8307 CallStructure callStreucture, | 8319 CallStructure callStreucture, |
| 8308 _) { | 8320 _) { |
| 8309 visitNode(node); | 8321 visitNode(node); |
| 8310 } | 8322 } |
| 8311 | 8323 |
| 8312 @override | 8324 @override |
| 8313 void errorInvalidAssert( | |
| 8314 ast.Send node, | |
| 8315 ast.NodeList arguments, | |
| 8316 _) { | |
| 8317 visitNode(node); | |
| 8318 } | |
| 8319 | |
| 8320 @override | |
| 8321 void errorUndefinedBinaryExpression( | 8325 void errorUndefinedBinaryExpression( |
| 8322 ast.Send node, | 8326 ast.Send node, |
| 8323 ast.Node left, | 8327 ast.Node left, |
| 8324 ast.Operator operator, | 8328 ast.Operator operator, |
| 8325 ast.Node right, | 8329 ast.Node right, |
| 8326 _) { | 8330 _) { |
| 8327 visitNode(node); | 8331 visitNode(node); |
| 8328 } | 8332 } |
| 8329 | 8333 |
| 8330 @override | 8334 @override |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8939 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8943 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 8940 unaliased.accept(this, builder); | 8944 unaliased.accept(this, builder); |
| 8941 } | 8945 } |
| 8942 | 8946 |
| 8943 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8947 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 8944 JavaScriptBackend backend = builder.compiler.backend; | 8948 JavaScriptBackend backend = builder.compiler.backend; |
| 8945 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8949 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 8946 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8950 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 8947 } | 8951 } |
| 8948 } | 8952 } |
| OLD | NEW |