| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 | 9 |
| 10 String generateMethod(WorkItem work, HGraph graph) { | 10 String generateMethod(WorkItem work, HGraph graph) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 final Map<int, String> names; | 120 final Map<int, String> names; |
| 121 final Set<String> usedNames; | 121 final Set<String> usedNames; |
| 122 final Map<String, int> prefixes; | 122 final Map<String, int> prefixes; |
| 123 final Set<HInstruction> generateAtUseSite; | 123 final Set<HInstruction> generateAtUseSite; |
| 124 final Map<HPhi, String> logicalOperations; | 124 final Map<HPhi, String> logicalOperations; |
| 125 final Map<Element, ElementAction> breakAction; | 125 final Map<Element, ElementAction> breakAction; |
| 126 final Map<Element, ElementAction> continueAction; | 126 final Map<Element, ElementAction> continueAction; |
| 127 final Equivalence<HPhi> phiEquivalence; | 127 final Equivalence<HPhi> phiEquivalence; |
| 128 | 128 |
| 129 Element equalsNullElement; | 129 Element equalsNullElement; |
| 130 Element boolifiedEqualsNullElement; | |
| 131 int indent = 0; | 130 int indent = 0; |
| 132 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; | 131 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; |
| 133 HGraph currentGraph; | 132 HGraph currentGraph; |
| 134 /** | 133 /** |
| 135 * Whether the code-generation should try to generate an expression | 134 * Whether the code-generation should try to generate an expression |
| 136 * instead of a sequence of statements. | 135 * instead of a sequence of statements. |
| 137 */ | 136 */ |
| 138 int generationState = STATE_STATEMENT; | 137 int generationState = STATE_STATEMENT; |
| 139 /** | 138 /** |
| 140 * While generating expressions, we can't insert variable declarations. | 139 * While generating expressions, we can't insert variable declarations. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 170 continueAction = new Map<Element, ElementAction>(), | 169 continueAction = new Map<Element, ElementAction>(), |
| 171 phiEquivalence = new Equivalence<HPhi>() { | 170 phiEquivalence = new Equivalence<HPhi>() { |
| 172 | 171 |
| 173 for (final name in parameterNames.getValues()) { | 172 for (final name in parameterNames.getValues()) { |
| 174 prefixes[name] = 0; | 173 prefixes[name] = 0; |
| 175 } | 174 } |
| 176 | 175 |
| 177 // Create a namespace for temporaries. | 176 // Create a namespace for temporaries. |
| 178 prefixes[TEMPORARY_PREFIX] = 0; | 177 prefixes[TEMPORARY_PREFIX] = 0; |
| 179 | 178 |
| 180 Interceptors interceptors = compiler.builder.interceptors; | 179 equalsNullElement = |
| 181 equalsNullElement = interceptors.getEqualsNullInterceptor(); | 180 compiler.builder.interceptors.getEqualsNullInterceptor(); |
| 182 boolifiedEqualsNullElement = | |
| 183 interceptors.getBoolifiedVersionOf(equalsNullElement); | |
| 184 } | 181 } |
| 185 | 182 |
| 186 abstract visitTypeGuard(HTypeGuard node); | 183 abstract visitTypeGuard(HTypeGuard node); |
| 187 | 184 |
| 188 abstract beginGraph(HGraph graph); | 185 abstract beginGraph(HGraph graph); |
| 189 abstract endGraph(HGraph graph); | 186 abstract endGraph(HGraph graph); |
| 190 | 187 |
| 191 abstract beginLoop(HBasicBlock block); | 188 abstract beginLoop(HBasicBlock block); |
| 192 abstract endLoop(HBasicBlock block); | 189 abstract endLoop(HBasicBlock block); |
| 193 abstract handleLoopCondition(HLoopBranch node); | 190 abstract handleLoopCondition(HLoopBranch node); |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 850 } |
| 854 } | 851 } |
| 855 | 852 |
| 856 visitEquals(HEquals node) { | 853 visitEquals(HEquals node) { |
| 857 if (node.builtin) { | 854 if (node.builtin) { |
| 858 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 855 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 859 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); | 856 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); |
| 860 buffer.add(' === '); | 857 buffer.add(' === '); |
| 861 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); | 858 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); |
| 862 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 859 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 863 } else if (node.element === equalsNullElement || | 860 } else if (node.element === equalsNullElement) { |
| 864 node.element === boolifiedEqualsNullElement) { | |
| 865 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 861 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 866 use(node.target, JSPrecedence.CALL_PRECEDENCE); | 862 use(node.target, JSPrecedence.CALL_PRECEDENCE); |
| 867 buffer.add('('); | 863 buffer.add('('); |
| 868 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 864 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 869 buffer.add(')'); | 865 buffer.add(')'); |
| 870 endExpression(JSPrecedence.CALL_PRECEDENCE); | 866 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 871 } else { | 867 } else { |
| 872 visitInvokeStatic(node); | 868 visitInvokeStatic(node); |
| 873 } | 869 } |
| 874 } | 870 } |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 startBailoutSwitch(); | 2100 startBailoutSwitch(); |
| 2105 } | 2101 } |
| 2106 } | 2102 } |
| 2107 | 2103 |
| 2108 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2104 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2109 if (labeledBlockInfo.body.start.hasGuards()) { | 2105 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2110 endBailoutSwitch(); | 2106 endBailoutSwitch(); |
| 2111 } | 2107 } |
| 2112 } | 2108 } |
| 2113 } | 2109 } |
| OLD | NEW |