| 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 } | 842 } |
| 846 } | 843 } |
| 847 | 844 |
| 848 visitEquals(HEquals node) { | 845 visitEquals(HEquals node) { |
| 849 if (node.builtin) { | 846 if (node.builtin) { |
| 850 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 847 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 851 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); | 848 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); |
| 852 buffer.add(' === '); | 849 buffer.add(' === '); |
| 853 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); | 850 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); |
| 854 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 851 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 855 } else if (node.element === equalsNullElement || | 852 } else if (node.element === equalsNullElement) { |
| 856 node.element === boolifiedEqualsNullElement) { | |
| 857 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 853 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 858 use(node.target, JSPrecedence.CALL_PRECEDENCE); | 854 use(node.target, JSPrecedence.CALL_PRECEDENCE); |
| 859 buffer.add('('); | 855 buffer.add('('); |
| 860 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 856 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 861 buffer.add(')'); | 857 buffer.add(')'); |
| 862 endExpression(JSPrecedence.CALL_PRECEDENCE); | 858 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 863 } else { | 859 } else { |
| 864 visitInvokeStatic(node); | 860 visitInvokeStatic(node); |
| 865 } | 861 } |
| 866 } | 862 } |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 startBailoutSwitch(); | 2087 startBailoutSwitch(); |
| 2092 } | 2088 } |
| 2093 } | 2089 } |
| 2094 | 2090 |
| 2095 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2091 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2096 if (labeledBlockInfo.body.start.hasGuards()) { | 2092 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2097 endBailoutSwitch(); | 2093 endBailoutSwitch(); |
| 2098 } | 2094 } |
| 2099 } | 2095 } |
| 2100 } | 2096 } |
| OLD | NEW |