Chromium Code Reviews| 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)); |
| 1578 if (constant->value() == Smi::kMinValue) { | 1579 LoadSmiConstant(kScratchRegister, constant); |
| 1579 // Subtracting min-value from any non-negative value will overflow. | 1580 subq(dst, kScratchRegister); |
| 1580 // We test the non-negativeness before doing the subtraction. | 1581 if (mode.Contains(BAILOUT_ON_NO_OVERFLOW)) { |
| 1581 testq(src, src); | 1582 j(no_overflow, bailout_label, near_jump); |
| 1582 j(not_sign, on_not_smi_result, near_jump); | 1583 ASSERT(mode.Contains(NEED_RESERVE_SOURCES)); |
| 1583 LoadSmiConstant(kScratchRegister, constant); | 1584 addq(dst, kScratchRegister); |
| 1584 subq(dst, kScratchRegister); | 1585 } else if (mode.Contains(BAILOUT_ON_OVERFLOW)) { |
| 1586 if (mode.Contains(NEED_RESERVE_SOURCES)) { | |
| 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 // Implement this when SimSubConstant is invoked from Crankshaft. | |
| 1594 UNIMPLEMENTED(); // Not used. | |
|
danno
2013/10/14 18:30:45
I would feel more comfortable if you implemented t
haitao.feng
2013/10/16 09:17:01
Done.
| |
| 1595 } | |
| 1585 } else { | 1596 } else { |
| 1586 // Subtract by adding the negation. | 1597 ASSERT(mode.IsEmpty()); |
|
danno
2013/10/14 18:30:45
Turn this ASSERT into a CHECK
haitao.feng
2013/10/16 09:17:01
Done.
| |
| 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 } | 1598 } |
| 1592 } else { | 1599 } else { |
| 1593 if (constant->value() == Smi::kMinValue) { | 1600 UNIMPLEMENTED(); // Not used. |
|
danno
2013/10/14 18:30:45
I would feel more comfortable if you implemented t
haitao.feng
2013/10/16 09:17:01
Done.
| |
| 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 { | |
| 1603 // Subtract by adding the negation. | |
| 1604 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); | |
| 1605 addq(dst, src); | |
| 1606 j(overflow, on_not_smi_result, near_jump); | |
| 1607 } | |
| 1608 } | 1601 } |
| 1609 } | 1602 } |
| 1610 | 1603 |
| 1611 | 1604 |
| 1612 void MacroAssembler::SmiNeg(Register dst, | 1605 void MacroAssembler::SmiNeg(Register dst, |
| 1613 Register src, | 1606 Register src, |
| 1614 Label* on_smi_result, | 1607 Label* on_smi_result, |
| 1615 Label::Distance near_jump) { | 1608 Label::Distance near_jump) { |
| 1616 if (dst.is(src)) { | 1609 if (dst.is(src)) { |
| 1617 ASSERT(!dst.is(kScratchRegister)); | 1610 ASSERT(!dst.is(kScratchRegister)); |
| (...skipping 3309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4927 j(greater, &no_memento_available); | 4920 j(greater, &no_memento_available); |
| 4928 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4921 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4929 Heap::kAllocationMementoMapRootIndex); | 4922 Heap::kAllocationMementoMapRootIndex); |
| 4930 bind(&no_memento_available); | 4923 bind(&no_memento_available); |
| 4931 } | 4924 } |
| 4932 | 4925 |
| 4933 | 4926 |
| 4934 } } // namespace v8::internal | 4927 } } // namespace v8::internal |
| 4935 | 4928 |
| 4936 #endif // V8_TARGET_ARCH_X64 | 4929 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |