OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); | 1547 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); |
1548 addq(dst, src); | 1548 addq(dst, src); |
1549 } | 1549 } |
1550 } | 1550 } |
1551 } | 1551 } |
1552 | 1552 |
1553 | 1553 |
1554 void MacroAssembler::SmiSubConstant(Register dst, | 1554 void MacroAssembler::SmiSubConstant(Register dst, |
1555 Register src, | 1555 Register src, |
1556 Smi* constant, | 1556 Smi* constant, |
1557 Label* on_not_smi_result, | 1557 SmiExecutionMode mode, |
| 1558 Label* bailout_label, |
1558 Label::Distance near_jump) { | 1559 Label::Distance near_jump) { |
1559 if (constant->value() == 0) { | 1560 if (constant->value() == 0) { |
1560 if (!dst.is(src)) { | 1561 if (!dst.is(src)) { |
1561 movq(dst, src); | 1562 movq(dst, src); |
1562 } | 1563 } |
1563 } else if (dst.is(src)) { | 1564 } else if (dst.is(src)) { |
1564 ASSERT(!dst.is(kScratchRegister)); | 1565 ASSERT(!dst.is(kScratchRegister)); |
1565 if (constant->value() == Smi::kMinValue) { | 1566 LoadSmiConstant(kScratchRegister, constant); |
1566 // Subtracting min-value from any non-negative value will overflow. | 1567 subq(dst, kScratchRegister); |
1567 // We test the non-negativeness before doing the subtraction. | 1568 if (mode & SMI_BAILOUT_ON_NO_OVERFLOW) { |
1568 testq(src, src); | 1569 j(no_overflow, bailout_label, near_jump); |
1569 j(not_sign, on_not_smi_result, near_jump); | 1570 if (mode & SMI_NEED_RESERVE_SOURCES) { |
1570 LoadSmiConstant(kScratchRegister, constant); | 1571 addq(dst, kScratchRegister); |
1571 subq(dst, kScratchRegister); | 1572 } |
| 1573 } else if (mode & SMI_BAILOUT_ON_OVERFLOW) { |
| 1574 if (mode & SMI_NEED_RESERVE_SOURCES) { |
| 1575 Label done; |
| 1576 j(no_overflow, &done, Label::kNear); |
| 1577 addq(dst, kScratchRegister); |
| 1578 jmp(bailout_label, near_jump); |
| 1579 bind(&done); |
| 1580 } else { |
| 1581 // Implement this when SimSubConstant is invoked from Crankshaft. |
| 1582 // BailoutHandler->BailoutIf(overflow); |
| 1583 UNIMPLEMENTED(); // Not used. |
| 1584 } |
1572 } else { | 1585 } else { |
1573 // Subtract by adding the negation. | 1586 ASSERT(mode == SMI_NO_CONSTRAINT); |
1574 LoadSmiConstant(kScratchRegister, Smi::FromInt(-constant->value())); | |
1575 addq(kScratchRegister, dst); | |
1576 j(overflow, on_not_smi_result, near_jump); | |
1577 movq(dst, kScratchRegister); | |
1578 } | 1587 } |
1579 } else { | 1588 } else { |
1580 if (constant->value() == Smi::kMinValue) { | 1589 UNIMPLEMENTED(); // Not used. |
1581 // Subtracting min-value from any non-negative value will overflow. | |
1582 // We test the non-negativeness before doing the subtraction. | |
1583 testq(src, src); | |
1584 j(not_sign, on_not_smi_result, near_jump); | |
1585 LoadSmiConstant(dst, constant); | |
1586 // Adding and subtracting the min-value gives the same result, it only | |
1587 // differs on the overflow bit, which we don't check here. | |
1588 addq(dst, src); | |
1589 } else { | |
1590 // Subtract by adding the negation. | |
1591 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); | |
1592 addq(dst, src); | |
1593 j(overflow, on_not_smi_result, near_jump); | |
1594 } | |
1595 } | 1590 } |
1596 } | 1591 } |
1597 | 1592 |
1598 | 1593 |
1599 void MacroAssembler::SmiNeg(Register dst, | 1594 void MacroAssembler::SmiNeg(Register dst, |
1600 Register src, | 1595 Register src, |
1601 Label* on_smi_result, | 1596 Label* on_smi_result, |
1602 Label::Distance near_jump) { | 1597 Label::Distance near_jump) { |
1603 if (dst.is(src)) { | 1598 if (dst.is(src)) { |
1604 ASSERT(!dst.is(kScratchRegister)); | 1599 ASSERT(!dst.is(kScratchRegister)); |
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4905 j(greater, &no_memento_available); | 4900 j(greater, &no_memento_available); |
4906 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4901 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
4907 Heap::kAllocationMementoMapRootIndex); | 4902 Heap::kAllocationMementoMapRootIndex); |
4908 bind(&no_memento_available); | 4903 bind(&no_memento_available); |
4909 } | 4904 } |
4910 | 4905 |
4911 | 4906 |
4912 } } // namespace v8::internal | 4907 } } // namespace v8::internal |
4913 | 4908 |
4914 #endif // V8_TARGET_ARCH_X64 | 4909 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |