OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 | 1461 |
1462 __ CallRuntime(Runtime::kTypeof, 1); | 1462 __ CallRuntime(Runtime::kTypeof, 1); |
1463 Apply(context_, rax); | 1463 Apply(context_, rax); |
1464 break; | 1464 break; |
1465 } | 1465 } |
1466 | 1466 |
1467 case Token::ADD: { | 1467 case Token::ADD: { |
1468 Comment cmt(masm_, "[ UnaryOperation (ADD)"); | 1468 Comment cmt(masm_, "[ UnaryOperation (ADD)"); |
1469 VisitForValue(expr->expression(), kAccumulator); | 1469 VisitForValue(expr->expression(), kAccumulator); |
1470 Label no_conversion; | 1470 Label no_conversion; |
1471 Condition is_smi; | 1471 Condition is_smi = masm_->CheckSmi(result_register()); |
1472 is_smi = masm_->CheckSmi(result_register()); | |
1473 __ j(is_smi, &no_conversion); | 1472 __ j(is_smi, &no_conversion); |
1474 __ push(result_register()); | 1473 __ push(result_register()); |
1475 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); | 1474 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); |
1476 __ bind(&no_conversion); | 1475 __ bind(&no_conversion); |
1477 Apply(context_, result_register()); | 1476 Apply(context_, result_register()); |
1478 break; | 1477 break; |
1479 } | 1478 } |
1480 | 1479 |
| 1480 case Token::SUB: { |
| 1481 Comment cmt(masm_, "[ UnaryOperation (SUB)"); |
| 1482 bool overwrite = |
| 1483 (expr->expression()->AsBinaryOperation() != NULL && |
| 1484 expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); |
| 1485 GenericUnaryOpStub stub(Token::SUB, overwrite); |
| 1486 // GenericUnaryOpStub expects the argument to be in the |
| 1487 // accumulator register rax. |
| 1488 VisitForValue(expr->expression(), kAccumulator); |
| 1489 __ CallStub(&stub); |
| 1490 Apply(context_, rax); |
| 1491 break; |
| 1492 } |
| 1493 |
| 1494 case Token::BIT_NOT: { |
| 1495 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); |
| 1496 bool overwrite = |
| 1497 (expr->expression()->AsBinaryOperation() != NULL && |
| 1498 expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); |
| 1499 GenericUnaryOpStub stub(Token::BIT_NOT, overwrite); |
| 1500 // GenericUnaryOpStub expects the argument to be in the |
| 1501 // accumulator register rax. |
| 1502 VisitForValue(expr->expression(), kAccumulator); |
| 1503 // Avoid calling the stub for Smis. |
| 1504 Label smi, done; |
| 1505 Condition is_smi = masm_->CheckSmi(result_register()); |
| 1506 __ j(is_smi, &smi); |
| 1507 // Non-smi: call stub leaving result in accumulator register. |
| 1508 __ CallStub(&stub); |
| 1509 __ jmp(&done); |
| 1510 // Perform operation directly on Smis. |
| 1511 __ bind(&smi); |
| 1512 __ SmiNot(result_register(), result_register()); |
| 1513 __ bind(&done); |
| 1514 Apply(context_, result_register()); |
| 1515 } |
| 1516 |
1481 default: | 1517 default: |
1482 UNREACHABLE(); | 1518 UNREACHABLE(); |
1483 } | 1519 } |
1484 } | 1520 } |
1485 | 1521 |
1486 | 1522 |
1487 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 1523 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
1488 Comment cmnt(masm_, "[ CountOperation"); | 1524 Comment cmnt(masm_, "[ CountOperation"); |
1489 | 1525 |
1490 // Expression can only be a property, a global or a (parameter or local) | 1526 // Expression can only be a property, a global or a (parameter or local) |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 __ movq(Operand(rsp, 0), rdx); | 1879 __ movq(Operand(rsp, 0), rdx); |
1844 // And return. | 1880 // And return. |
1845 __ ret(0); | 1881 __ ret(0); |
1846 } | 1882 } |
1847 | 1883 |
1848 | 1884 |
1849 #undef __ | 1885 #undef __ |
1850 | 1886 |
1851 | 1887 |
1852 } } // namespace v8::internal | 1888 } } // namespace v8::internal |
OLD | NEW |