| 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 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
| 9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
| 10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
| (...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 compiler.boolClass.rawType, | 2439 compiler.boolClass.rawType, |
| 2440 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); | 2440 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); |
| 2441 } | 2441 } |
| 2442 HInstruction result = new HBoolify(value, backend.boolType); | 2442 HInstruction result = new HBoolify(value, backend.boolType); |
| 2443 add(result); | 2443 add(result); |
| 2444 return result; | 2444 return result; |
| 2445 } | 2445 } |
| 2446 | 2446 |
| 2447 HInstruction attachPosition(HInstruction target, ast.Node node) { | 2447 HInstruction attachPosition(HInstruction target, ast.Node node) { |
| 2448 if (generateSourceMap && node != null) { | 2448 if (generateSourceMap && node != null) { |
| 2449 target.sourcePosition = sourceFileLocationForBeginToken(node); | 2449 target.sourceInformation = sourceInformationForBeginToken(node); |
| 2450 } | 2450 } |
| 2451 return target; | 2451 return target; |
| 2452 } | 2452 } |
| 2453 | 2453 |
| 2454 SourceInformation sourceInformationForBeginToken(ast.Node node) { |
| 2455 return new StartEndSourceInformation(sourceFileLocationForBeginToken(node)); |
| 2456 } |
| 2457 |
| 2458 SourceInformation sourceInformationForBeginEndToken(ast.Node node) { |
| 2459 return new StartEndSourceInformation( |
| 2460 sourceFileLocationForBeginToken(node), |
| 2461 sourceFileLocationForEndToken(node)); |
| 2462 } |
| 2463 |
| 2454 SourceFileLocation sourceFileLocationForBeginToken(ast.Node node) => | 2464 SourceFileLocation sourceFileLocationForBeginToken(ast.Node node) => |
| 2455 sourceFileLocationForToken(node, node.getBeginToken()); | 2465 sourceFileLocationForToken(node, node.getBeginToken()); |
| 2456 | 2466 |
| 2457 SourceFileLocation sourceFileLocationForEndToken(ast.Node node) => | 2467 SourceFileLocation sourceFileLocationForEndToken(ast.Node node) => |
| 2458 sourceFileLocationForToken(node, node.getEndToken()); | 2468 sourceFileLocationForToken(node, node.getEndToken()); |
| 2459 | 2469 |
| 2460 SourceFileLocation sourceFileLocationForToken(ast.Node node, Token token) { | 2470 SourceFileLocation sourceFileLocationForToken(ast.Node node, Token token) { |
| 2461 SourceFile sourceFile = currentSourceFile(); | 2471 SourceFile sourceFile = currentSourceFile(); |
| 2462 SourceFileLocation location = | 2472 SourceFileLocation location = |
| 2463 new TokenSourceFileLocation(sourceFile, token, sourceElement.name); | 2473 new TokenSourceFileLocation(sourceFile, token, sourceElement.name); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 conditionBlock.postProcessLoopHeader(); | 2737 conditionBlock.postProcessLoopHeader(); |
| 2728 HLoopBlockInformation info = | 2738 HLoopBlockInformation info = |
| 2729 new HLoopBlockInformation( | 2739 new HLoopBlockInformation( |
| 2730 HLoopBlockInformation.loopType(loop), | 2740 HLoopBlockInformation.loopType(loop), |
| 2731 wrapExpressionGraph(initializerGraph), | 2741 wrapExpressionGraph(initializerGraph), |
| 2732 wrapExpressionGraph(conditionExpression), | 2742 wrapExpressionGraph(conditionExpression), |
| 2733 wrapStatementGraph(bodyGraph), | 2743 wrapStatementGraph(bodyGraph), |
| 2734 wrapExpressionGraph(updateGraph), | 2744 wrapExpressionGraph(updateGraph), |
| 2735 conditionBlock.loopInformation.target, | 2745 conditionBlock.loopInformation.target, |
| 2736 conditionBlock.loopInformation.labels, | 2746 conditionBlock.loopInformation.labels, |
| 2737 sourceFileLocationForBeginToken(loop), | 2747 sourceInformationForBeginEndToken(loop)); |
| 2738 sourceFileLocationForEndToken(loop)); | |
| 2739 | 2748 |
| 2740 startBlock.setBlockFlow(info, current); | 2749 startBlock.setBlockFlow(info, current); |
| 2741 loopInfo.loopBlockInformation = info; | 2750 loopInfo.loopBlockInformation = info; |
| 2742 } else { | 2751 } else { |
| 2743 // The body of the for/while loop always aborts, so there is no back edge. | 2752 // The body of the for/while loop always aborts, so there is no back edge. |
| 2744 // We turn the code into: | 2753 // We turn the code into: |
| 2745 // if (condition) { | 2754 // if (condition) { |
| 2746 // body; | 2755 // body; |
| 2747 // } else { | 2756 // } else { |
| 2748 // // We always create an empty else block to avoid critical edges. | 2757 // // We always create an empty else block to avoid critical edges. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 SubGraph bodyGraph = new SubGraph(loopEntryBlock, bodyExitBlock); | 2954 SubGraph bodyGraph = new SubGraph(loopEntryBlock, bodyExitBlock); |
| 2946 HLoopBlockInformation loopBlockInfo = | 2955 HLoopBlockInformation loopBlockInfo = |
| 2947 new HLoopBlockInformation( | 2956 new HLoopBlockInformation( |
| 2948 HLoopBlockInformation.DO_WHILE_LOOP, | 2957 HLoopBlockInformation.DO_WHILE_LOOP, |
| 2949 null, | 2958 null, |
| 2950 wrapExpressionGraph(conditionExpression), | 2959 wrapExpressionGraph(conditionExpression), |
| 2951 wrapStatementGraph(bodyGraph), | 2960 wrapStatementGraph(bodyGraph), |
| 2952 null, | 2961 null, |
| 2953 loopEntryBlock.loopInformation.target, | 2962 loopEntryBlock.loopInformation.target, |
| 2954 loopEntryBlock.loopInformation.labels, | 2963 loopEntryBlock.loopInformation.labels, |
| 2955 sourceFileLocationForBeginToken(node), | 2964 sourceInformationForBeginEndToken(node)); |
| 2956 sourceFileLocationForEndToken(node)); | |
| 2957 loopEntryBlock.setBlockFlow(loopBlockInfo, current); | 2965 loopEntryBlock.setBlockFlow(loopBlockInfo, current); |
| 2958 loopInfo.loopBlockInformation = loopBlockInfo; | 2966 loopInfo.loopBlockInformation = loopBlockInfo; |
| 2959 } else { | 2967 } else { |
| 2960 // Since the loop has no back edge, we remove the loop information on the | 2968 // Since the loop has no back edge, we remove the loop information on the |
| 2961 // header. | 2969 // header. |
| 2962 loopEntryBlock.loopInformation = null; | 2970 loopEntryBlock.loopInformation = null; |
| 2963 | 2971 |
| 2964 if (jumpHandler.hasAnyBreak()) { | 2972 if (jumpHandler.hasAnyBreak()) { |
| 2965 // Null branchBlock because the body of the do-while loop always aborts, | 2973 // Null branchBlock because the body of the do-while loop always aborts, |
| 2966 // so we never get to the condition. | 2974 // so we never get to the condition. |
| (...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6670 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6678 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 6671 unaliased.accept(this, builder); | 6679 unaliased.accept(this, builder); |
| 6672 } | 6680 } |
| 6673 | 6681 |
| 6674 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 6682 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 6675 JavaScriptBackend backend = builder.compiler.backend; | 6683 JavaScriptBackend backend = builder.compiler.backend; |
| 6676 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 6684 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 6677 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 6685 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 6678 } | 6686 } |
| 6679 } | 6687 } |
| OLD | NEW |