| 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'; |
| 11 NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter; | 11 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; |
| 12 | 12 |
| 13 | 13 |
| 14 js.Fun buildJavaScriptFunction(FunctionElement element, | 14 js.Fun buildJavaScriptFunction(FunctionElement element, |
| 15 List<js.Parameter> parameters, | 15 List<js.Parameter> parameters, |
| 16 js.Block body) { | 16 js.Block body) { |
| 17 FunctionExpression expression = element.cachedNode; | 17 FunctionExpression expression = element.cachedNode; |
| 18 js.Fun result = new js.Fun(parameters, body); | 18 js.Fun result = new js.Fun(parameters, body); |
| 19 result.sourcePosition = expression.getBeginToken(); | 19 result.sourcePosition = expression.getBeginToken(); |
| 20 result.endSourcePosition = expression.getEndToken(); | 20 result.endSourcePosition = expression.getEndToken(); |
| 21 return result; | 21 return result; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 final WorkItem work; | 142 final WorkItem work; |
| 143 final HTypeMap types; | 143 final HTypeMap types; |
| 144 | 144 |
| 145 final Set<HInstruction> generateAtUseSite; | 145 final Set<HInstruction> generateAtUseSite; |
| 146 final Set<HInstruction> controlFlowOperators; | 146 final Set<HInstruction> controlFlowOperators; |
| 147 final Map<Element, ElementAction> breakAction; | 147 final Map<Element, ElementAction> breakAction; |
| 148 final Map<Element, ElementAction> continueAction; | 148 final Map<Element, ElementAction> continueAction; |
| 149 final Map<Element, String> parameterNames; | 149 final Map<Element, String> parameterNames; |
| 150 | 150 |
| 151 js.Block currentContainer; | 151 js.Block currentContainer; |
| 152 js.Block get body() => currentContainer; | 152 js.Block get body => currentContainer; |
| 153 List<js.Expression> expressionStack; | 153 List<js.Expression> expressionStack; |
| 154 List<js.Block> oldContainerStack; | 154 List<js.Block> oldContainerStack; |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * Contains the names of the instructions, as well as the parallel | 157 * Contains the names of the instructions, as well as the parallel |
| 158 * copies to perform on block transitioning. | 158 * copies to perform on block transitioning. |
| 159 */ | 159 */ |
| 160 VariableNames variableNames; | 160 VariableNames variableNames; |
| 161 | 161 |
| 162 /** | 162 /** |
| (...skipping 29 matching lines...) Expand all Loading... |
| 192 declaredVariables = new Set<String>(), | 192 declaredVariables = new Set<String>(), |
| 193 delayedVariableDeclarations = new Set<String>(), | 193 delayedVariableDeclarations = new Set<String>(), |
| 194 currentContainer = new js.Block.empty(), | 194 currentContainer = new js.Block.empty(), |
| 195 expressionStack = <js.Expression>[], | 195 expressionStack = <js.Expression>[], |
| 196 oldContainerStack = <js.Block>[], | 196 oldContainerStack = <js.Block>[], |
| 197 generateAtUseSite = new Set<HInstruction>(), | 197 generateAtUseSite = new Set<HInstruction>(), |
| 198 controlFlowOperators = new Set<HInstruction>(), | 198 controlFlowOperators = new Set<HInstruction>(), |
| 199 breakAction = new Map<Element, ElementAction>(), | 199 breakAction = new Map<Element, ElementAction>(), |
| 200 continueAction = new Map<Element, ElementAction>(); | 200 continueAction = new Map<Element, ElementAction>(); |
| 201 | 201 |
| 202 LibraryElement get currentLibrary() => work.element.getLibrary(); | 202 LibraryElement get currentLibrary => work.element.getLibrary(); |
| 203 Compiler get compiler() => backend.compiler; | 203 Compiler get compiler => backend.compiler; |
| 204 NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter; | 204 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; |
| 205 Enqueuer get world() => backend.compiler.enqueuer.codegen; | 205 Enqueuer get world => backend.compiler.enqueuer.codegen; |
| 206 | 206 |
| 207 bool isGenerateAtUseSite(HInstruction instruction) { | 207 bool isGenerateAtUseSite(HInstruction instruction) { |
| 208 return generateAtUseSite.contains(instruction); | 208 return generateAtUseSite.contains(instruction); |
| 209 } | 209 } |
| 210 | 210 |
| 211 bool isNonNegativeInt32Constant(HInstruction instruction) { | 211 bool isNonNegativeInt32Constant(HInstruction instruction) { |
| 212 if (instruction.isConstantInteger()) { | 212 if (instruction.isConstantInteger()) { |
| 213 HConstant constantInstruction = instruction; | 213 HConstant constantInstruction = instruction; |
| 214 PrimitiveConstant primitiveConstant = constantInstruction.constant; | 214 PrimitiveConstant primitiveConstant = constantInstruction.constant; |
| 215 int value = primitiveConstant.value; | 215 int value = primitiveConstant.value; |
| (...skipping 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2906 if (leftType.canBeNull() && rightType.canBeNull()) { | 2906 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2907 if (left.isConstantNull() || right.isConstantNull() || | 2907 if (left.isConstantNull() || right.isConstantNull() || |
| 2908 (leftType.isPrimitive() && leftType == rightType)) { | 2908 (leftType.isPrimitive() && leftType == rightType)) { |
| 2909 return '=='; | 2909 return '=='; |
| 2910 } | 2910 } |
| 2911 return null; | 2911 return null; |
| 2912 } else { | 2912 } else { |
| 2913 return '==='; | 2913 return '==='; |
| 2914 } | 2914 } |
| 2915 } | 2915 } |
| OLD | NEW |