| 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; |
| 22 } | 22 } |
| 23 | 23 |
| 24 CodeBuffer prettyPrint(js.Node node, Element positionElement) { | 24 CodeBuffer prettyPrint(js.Node node, Element positionElement) { |
| 25 return js.prettyPrint(node, compiler, positionElement); | 25 return js.prettyPrint(node, compiler, positionElement); |
| 26 } | 26 } |
| 27 | 27 |
| 28 CodeBuffer generateMethod(WorkItem work, HGraph graph) { | 28 CodeBuffer generateMethod(WorkItem work, HGraph graph) { |
| 29 return measure(() { | 29 return measure(() { |
| 30 HTypeMap types = work.compilationContext.types; | 30 JavaScriptItemCompilationContext context = work.compilationContext; |
| 31 HTypeMap types = context.types; |
| 31 graph.exit.predecessors.forEach((block) { | 32 graph.exit.predecessors.forEach((block) { |
| 32 assert(block.last is HGoto || block.last is HReturn); | 33 assert(block.last is HGoto || block.last is HReturn); |
| 33 if (block.last is HReturn) { | 34 if (block.last is HReturn) { |
| 34 backend.registerReturnType(work.element, types[block.last.inputs[0]]); | 35 backend.registerReturnType(work.element, types[block.last.inputs[0]]); |
| 35 } else { | 36 } else { |
| 36 backend.registerReturnType(work.element, HType.NULL); | 37 backend.registerReturnType(work.element, HType.NULL); |
| 37 } | 38 } |
| 38 }); | 39 }); |
| 39 compiler.tracer.traceGraph("codegen", graph); | 40 compiler.tracer.traceGraph("codegen", graph); |
| 40 Map<Element, String> parameterNames = getParameterNames(work); | 41 Map<Element, String> parameterNames = getParameterNames(work); |
| (...skipping 2865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2906 if (leftType.canBeNull() && rightType.canBeNull()) { | 2907 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2907 if (left.isConstantNull() || right.isConstantNull() || | 2908 if (left.isConstantNull() || right.isConstantNull() || |
| 2908 (leftType.isPrimitive() && leftType == rightType)) { | 2909 (leftType.isPrimitive() && leftType == rightType)) { |
| 2909 return '=='; | 2910 return '=='; |
| 2910 } | 2911 } |
| 2911 return null; | 2912 return null; |
| 2912 } else { | 2913 } else { |
| 2913 return '==='; | 2914 return '==='; |
| 2914 } | 2915 } |
| 2915 } | 2916 } |
| OLD | NEW |