| 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 String generate(WorkItem work, HGraph graph) { | 9 String generate(WorkItem work, HGraph graph) { |
| 10 return measure(() { | 10 return measure(() { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 String local(HLocal local) { | 179 String local(HLocal local) { |
| 180 Element element = local.element; | 180 Element element = local.element; |
| 181 if (element != null && element.kind == ElementKind.PARAMETER) { | 181 if (element != null && element.kind == ElementKind.PARAMETER) { |
| 182 return parameterNames[element]; | 182 return parameterNames[element]; |
| 183 } | 183 } |
| 184 int id = local.id; | 184 int id = local.id; |
| 185 String name = names[id]; | 185 String name = names[id]; |
| 186 if (name !== null) return name; | 186 if (name !== null) return name; |
| 187 | 187 |
| 188 String prefix; | 188 String prefix; |
| 189 if (element !== null) { | 189 if (element !== null && !element.name.isEmpty()) { |
| 190 prefix = element.name.slowToString(); | 190 prefix = element.name.slowToString(); |
| 191 } else { | 191 } else { |
| 192 prefix = 'v'; | 192 prefix = 'v'; |
| 193 } | 193 } |
| 194 if (!prefixes.containsKey(prefix)) { | 194 if (!prefixes.containsKey(prefix)) { |
| 195 prefixes[prefix] = 0; | 195 prefixes[prefix] = 0; |
| 196 return newName(id, prefix); | 196 return newName(id, prefix); |
| 197 } else { | 197 } else { |
| 198 return newName(id, '${prefix}_${prefixes[prefix]++}'); | 198 return newName(id, '${prefix}_${prefixes[prefix]++}'); |
| 199 } | 199 } |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 // need to work together to avoid the parenthesis. See r4928 for an | 664 // need to work together to avoid the parenthesis. See r4928 for an |
| 665 // implementation that still dealt with precedence. | 665 // implementation that still dealt with precedence. |
| 666 ConstantHandler handler = compiler.constantHandler; | 666 ConstantHandler handler = compiler.constantHandler; |
| 667 String name = handler.getNameForConstant(node.constant); | 667 String name = handler.getNameForConstant(node.constant); |
| 668 if (name === null) { | 668 if (name === null) { |
| 669 assert(!node.constant.isObject()); | 669 assert(!node.constant.isObject()); |
| 670 node.constant.writeJsCode(buffer, handler); | 670 node.constant.writeJsCode(buffer, handler); |
| 671 } else { | 671 } else { |
| 672 buffer.add(compiler.namer.CURRENT_ISOLATE); | 672 buffer.add(compiler.namer.CURRENT_ISOLATE); |
| 673 buffer.add("."); | 673 buffer.add("."); |
| 674 buffer.add(name); | 674 buffer.add(name); |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 | 677 |
| 678 visitLoopBranch(HLoopBranch node) { | 678 visitLoopBranch(HLoopBranch node) { |
| 679 HBasicBlock branchBlock = currentBlock; | 679 HBasicBlock branchBlock = currentBlock; |
| 680 handleLoopCondition(node); | 680 handleLoopCondition(node); |
| 681 List<HBasicBlock> dominated = currentBlock.dominatedBlocks; | 681 List<HBasicBlock> dominated = currentBlock.dominatedBlocks; |
| 682 // For a do while loop, the body has already been visited. | 682 // For a do while loop, the body has already been visited. |
| 683 if (!node.isDoWhile()) { | 683 if (!node.isDoWhile()) { |
| 684 visitBasicBlock(dominated[0]); | 684 visitBasicBlock(dominated[0]); |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 startBailoutSwitch(); | 1392 startBailoutSwitch(); |
| 1393 } | 1393 } |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 void endElse(HIf node) { | 1396 void endElse(HIf node) { |
| 1397 if (node.elseBlock.hasBailouts()) { | 1397 if (node.elseBlock.hasBailouts()) { |
| 1398 endBailoutSwitch(); | 1398 endBailoutSwitch(); |
| 1399 } | 1399 } |
| 1400 } | 1400 } |
| 1401 } | 1401 } |
| OLD | NEW |