| 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 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 push(new js.Binary('&&', pop(), pop()), node); | 2414 push(new js.Binary('&&', pop(), pop()), node); |
| 2415 } else { | 2415 } else { |
| 2416 checkNull(input); | 2416 checkNull(input); |
| 2417 push(new js.Binary('||', pop(), pop()), node); | 2417 push(new js.Binary('||', pop(), pop()), node); |
| 2418 } | 2418 } |
| 2419 } | 2419 } |
| 2420 } | 2420 } |
| 2421 | 2421 |
| 2422 js.Expression generateTest(HCheck node) { | 2422 js.Expression generateTest(HCheck node) { |
| 2423 HInstruction input = node.checkedInput; | 2423 HInstruction input = node.checkedInput; |
| 2424 TypeMask receiver = input.instructionType.computeMask(compiler); |
| 2425 TypeMask mask = node.instructionType.computeMask(compiler); |
| 2426 bool turnIntoNullCheck = mask.nullable() == receiver; |
| 2424 js.Expression test; | 2427 js.Expression test; |
| 2425 if (node.isInteger()) { | 2428 if (turnIntoNullCheck) { |
| 2429 use(input); |
| 2430 test = new js.Binary("==", pop(), new js.LiteralNull()); |
| 2431 } else if (node.isInteger()) { |
| 2426 // input is !int | 2432 // input is !int |
| 2427 checkInt(input, '!=='); | 2433 checkInt(input, '!=='); |
| 2428 test = pop(); | 2434 test = pop(); |
| 2429 } else if (node.isNumber()) { | 2435 } else if (node.isNumber()) { |
| 2430 // input is !num | 2436 // input is !num |
| 2431 checkNum(input, '!=='); | 2437 checkNum(input, '!=='); |
| 2432 test = pop(); | 2438 test = pop(); |
| 2433 } else if (node.isBoolean()) { | 2439 } else if (node.isBoolean()) { |
| 2434 // input is !bool | 2440 // input is !bool |
| 2435 checkBool(input, '!=='); | 2441 checkBool(input, '!=='); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 checkObject(input, '!=='); | 2485 checkObject(input, '!=='); |
| 2480 js.Expression objectTest = pop(); | 2486 js.Expression objectTest = pop(); |
| 2481 checkArray(input, '!=='); | 2487 checkArray(input, '!=='); |
| 2482 js.Expression arrayTest = pop(); | 2488 js.Expression arrayTest = pop(); |
| 2483 checkIndexingBehavior(input, negative: true); | 2489 checkIndexingBehavior(input, negative: true); |
| 2484 js.Binary notIndexingTest = new js.Binary('&&', arrayTest, pop()); | 2490 js.Binary notIndexingTest = new js.Binary('&&', arrayTest, pop()); |
| 2485 js.Binary notObjectOrIndexingTest = | 2491 js.Binary notObjectOrIndexingTest = |
| 2486 new js.Binary('||', objectTest, notIndexingTest); | 2492 new js.Binary('||', objectTest, notIndexingTest); |
| 2487 test = new js.Binary('&&', stringTest, notObjectOrIndexingTest); | 2493 test = new js.Binary('&&', stringTest, notObjectOrIndexingTest); |
| 2488 } else { | 2494 } else { |
| 2489 compiler.internalError('Unexpected type guard', instruction: input); | 2495 compiler.internalError('Unexpected check', instruction: input); |
| 2490 } | 2496 } |
| 2491 return test; | 2497 return test; |
| 2492 } | 2498 } |
| 2493 | 2499 |
| 2494 void visitTypeConversion(HTypeConversion node) { | 2500 void visitTypeConversion(HTypeConversion node) { |
| 2495 if (!node.isChecked) { | 2501 if (!node.isChecked) { |
| 2496 use(node.checkedInput); | 2502 use(node.checkedInput); |
| 2497 return; | 2503 return; |
| 2498 } | 2504 } |
| 2499 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { | 2505 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3015 if (leftType.canBeNull() && rightType.canBeNull()) { | 3021 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 3016 if (left.isConstantNull() || right.isConstantNull() || | 3022 if (left.isConstantNull() || right.isConstantNull() || |
| 3017 (leftType.isPrimitive(compiler) && leftType == rightType)) { | 3023 (leftType.isPrimitive(compiler) && leftType == rightType)) { |
| 3018 return '=='; | 3024 return '=='; |
| 3019 } | 3025 } |
| 3020 return null; | 3026 return null; |
| 3021 } else { | 3027 } else { |
| 3022 return '==='; | 3028 return '==='; |
| 3023 } | 3029 } |
| 3024 } | 3030 } |
| OLD | NEW |