| 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 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 // We want the outcome of bit-operations to be positive. We use the unsigned | 1272 // We want the outcome of bit-operations to be positive. We use the unsigned |
| 1273 // shift operator to achieve this. | 1273 // shift operator to achieve this. |
| 1274 visitBitInvokeBinary(HBinaryBitOp node, String op) { | 1274 visitBitInvokeBinary(HBinaryBitOp node, String op) { |
| 1275 visitInvokeBinary(node, op); | 1275 visitInvokeBinary(node, op); |
| 1276 if (node.isBuiltin(types) && requiresUintConversion(node)) { | 1276 if (node.isBuiltin(types) && requiresUintConversion(node)) { |
| 1277 push(new js.Binary(">>>", pop(), new js.LiteralNumber("0")), node); | 1277 push(new js.Binary(">>>", pop(), new js.LiteralNumber("0")), node); |
| 1278 } | 1278 } |
| 1279 } | 1279 } |
| 1280 | 1280 |
| 1281 visitInvokeUnary(HInvokeUnary node, String op) { | 1281 visitInvokeUnary(HInvokeUnary node, String op) { |
| 1282 if (node.isBuiltin(types)) { | 1282 use(node.operand); |
| 1283 use(node.operand); | 1283 push(new js.Prefix(op, pop()), node); |
| 1284 push(new js.Prefix(op, pop()), node); | |
| 1285 } else { | |
| 1286 visitInvokeStatic(node); | |
| 1287 } | |
| 1288 } | 1284 } |
| 1289 | 1285 |
| 1290 // We want the outcome of bit-operations to be positive. We use the unsigned | 1286 // We want the outcome of bit-operations to be positive. We use the unsigned |
| 1291 // shift operator to achieve this. | 1287 // shift operator to achieve this. |
| 1292 visitBitInvokeUnary(HInvokeUnary node, String op) { | 1288 visitBitInvokeUnary(HInvokeUnary node, String op) { |
| 1293 visitInvokeUnary(node, op); | 1289 visitInvokeUnary(node, op); |
| 1294 if (node.isBuiltin(types) && requiresUintConversion(node)) { | 1290 if (requiresUintConversion(node)) { |
| 1295 push(new js.Binary(">>>", pop(), new js.LiteralNumber("0")), node); | 1291 push(new js.Binary(">>>", pop(), new js.LiteralNumber("0")), node); |
| 1296 } | 1292 } |
| 1297 } | 1293 } |
| 1298 | 1294 |
| 1299 void emitIdentityComparison(HInstruction left, HInstruction right) { | 1295 void emitIdentityComparison(HInstruction left, HInstruction right) { |
| 1300 String op = singleIdentityComparison(left, right, types); | 1296 String op = singleIdentityComparison(left, right, types); |
| 1301 if (op != null) { | 1297 if (op != null) { |
| 1302 use(left); | 1298 use(left); |
| 1303 js.Expression jsLeft = pop(); | 1299 js.Expression jsLeft = pop(); |
| 1304 use(right); | 1300 use(right); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 } | 2132 } |
| 2137 | 2133 |
| 2138 void visitIndex(HIndex node) { | 2134 void visitIndex(HIndex node) { |
| 2139 use(node.receiver); | 2135 use(node.receiver); |
| 2140 js.Expression receiver = pop(); | 2136 js.Expression receiver = pop(); |
| 2141 use(node.index); | 2137 use(node.index); |
| 2142 push(new js.PropertyAccess(receiver, pop()), node); | 2138 push(new js.PropertyAccess(receiver, pop()), node); |
| 2143 } | 2139 } |
| 2144 | 2140 |
| 2145 void visitIndexAssign(HIndexAssign node) { | 2141 void visitIndexAssign(HIndexAssign node) { |
| 2146 if (node.isBuiltin(types)) { | 2142 use(node.receiver); |
| 2147 use(node.inputs[1]); | 2143 js.Expression receiver = pop(); |
| 2148 js.Expression receiver = pop(); | 2144 use(node.index); |
| 2149 use(node.inputs[2]); | 2145 js.Expression index = pop(); |
| 2150 js.Expression index = pop(); | 2146 use(node.value); |
| 2151 use(node.inputs[3]); | 2147 push(new js.Assignment(new js.PropertyAccess(receiver, index), pop()), |
| 2152 push(new js.Assignment(new js.PropertyAccess(receiver, index), pop()), | 2148 node); |
| 2153 node); | |
| 2154 } else { | |
| 2155 visitInvokeStatic(node); | |
| 2156 } | |
| 2157 } | 2149 } |
| 2158 | 2150 |
| 2159 void checkInt(HInstruction input, String cmp) { | 2151 void checkInt(HInstruction input, String cmp) { |
| 2160 use(input); | 2152 use(input); |
| 2161 js.Expression left = pop(); | 2153 js.Expression left = pop(); |
| 2162 use(input); | 2154 use(input); |
| 2163 js.Expression or0 = new js.Binary("|", pop(), new js.LiteralNumber("0")); | 2155 js.Expression or0 = new js.Binary("|", pop(), new js.LiteralNumber("0")); |
| 2164 push(new js.Binary(cmp, left, or0)); | 2156 push(new js.Binary(cmp, left, or0)); |
| 2165 } | 2157 } |
| 2166 | 2158 |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3027 if (leftType.canBeNull() && rightType.canBeNull()) { | 3019 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 3028 if (left.isConstantNull() || right.isConstantNull() || | 3020 if (left.isConstantNull() || right.isConstantNull() || |
| 3029 (leftType.isPrimitive() && leftType == rightType)) { | 3021 (leftType.isPrimitive() && leftType == rightType)) { |
| 3030 return '=='; | 3022 return '=='; |
| 3031 } | 3023 } |
| 3032 return null; | 3024 return null; |
| 3033 } else { | 3025 } else { |
| 3034 return '==='; | 3026 return '==='; |
| 3035 } | 3027 } |
| 3036 } | 3028 } |
| OLD | NEW |