| 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 8431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8442 final bool allowLoops; | 8442 final bool allowLoops; |
| 8443 | 8443 |
| 8444 InlineWeeder(this.maxInliningNodes, | 8444 InlineWeeder(this.maxInliningNodes, |
| 8445 this.useMaxInliningNodes, | 8445 this.useMaxInliningNodes, |
| 8446 this.allowLoops); | 8446 this.allowLoops); |
| 8447 | 8447 |
| 8448 static bool canBeInlined(FunctionElement function, | 8448 static bool canBeInlined(FunctionElement function, |
| 8449 int maxInliningNodes, | 8449 int maxInliningNodes, |
| 8450 bool useMaxInliningNodes, | 8450 bool useMaxInliningNodes, |
| 8451 {bool allowLoops: false}) { | 8451 {bool allowLoops: false}) { |
| 8452 if (function.resolvedAst.elements.containsTryStatement) return false; |
| 8453 |
| 8452 InlineWeeder weeder = | 8454 InlineWeeder weeder = |
| 8453 new InlineWeeder(maxInliningNodes, useMaxInliningNodes, allowLoops); | 8455 new InlineWeeder(maxInliningNodes, useMaxInliningNodes, allowLoops); |
| 8454 ast.FunctionExpression functionExpression = function.node; | 8456 ast.FunctionExpression functionExpression = function.node; |
| 8455 weeder.visit(functionExpression.initializers); | 8457 weeder.visit(functionExpression.initializers); |
| 8456 weeder.visit(functionExpression.body); | 8458 weeder.visit(functionExpression.body); |
| 8457 weeder.visit(functionExpression.asyncModifier); | 8459 weeder.visit(functionExpression.asyncModifier); |
| 8458 return !weeder.tooDifficult; | 8460 return !weeder.tooDifficult; |
| 8459 } | 8461 } |
| 8460 | 8462 |
| 8461 bool registerNode() { | 8463 bool registerNode() { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8524 if (!registerNode()) return; | 8526 if (!registerNode()) return; |
| 8525 if (seenReturn | 8527 if (seenReturn |
| 8526 || identical(node.beginToken.stringValue, 'native')) { | 8528 || identical(node.beginToken.stringValue, 'native')) { |
| 8527 tooDifficult = true; | 8529 tooDifficult = true; |
| 8528 return; | 8530 return; |
| 8529 } | 8531 } |
| 8530 node.visitChildren(this); | 8532 node.visitChildren(this); |
| 8531 seenReturn = true; | 8533 seenReturn = true; |
| 8532 } | 8534 } |
| 8533 | 8535 |
| 8534 void visitTryStatement(ast.Node node) { | |
| 8535 if (!registerNode()) return; | |
| 8536 tooDifficult = true; | |
| 8537 } | |
| 8538 | |
| 8539 void visitThrow(ast.Throw node) { | 8536 void visitThrow(ast.Throw node) { |
| 8540 if (!registerNode()) return; | 8537 if (!registerNode()) return; |
| 8541 // For now, we don't want to handle throw after a return even if | 8538 // For now, we don't want to handle throw after a return even if |
| 8542 // it is in an "if". | 8539 // it is in an "if". |
| 8543 if (seenReturn) { | 8540 if (seenReturn) { |
| 8544 tooDifficult = true; | 8541 tooDifficult = true; |
| 8545 } else { | 8542 } else { |
| 8546 node.visitChildren(this); | 8543 node.visitChildren(this); |
| 8547 } | 8544 } |
| 8548 } | 8545 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8926 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8923 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 8927 unaliased.accept(this, builder); | 8924 unaliased.accept(this, builder); |
| 8928 } | 8925 } |
| 8929 | 8926 |
| 8930 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8927 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 8931 JavaScriptBackend backend = builder.compiler.backend; | 8928 JavaScriptBackend backend = builder.compiler.backend; |
| 8932 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8929 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 8933 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8930 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 8934 } | 8931 } |
| 8935 } | 8932 } |
| OLD | NEW |