| 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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); | 1560 LoadSmiConstant(dst, Smi::FromInt(-constant->value())); |
| 1561 addq(dst, src); | 1561 addq(dst, src); |
| 1562 } | 1562 } |
| 1563 } | 1563 } |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 | 1566 |
| 1567 void MacroAssembler::SmiSubConstant(Register dst, | 1567 void MacroAssembler::SmiSubConstant(Register dst, |
| 1568 Register src, | 1568 Register src, |
| 1569 Smi* constant, | 1569 Smi* constant, |
| 1570 Label* on_not_smi_result, | 1570 SmiOperationExecutionMode mode, |
| 1571 Label* bailout_label, |
| 1571 Label::Distance near_jump) { | 1572 Label::Distance near_jump) { |
| 1572 if (constant->value() == 0) { | 1573 if (constant->value() == 0) { |
| 1573 if (!dst.is(src)) { | 1574 if (!dst.is(src)) { |
| 1574 movq(dst, src); | 1575 movq(dst, src); |
| 1575 } | 1576 } |
| 1576 } else if (dst.is(src)) { | 1577 } else if (dst.is(src)) { |
| 1577 ASSERT(!dst.is(kScratchRegister)); | 1578 ASSERT(!dst.is(kScratchRegister)); |
| 1579 LoadSmiConstant(kScratchRegister, constant); |
| 1580 subq(dst, kScratchRegister); |
| 1581 if (mode.Contains(BAILOUT_ON_NO_OVERFLOW)) { |
| 1582 j(no_overflow, bailout_label, near_jump); |
| 1583 ASSERT(mode.Contains(RESERVE_SOURCE_REGISTER)); |
| 1584 addq(dst, kScratchRegister); |
| 1585 } else if (mode.Contains(BAILOUT_ON_OVERFLOW)) { |
| 1586 if (mode.Contains(RESERVE_SOURCE_REGISTER)) { |
| 1587 Label done; |
| 1588 j(no_overflow, &done, Label::kNear); |
| 1589 addq(dst, kScratchRegister); |
| 1590 jmp(bailout_label, near_jump); |
| 1591 bind(&done); |
| 1592 } else { |
| 1593 // Bailout if overflow without reserving src. |
| 1594 j(overflow, bailout_label, near_jump); |
| 1595 } |
| 1596 } else { |
| 1597 CHECK(mode.IsEmpty()); |
| 1598 } |
| 1599 } else { |
| 1600 ASSERT(mode.Contains(RESERVE_SOURCE_REGISTER)); |
| 1601 ASSERT(mode.Contains(BAILOUT_ON_OVERFLOW)); |
| 1578 if (constant->value() == Smi::kMinValue) { | 1602 if (constant->value() == Smi::kMinValue) { |
| 1579 // Subtracting min-value from any non-negative value will overflow. | 1603 ASSERT(!dst.is(kScratchRegister)); |
| 1580 // We test the non-negativeness before doing the subtraction. | 1604 movq(dst, src); |
| 1581 testq(src, src); | |
| 1582 j(not_sign, on_not_smi_result, near_jump); | |
| 1583 LoadSmiConstant(kScratchRegister, constant); | 1605 LoadSmiConstant(kScratchRegister, constant); |
| 1584 subq(dst, kScratchRegister); | 1606 subq(dst, kScratchRegister); |
| 1585 } else { | 1607 j(overflow, bailout_label, near_jump); |
| 1586 // Subtract by adding the negation. | |
| 1587 LoadSmiConstant(kScratchRegister, Smi::FromInt(-constant->value())); | |
| 1588 addq(kScratchRegister, dst); | |
| 1589 j(overflow, on_not_smi_result, near_jump); | |
| 1590 movq(dst, kScratchRegister); | |
| 1591 } | |
| 1592 } else { | |
| 1593 if (constant->value() == Smi::kMinValue) { | |
| 1594 // Subtracting min-value from any non-negative value will overflow. | |
| 1595 // We test the non-negativeness before doing the subtraction. | |
| 1596 testq(src, src); | |
| 1597 j(not_sign, on_not_smi_result, near_jump); | |
| 1598 LoadSmiConstant(dst, constant); | |
| 1599 // Adding and subtracting the min-value gives the same result, it only | |
| 1600 // differs on the overflow bit, which we don't check here. | |
| 1601 addq(dst, src); | |
| 1602 } else { | 1608 } else { |
| 1603 // Subtract by adding the negation. | 1609 // Subtract by adding the negation. |
| 1604 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); | 1610 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); |
| 1605 addq(dst, src); | 1611 addq(dst, src); |
| 1606 j(overflow, on_not_smi_result, near_jump); | 1612 j(overflow, bailout_label, near_jump); |
| 1607 } | 1613 } |
| 1608 } | 1614 } |
| 1609 } | 1615 } |
| 1610 | 1616 |
| 1611 | 1617 |
| 1612 void MacroAssembler::SmiNeg(Register dst, | 1618 void MacroAssembler::SmiNeg(Register dst, |
| 1613 Register src, | 1619 Register src, |
| 1614 Label* on_smi_result, | 1620 Label* on_smi_result, |
| 1615 Label::Distance near_jump) { | 1621 Label::Distance near_jump) { |
| 1616 if (dst.is(src)) { | 1622 if (dst.is(src)) { |
| (...skipping 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4927 j(greater, &no_memento_available); | 4933 j(greater, &no_memento_available); |
| 4928 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4934 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4929 Heap::kAllocationMementoMapRootIndex); | 4935 Heap::kAllocationMementoMapRootIndex); |
| 4930 bind(&no_memento_available); | 4936 bind(&no_memento_available); |
| 4931 } | 4937 } |
| 4932 | 4938 |
| 4933 | 4939 |
| 4934 } } // namespace v8::internal | 4940 } } // namespace v8::internal |
| 4935 | 4941 |
| 4936 #endif // V8_TARGET_ARCH_X64 | 4942 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |