| 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; |
| 130 int indent = 0; | 131 int indent = 0; |
| 131 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; | 132 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; |
| 132 HGraph currentGraph; | 133 HGraph currentGraph; |
| 133 /** | 134 /** |
| 134 * Whether the code-generation should try to generate an expression | 135 * Whether the code-generation should try to generate an expression |
| 135 * instead of a sequence of statements. | 136 * instead of a sequence of statements. |
| 136 */ | 137 */ |
| 137 int generationState = STATE_STATEMENT; | 138 int generationState = STATE_STATEMENT; |
| 138 /** | 139 /** |
| 139 * While generating expressions, we can't insert variable declarations. | 140 * While generating expressions, we can't insert variable declarations. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 169 continueAction = new Map<Element, ElementAction>(), | 170 continueAction = new Map<Element, ElementAction>(), |
| 170 phiEquivalence = new Equivalence<HPhi>() { | 171 phiEquivalence = new Equivalence<HPhi>() { |
| 171 | 172 |
| 172 for (final name in parameterNames.getValues()) { | 173 for (final name in parameterNames.getValues()) { |
| 173 prefixes[name] = 0; | 174 prefixes[name] = 0; |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Create a namespace for temporaries. | 177 // Create a namespace for temporaries. |
| 177 prefixes[TEMPORARY_PREFIX] = 0; | 178 prefixes[TEMPORARY_PREFIX] = 0; |
| 178 | 179 |
| 179 equalsNullElement = | 180 Interceptors interceptors = compiler.builder.interceptors; |
| 180 compiler.builder.interceptors.getEqualsNullInterceptor(); | 181 equalsNullElement = interceptors.getEqualsNullInterceptor(); |
| 182 boolifiedEqualsNullElement = |
| 183 interceptors.getBoolifiedVersionOf(equalsNullElement); |
| 181 } | 184 } |
| 182 | 185 |
| 183 abstract visitTypeGuard(HTypeGuard node); | 186 abstract visitTypeGuard(HTypeGuard node); |
| 184 | 187 |
| 185 abstract beginGraph(HGraph graph); | 188 abstract beginGraph(HGraph graph); |
| 186 abstract endGraph(HGraph graph); | 189 abstract endGraph(HGraph graph); |
| 187 | 190 |
| 188 abstract beginLoop(HBasicBlock block); | 191 abstract beginLoop(HBasicBlock block); |
| 189 abstract endLoop(HBasicBlock block); | 192 abstract endLoop(HBasicBlock block); |
| 190 abstract handleLoopCondition(HLoopBranch node); | 193 abstract handleLoopCondition(HLoopBranch node); |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 845 } |
| 843 } | 846 } |
| 844 | 847 |
| 845 visitEquals(HEquals node) { | 848 visitEquals(HEquals node) { |
| 846 if (node.builtin) { | 849 if (node.builtin) { |
| 847 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 850 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 848 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); | 851 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); |
| 849 buffer.add(' === '); | 852 buffer.add(' === '); |
| 850 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); | 853 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); |
| 851 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 854 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 852 } else if (node.element === equalsNullElement) { | 855 } else if (node.element === equalsNullElement || |
| 856 node.element === boolifiedEqualsNullElement) { |
| 853 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 857 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 854 use(node.target, JSPrecedence.CALL_PRECEDENCE); | 858 use(node.target, JSPrecedence.CALL_PRECEDENCE); |
| 855 buffer.add('('); | 859 buffer.add('('); |
| 856 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 860 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 857 buffer.add(')'); | 861 buffer.add(')'); |
| 858 endExpression(JSPrecedence.CALL_PRECEDENCE); | 862 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 859 } else { | 863 } else { |
| 860 visitInvokeStatic(node); | 864 visitInvokeStatic(node); |
| 861 } | 865 } |
| 862 } | 866 } |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 startBailoutSwitch(); | 2083 startBailoutSwitch(); |
| 2080 } | 2084 } |
| 2081 } | 2085 } |
| 2082 | 2086 |
| 2083 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2087 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2084 if (labeledBlockInfo.body.start.hasGuards()) { | 2088 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2085 endBailoutSwitch(); | 2089 endBailoutSwitch(); |
| 2086 } | 2090 } |
| 2087 } | 2091 } |
| 2088 } | 2092 } |
| OLD | NEW |