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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arm/lithium-codegen-arm.h" | 7 #include "src/arm/lithium-codegen-arm.h" |
| 8 #include "src/arm/lithium-gap-resolver-arm.h" | 8 #include "src/arm/lithium-gap-resolver-arm.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/stub-cache.h" | 10 #include "src/stub-cache.h" |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 ASSERT(chunk_->LookupLiteralRepresentation(op).IsSmiOrTagged()); | 473 ASSERT(chunk_->LookupLiteralRepresentation(op).IsSmiOrTagged()); |
| 474 return constant->handle(isolate()); | 474 return constant->handle(isolate()); |
| 475 } | 475 } |
| 476 | 476 |
| 477 | 477 |
| 478 bool LCodeGen::IsInteger32(LConstantOperand* op) const { | 478 bool LCodeGen::IsInteger32(LConstantOperand* op) const { |
| 479 return chunk_->LookupLiteralRepresentation(op).IsSmiOrInteger32(); | 479 return chunk_->LookupLiteralRepresentation(op).IsSmiOrInteger32(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 | 482 |
| 483 template<class LI> | |
| 484 Operand LCodeGen::ToShiftedRightOperand(LOperand* right, LI* shift_info) { | |
| 485 if (shift_info->shift() == NO_SHIFT) { | |
| 486 return ToOperand(right); | |
| 487 } else { | |
| 488 return Operand( | |
| 489 ToRegister(right), | |
| 490 shift_info->shift(), | |
| 491 JSShiftAmountFromLConstant(shift_info->shift_amount())); | |
| 492 } | |
| 493 } | |
| 494 | |
| 495 | |
| 483 bool LCodeGen::IsSmi(LConstantOperand* op) const { | 496 bool LCodeGen::IsSmi(LConstantOperand* op) const { |
| 484 return chunk_->LookupLiteralRepresentation(op).IsSmi(); | 497 return chunk_->LookupLiteralRepresentation(op).IsSmi(); |
| 485 } | 498 } |
| 486 | 499 |
| 487 | 500 |
| 488 int32_t LCodeGen::ToInteger32(LConstantOperand* op) const { | 501 int32_t LCodeGen::ToInteger32(LConstantOperand* op) const { |
| 489 return ToRepresentation(op, Representation::Integer32()); | 502 return ToRepresentation(op, Representation::Integer32()); |
| 490 } | 503 } |
| 491 | 504 |
| 492 | 505 |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1703 | 1716 |
| 1704 | 1717 |
| 1705 void LCodeGen::DoBitI(LBitI* instr) { | 1718 void LCodeGen::DoBitI(LBitI* instr) { |
| 1706 LOperand* left_op = instr->left(); | 1719 LOperand* left_op = instr->left(); |
| 1707 LOperand* right_op = instr->right(); | 1720 LOperand* right_op = instr->right(); |
| 1708 ASSERT(left_op->IsRegister()); | 1721 ASSERT(left_op->IsRegister()); |
| 1709 Register left = ToRegister(left_op); | 1722 Register left = ToRegister(left_op); |
| 1710 Register result = ToRegister(instr->result()); | 1723 Register result = ToRegister(instr->result()); |
| 1711 Operand right(no_reg); | 1724 Operand right(no_reg); |
| 1712 | 1725 |
| 1726 ASSERT(right_op->IsRegister() || (instr->shift() == NO_SHIFT)); | |
| 1727 | |
| 1713 if (right_op->IsStackSlot()) { | 1728 if (right_op->IsStackSlot()) { |
| 1714 right = Operand(EmitLoadRegister(right_op, ip)); | 1729 right = Operand(EmitLoadRegister(right_op, ip)); |
| 1730 } else if (right_op->IsConstantOperand()) { | |
| 1731 right = ToOperand(right_op); | |
|
ulan
2014/06/10 11:53:37
Doesn't ToShiftedRightOperand take care of this ca
Alexandre Rames
2014/06/11 10:19:40
It does. Removed the constant case.
| |
| 1715 } else { | 1732 } else { |
| 1716 ASSERT(right_op->IsRegister() || right_op->IsConstantOperand()); | 1733 ASSERT(right_op->IsRegister()); |
| 1717 right = ToOperand(right_op); | 1734 right = ToShiftedRightOperand(right_op, instr); |
| 1718 } | 1735 } |
| 1719 | 1736 |
| 1720 switch (instr->op()) { | 1737 switch (instr->op()) { |
| 1721 case Token::BIT_AND: | 1738 case Token::BIT_AND: |
| 1722 __ and_(result, left, right); | 1739 __ and_(result, left, right); |
| 1723 break; | 1740 break; |
| 1724 case Token::BIT_OR: | 1741 case Token::BIT_OR: |
| 1725 __ orr(result, left, right); | 1742 __ orr(result, left, right); |
| 1726 break; | 1743 break; |
| 1727 case Token::BIT_XOR: | 1744 case Token::BIT_XOR: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1766 case Token::SHL: | 1783 case Token::SHL: |
| 1767 __ mov(result, Operand(left, LSL, scratch)); | 1784 __ mov(result, Operand(left, LSL, scratch)); |
| 1768 break; | 1785 break; |
| 1769 default: | 1786 default: |
| 1770 UNREACHABLE(); | 1787 UNREACHABLE(); |
| 1771 break; | 1788 break; |
| 1772 } | 1789 } |
| 1773 } else { | 1790 } else { |
| 1774 // Mask the right_op operand. | 1791 // Mask the right_op operand. |
| 1775 int value = ToInteger32(LConstantOperand::cast(right_op)); | 1792 int value = ToInteger32(LConstantOperand::cast(right_op)); |
| 1776 uint8_t shift_count = static_cast<uint8_t>(value & 0x1F); | 1793 uint8_t shift_count = static_cast<uint8_t>(value & 0x1F); |
|
ulan
2014/06/10 11:53:37
The original CL used JSShiftAmountFromLConstant he
Alexandre Rames
2014/06/11 10:19:40
Done.
| |
| 1777 switch (instr->op()) { | 1794 switch (instr->op()) { |
| 1778 case Token::ROR: | 1795 case Token::ROR: |
| 1779 if (shift_count != 0) { | 1796 if (shift_count != 0) { |
| 1780 __ mov(result, Operand(left, ROR, shift_count)); | 1797 __ mov(result, Operand(left, ROR, shift_count)); |
| 1781 } else { | 1798 } else { |
| 1782 __ Move(result, left); | 1799 __ Move(result, left); |
| 1783 } | 1800 } |
| 1784 break; | 1801 break; |
| 1785 case Token::SAR: | 1802 case Token::SAR: |
| 1786 if (shift_count != 0) { | 1803 if (shift_count != 0) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1826 } | 1843 } |
| 1827 | 1844 |
| 1828 | 1845 |
| 1829 void LCodeGen::DoSubI(LSubI* instr) { | 1846 void LCodeGen::DoSubI(LSubI* instr) { |
| 1830 LOperand* left = instr->left(); | 1847 LOperand* left = instr->left(); |
| 1831 LOperand* right = instr->right(); | 1848 LOperand* right = instr->right(); |
| 1832 LOperand* result = instr->result(); | 1849 LOperand* result = instr->result(); |
| 1833 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); | 1850 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
| 1834 SBit set_cond = can_overflow ? SetCC : LeaveCC; | 1851 SBit set_cond = can_overflow ? SetCC : LeaveCC; |
| 1835 | 1852 |
| 1853 ASSERT(right->IsRegister() || (instr->shift() == NO_SHIFT)); | |
| 1854 | |
| 1836 if (right->IsStackSlot()) { | 1855 if (right->IsStackSlot()) { |
| 1837 Register right_reg = EmitLoadRegister(right, ip); | 1856 Register right_reg = EmitLoadRegister(right, ip); |
| 1838 __ sub(ToRegister(result), ToRegister(left), Operand(right_reg), set_cond); | 1857 __ sub(ToRegister(result), ToRegister(left), Operand(right_reg), set_cond); |
| 1839 } else { | 1858 } else { |
| 1840 ASSERT(right->IsRegister() || right->IsConstantOperand()); | 1859 ASSERT(right->IsRegister() || right->IsConstantOperand()); |
| 1841 __ sub(ToRegister(result), ToRegister(left), ToOperand(right), set_cond); | 1860 __ sub(ToRegister(result), ToRegister(left), |
| 1861 ToShiftedRightOperand(right, instr), set_cond); | |
| 1842 } | 1862 } |
| 1843 | 1863 |
| 1844 if (can_overflow) { | 1864 if (can_overflow) { |
| 1845 DeoptimizeIf(vs, instr->environment()); | 1865 DeoptimizeIf(vs, instr->environment()); |
| 1846 } | 1866 } |
| 1847 } | 1867 } |
| 1848 | 1868 |
| 1849 | 1869 |
| 1850 void LCodeGen::DoRSubI(LRSubI* instr) { | 1870 void LCodeGen::DoRSubI(LRSubI* instr) { |
| 1851 LOperand* left = instr->left(); | 1871 LOperand* left = instr->left(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2020 } | 2040 } |
| 2021 | 2041 |
| 2022 | 2042 |
| 2023 void LCodeGen::DoAddI(LAddI* instr) { | 2043 void LCodeGen::DoAddI(LAddI* instr) { |
| 2024 LOperand* left = instr->left(); | 2044 LOperand* left = instr->left(); |
| 2025 LOperand* right = instr->right(); | 2045 LOperand* right = instr->right(); |
| 2026 LOperand* result = instr->result(); | 2046 LOperand* result = instr->result(); |
| 2027 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); | 2047 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
| 2028 SBit set_cond = can_overflow ? SetCC : LeaveCC; | 2048 SBit set_cond = can_overflow ? SetCC : LeaveCC; |
| 2029 | 2049 |
| 2050 ASSERT(right->IsRegister() || (instr->shift() == NO_SHIFT)); | |
| 2051 | |
| 2030 if (right->IsStackSlot()) { | 2052 if (right->IsStackSlot()) { |
| 2031 Register right_reg = EmitLoadRegister(right, ip); | 2053 Register right_reg = EmitLoadRegister(right, ip); |
| 2032 __ add(ToRegister(result), ToRegister(left), Operand(right_reg), set_cond); | 2054 __ add(ToRegister(result), ToRegister(left), Operand(right_reg), set_cond); |
| 2033 } else { | 2055 } else { |
| 2034 ASSERT(right->IsRegister() || right->IsConstantOperand()); | 2056 ASSERT(right->IsRegister() || right->IsConstantOperand()); |
| 2035 __ add(ToRegister(result), ToRegister(left), ToOperand(right), set_cond); | 2057 __ add(ToRegister(result), ToRegister(left), |
| 2058 ToShiftedRightOperand(right, instr), set_cond); | |
| 2036 } | 2059 } |
| 2037 | 2060 |
| 2038 if (can_overflow) { | 2061 if (can_overflow) { |
| 2039 DeoptimizeIf(vs, instr->environment()); | 2062 DeoptimizeIf(vs, instr->environment()); |
| 2040 } | 2063 } |
| 2041 } | 2064 } |
| 2042 | 2065 |
| 2043 | 2066 |
| 2044 void LCodeGen::DoMathMinMax(LMathMinMax* instr) { | 2067 void LCodeGen::DoMathMinMax(LMathMinMax* instr) { |
| 2045 LOperand* left = instr->left(); | 2068 LOperand* left = instr->left(); |
| (...skipping 3768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5814 __ ldr(result, FieldMemOperand(scratch, | 5837 __ ldr(result, FieldMemOperand(scratch, |
| 5815 FixedArray::kHeaderSize - kPointerSize)); | 5838 FixedArray::kHeaderSize - kPointerSize)); |
| 5816 __ bind(deferred->exit()); | 5839 __ bind(deferred->exit()); |
| 5817 __ bind(&done); | 5840 __ bind(&done); |
| 5818 } | 5841 } |
| 5819 | 5842 |
| 5820 | 5843 |
| 5821 #undef __ | 5844 #undef __ |
| 5822 | 5845 |
| 5823 } } // namespace v8::internal | 5846 } } // namespace v8::internal |
| OLD | NEW |