| 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 SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 allocator.visitGraph(graph); | 330 allocator.visitGraph(graph); |
| 331 variableNames = allocator.names; | 331 variableNames = allocator.names; |
| 332 shouldGroupVarDeclarations = allocator.names.numberOfVariables > 1; | 332 shouldGroupVarDeclarations = allocator.names.numberOfVariables > 1; |
| 333 | 333 |
| 334 // Don't register a return type for lazily initialized variables. | 334 // Don't register a return type for lazily initialized variables. |
| 335 if (work.element is! FunctionElement) return; | 335 if (work.element is! FunctionElement) return; |
| 336 | 336 |
| 337 // Register return types to the backend. | 337 // Register return types to the backend. |
| 338 graph.exit.predecessors.forEach((HBasicBlock block) { | 338 graph.exit.predecessors.forEach((HBasicBlock block) { |
| 339 HInstruction last = block.last; | 339 HInstruction last = block.last; |
| 340 assert(last is HGoto || last is HReturn); | 340 assert(last is HGoto || last is HReturn || last is HThrow); |
| 341 if (last is HReturn) { | 341 if (last is HReturn) { |
| 342 backend.registerReturnType( | 342 backend.registerReturnType( |
| 343 work.element, last.inputs[0].instructionType); | 343 work.element, last.inputs[0].instructionType); |
| 344 } else { | 344 } else if (last is HGoto) { |
| 345 backend.registerReturnType(work.element, HType.NULL); | 345 backend.registerReturnType(work.element, HType.NULL); |
| 346 } | 346 } |
| 347 }); | 347 }); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void handleDelayedVariableDeclarations() { | 350 void handleDelayedVariableDeclarations() { |
| 351 // If we have only one variable declaration and the first statement is an | 351 // If we have only one variable declaration and the first statement is an |
| 352 // assignment to that variable then we can merge the two. We count the | 352 // assignment to that variable then we can merge the two. We count the |
| 353 // number of variables in the variable allocator to try to avoid this issue, | 353 // number of variables in the variable allocator to try to avoid this issue, |
| 354 // but it sometimes happens that the variable allocator introduces a | 354 // but it sometimes happens that the variable allocator introduces a |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 if (leftType.canBeNull() && rightType.canBeNull()) { | 2987 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2988 if (left.isConstantNull() || right.isConstantNull() || | 2988 if (left.isConstantNull() || right.isConstantNull() || |
| 2989 (leftType.isPrimitive() && leftType == rightType)) { | 2989 (leftType.isPrimitive() && leftType == rightType)) { |
| 2990 return '=='; | 2990 return '=='; |
| 2991 } | 2991 } |
| 2992 return null; | 2992 return null; |
| 2993 } else { | 2993 } else { |
| 2994 return '==='; | 2994 return '==='; |
| 2995 } | 2995 } |
| 2996 } | 2996 } |
| OLD | NEW |