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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 visitThen: () { | 1616 visitThen: () { |
1617 closeAndGotoExit(new HReturn( | 1617 closeAndGotoExit(new HReturn( |
1618 graph.addConstantBool(false, compiler), | 1618 graph.addConstantBool(false, compiler), |
1619 sourceInformationBuilder | 1619 sourceInformationBuilder |
1620 .buildImplicitReturn(functionElement))); | 1620 .buildImplicitReturn(functionElement))); |
1621 }, | 1621 }, |
1622 visitElse: null, | 1622 visitElse: null, |
1623 sourceInformation: sourceInformationBuilder.buildIf(function.body)); | 1623 sourceInformation: sourceInformationBuilder.buildIf(function.body)); |
1624 } | 1624 } |
1625 } | 1625 } |
| 1626 if (const bool.fromEnvironment('unreachable-throw') == true) { |
| 1627 var emptyParameters = parameters.values.where((p) => |
| 1628 p.instructionType.isEmpty && !p.instructionType.isNullable); |
| 1629 if (emptyParameters.length > 0) { |
| 1630 String message = compiler.enableMinification |
| 1631 ? 'unreachable' |
| 1632 : 'unreachable: ${functionElement} because: ${emptyParameters}'; |
| 1633 // TODO(sra): Use a library function that throws a proper error object. |
| 1634 push(new HForeignCode( |
| 1635 js.js.parseForeignJS('throw "$message"'), |
| 1636 backend.dynamicType, |
| 1637 <HInstruction>[], |
| 1638 isStatement: true)); |
| 1639 return closeFunction(); |
| 1640 } |
| 1641 } |
1626 function.body.accept(this); | 1642 function.body.accept(this); |
1627 return closeFunction(); | 1643 return closeFunction(); |
1628 } | 1644 } |
1629 | 1645 |
1630 HGraph buildCheckedSetter(VariableElement field) { | 1646 HGraph buildCheckedSetter(VariableElement field) { |
1631 openFunction(field, field.node); | 1647 openFunction(field, field.node); |
1632 HInstruction thisInstruction = localsHandler.readThis(); | 1648 HInstruction thisInstruction = localsHandler.readThis(); |
1633 // Use dynamic type because the type computed by the inferrer is | 1649 // Use dynamic type because the type computed by the inferrer is |
1634 // narrowed to the type annotation. | 1650 // narrowed to the type annotation. |
1635 HInstruction parameter = new HParameterValue(field, backend.dynamicType); | 1651 HInstruction parameter = new HParameterValue(field, backend.dynamicType); |
(...skipping 7290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8926 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8942 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8927 unaliased.accept(this, builder); | 8943 unaliased.accept(this, builder); |
8928 } | 8944 } |
8929 | 8945 |
8930 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8946 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8931 JavaScriptBackend backend = builder.compiler.backend; | 8947 JavaScriptBackend backend = builder.compiler.backend; |
8932 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8948 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8933 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8949 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8934 } | 8950 } |
8935 } | 8951 } |
OLD | NEW |