| 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 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
| 7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 8 : this.backend = backend, | 8 : this.backend = backend, |
| 9 super(backend.compiler); | 9 super(backend.compiler); |
| 10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Map<Element, String> parameterNames = getParameterNames(work); | 82 Map<Element, String> parameterNames = getParameterNames(work); |
| 83 List<js.Parameter> parameters = <js.Parameter>[]; | 83 List<js.Parameter> parameters = <js.Parameter>[]; |
| 84 parameterNames.forEach((element, name) { | 84 parameterNames.forEach((element, name) { |
| 85 parameters.add(new js.Parameter(name)); | 85 parameters.add(new js.Parameter(name)); |
| 86 }); | 86 }); |
| 87 SsaUnoptimizedCodeGenerator codegen = new SsaUnoptimizedCodeGenerator( | 87 SsaUnoptimizedCodeGenerator codegen = new SsaUnoptimizedCodeGenerator( |
| 88 backend, work, parameters, parameterNames); | 88 backend, work, parameters, parameterNames); |
| 89 codegen.visitGraph(graph); | 89 codegen.visitGraph(graph); |
| 90 | 90 |
| 91 js.Block body = new js.Block(<js.Statement>[]); | 91 js.Block body = new js.Block(<js.Statement>[]); |
| 92 body.statements.add(codegen.setup); | 92 if (codegen.setup != null) body.statements.add(codegen.setup); |
| 93 body.statements.add(codegen.body); | 93 body.statements.add(codegen.body); |
| 94 js.Fun fun = | 94 js.Fun fun = |
| 95 buildJavaScriptFunction(work.element, codegen.newParameters, body); | 95 buildJavaScriptFunction(work.element, codegen.newParameters, body); |
| 96 return prettyPrint(fun, work.element); | 96 return prettyPrint(fun, work.element); |
| 97 }); | 97 }); |
| 98 } | 98 } |
| 99 | 99 |
| 100 Map<Element, String> getParameterNames(WorkItem work) { | 100 Map<Element, String> getParameterNames(WorkItem work) { |
| 101 Map<Element, String> parameterNames = new LinkedHashMap<Element, String>(); | 101 Map<Element, String> parameterNames = new LinkedHashMap<Element, String>(); |
| 102 FunctionElement function = work.element; | 102 FunctionElement function = work.element; |
| (...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2595 * bailout-switches just push [:false:] on the stack and replace it when | 2595 * bailout-switches just push [:false:] on the stack and replace it when |
| 2596 * they used the [:default::] clause. | 2596 * they used the [:default::] clause. |
| 2597 */ | 2597 */ |
| 2598 final List<bool> defaultClauseUsedInBailoutStack; | 2598 final List<bool> defaultClauseUsedInBailoutStack; |
| 2599 | 2599 |
| 2600 SsaBailoutPropagator propagator; | 2600 SsaBailoutPropagator propagator; |
| 2601 HInstruction savedFirstInstruction; | 2601 HInstruction savedFirstInstruction; |
| 2602 | 2602 |
| 2603 SsaUnoptimizedCodeGenerator(backend, work, parameters, parameterNames) | 2603 SsaUnoptimizedCodeGenerator(backend, work, parameters, parameterNames) |
| 2604 : super(backend, work, parameterNames), | 2604 : super(backend, work, parameterNames), |
| 2605 setup = new js.EmptyStatement(), | |
| 2606 oldBailoutSwitches = <js.Switch>[], | 2605 oldBailoutSwitches = <js.Switch>[], |
| 2607 newParameters = <js.Parameter>[], | 2606 newParameters = <js.Parameter>[], |
| 2608 labels = <String>[], | 2607 labels = <String>[], |
| 2609 defaultClauseUsedInBailoutStack = <bool>[]; | 2608 defaultClauseUsedInBailoutStack = <bool>[]; |
| 2610 | 2609 |
| 2611 String pushLabel() { | 2610 String pushLabel() { |
| 2612 String label = 'L${labelId++}'; | 2611 String label = 'L${labelId++}'; |
| 2613 labels.addLast(label); | 2612 labels.addLast(label); |
| 2614 return label; | 2613 return label; |
| 2615 } | 2614 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 if (leftType.canBeNull() && rightType.canBeNull()) { | 2909 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2911 if (left.isConstantNull() || right.isConstantNull() || | 2910 if (left.isConstantNull() || right.isConstantNull() || |
| 2912 (leftType.isPrimitive() && leftType == rightType)) { | 2911 (leftType.isPrimitive() && leftType == rightType)) { |
| 2913 return '=='; | 2912 return '=='; |
| 2914 } | 2913 } |
| 2915 return null; | 2914 return null; |
| 2916 } else { | 2915 } else { |
| 2917 return '==='; | 2916 return '==='; |
| 2918 } | 2917 } |
| 2919 } | 2918 } |
| OLD | NEW |