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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 | 1251 |
1252 #define WRITE_INT_FIELD(p, offset, value) \ | 1252 #define WRITE_INT_FIELD(p, offset, value) \ |
1253 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value) | 1253 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value) |
1254 | 1254 |
1255 #define READ_INTPTR_FIELD(p, offset) \ | 1255 #define READ_INTPTR_FIELD(p, offset) \ |
1256 (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset))) | 1256 (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset))) |
1257 | 1257 |
1258 #define WRITE_INTPTR_FIELD(p, offset, value) \ | 1258 #define WRITE_INTPTR_FIELD(p, offset, value) \ |
1259 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) | 1259 (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) |
1260 | 1260 |
| 1261 #define READ_UINT8_FIELD(p, offset) \ |
| 1262 (*reinterpret_cast<const uint8_t*>(FIELD_ADDR_CONST(p, offset))) |
| 1263 |
| 1264 #define WRITE_UINT8_FIELD(p, offset, value) \ |
| 1265 (*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value) |
| 1266 |
| 1267 #define READ_INT8_FIELD(p, offset) \ |
| 1268 (*reinterpret_cast<const int8_t*>(FIELD_ADDR_CONST(p, offset))) |
| 1269 |
| 1270 #define WRITE_INT8_FIELD(p, offset, value) \ |
| 1271 (*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value) |
| 1272 |
1261 #define READ_UINT16_FIELD(p, offset) \ | 1273 #define READ_UINT16_FIELD(p, offset) \ |
1262 (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset))) | 1274 (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset))) |
1263 | 1275 |
1264 #define WRITE_UINT16_FIELD(p, offset, value) \ | 1276 #define WRITE_UINT16_FIELD(p, offset, value) \ |
1265 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value) | 1277 (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value) |
1266 | 1278 |
1267 #define READ_INT16_FIELD(p, offset) \ | 1279 #define READ_INT16_FIELD(p, offset) \ |
1268 (*reinterpret_cast<const int16_t*>(FIELD_ADDR_CONST(p, offset))) | 1280 (*reinterpret_cast<const int16_t*>(FIELD_ADDR_CONST(p, offset))) |
1269 | 1281 |
1270 #define WRITE_INT16_FIELD(p, offset, value) \ | 1282 #define WRITE_INT16_FIELD(p, offset, value) \ |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 bool Type::Equals(Type* that) { \ | 1549 bool Type::Equals(Type* that) { \ |
1538 for (int lane = 0; lane < lane_count; ++lane) { \ | 1550 for (int lane = 0; lane < lane_count; ++lane) { \ |
1539 if (this->get_lane(lane) != that->get_lane(lane)) return false; \ | 1551 if (this->get_lane(lane) != that->get_lane(lane)) return false; \ |
1540 } \ | 1552 } \ |
1541 return true; \ | 1553 return true; \ |
1542 } | 1554 } |
1543 SIMD128_TYPES(SIMD128_VALUE_EQUALS) | 1555 SIMD128_TYPES(SIMD128_VALUE_EQUALS) |
1544 #undef SIMD128_VALUE_EQUALS | 1556 #undef SIMD128_VALUE_EQUALS |
1545 | 1557 |
1546 | 1558 |
1547 float Float32x4::get_lane(int lane) const { | |
1548 DCHECK(lane < 4 && lane >= 0); | |
1549 #if defined(V8_TARGET_LITTLE_ENDIAN) | 1559 #if defined(V8_TARGET_LITTLE_ENDIAN) |
1550 return READ_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize); | 1560 #define SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \ |
| 1561 lane_type value = \ |
| 1562 READ_##field_type##_FIELD(this, kValueOffset + lane * field_size); |
1551 #elif defined(V8_TARGET_BIG_ENDIAN) | 1563 #elif defined(V8_TARGET_BIG_ENDIAN) |
1552 return READ_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize); | 1564 #define SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \ |
| 1565 lane_type value = READ_##field_type##_FIELD( \ |
| 1566 this, kValueOffset + (lane_count - lane - 1) * field_size); |
1553 #else | 1567 #else |
1554 #error Unknown byte ordering | 1568 #error Unknown byte ordering |
1555 #endif | 1569 #endif |
1556 } | |
1557 | 1570 |
1558 | |
1559 void Float32x4::set_lane(int lane, float value) { | |
1560 DCHECK(lane < 4 && lane >= 0); | |
1561 #if defined(V8_TARGET_LITTLE_ENDIAN) | 1571 #if defined(V8_TARGET_LITTLE_ENDIAN) |
1562 WRITE_FLOAT_FIELD(this, kValueOffset + lane * kFloatSize, value); | 1572 #define SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \ |
| 1573 WRITE_##field_type##_FIELD(this, kValueOffset + lane * field_size, value); |
1563 #elif defined(V8_TARGET_BIG_ENDIAN) | 1574 #elif defined(V8_TARGET_BIG_ENDIAN) |
1564 WRITE_FLOAT_FIELD(this, kValueOffset + (3 - lane) * kFloatSize, value); | 1575 #define SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \ |
| 1576 WRITE_##field_type##_FIELD( \ |
| 1577 this, kValueOffset + (lane_count - lane - 1) * field_size, value); |
1565 #else | 1578 #else |
1566 #error Unknown byte ordering | 1579 #error Unknown byte ordering |
1567 #endif | 1580 #endif |
1568 } | 1581 |
| 1582 #define SIMD128_NUMERIC_LANE_FNS(type, lane_type, lane_count, field_type, \ |
| 1583 field_size) \ |
| 1584 lane_type type::get_lane(int lane) const { \ |
| 1585 DCHECK(lane < lane_count && lane >= 0); \ |
| 1586 SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \ |
| 1587 return value; \ |
| 1588 } \ |
| 1589 \ |
| 1590 void type::set_lane(int lane, lane_type value) { \ |
| 1591 DCHECK(lane < lane_count && lane >= 0); \ |
| 1592 SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \ |
| 1593 } |
| 1594 |
| 1595 SIMD128_NUMERIC_LANE_FNS(Float32x4, float, 4, FLOAT, kFloatSize) |
| 1596 SIMD128_NUMERIC_LANE_FNS(Int32x4, int32_t, 4, INT32, kInt32Size) |
| 1597 SIMD128_NUMERIC_LANE_FNS(Int16x8, int16_t, 8, INT16, kShortSize) |
| 1598 SIMD128_NUMERIC_LANE_FNS(Int8x16, int8_t, 16, INT8, kCharSize) |
| 1599 #undef SIMD128_NUMERIC_LANE_FNS |
1569 | 1600 |
1570 | 1601 |
1571 int32_t Int32x4::get_lane(int lane) const { | 1602 #define SIMD128_BOOLEAN_LANE_FNS(type, lane_type, lane_count, field_type, \ |
1572 DCHECK(lane < 4 && lane >= 0); | 1603 field_size) \ |
1573 #if defined(V8_TARGET_LITTLE_ENDIAN) | 1604 bool type::get_lane(int lane) const { \ |
1574 return READ_INT32_FIELD(this, kValueOffset + lane * kInt32Size); | 1605 DCHECK(lane < lane_count && lane >= 0); \ |
1575 #elif defined(V8_TARGET_BIG_ENDIAN) | 1606 SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \ |
1576 return READ_INT32_FIELD(this, kValueOffset + (3 - lane) * kInt32Size); | 1607 DCHECK(value == 0 || value == -1); \ |
1577 #else | 1608 return value != 0; \ |
1578 #error Unknown byte ordering | 1609 } \ |
1579 #endif | 1610 \ |
1580 } | 1611 void type::set_lane(int lane, bool value) { \ |
| 1612 DCHECK(lane < lane_count && lane >= 0); \ |
| 1613 int32_t int_val = value ? -1 : 0; \ |
| 1614 SIMD128_WRITE_LANE(lane_count, field_type, field_size, int_val) \ |
| 1615 } |
1581 | 1616 |
| 1617 SIMD128_BOOLEAN_LANE_FNS(Bool32x4, int32_t, 4, INT32, kInt32Size) |
| 1618 SIMD128_BOOLEAN_LANE_FNS(Bool16x8, int16_t, 8, INT16, kShortSize) |
| 1619 SIMD128_BOOLEAN_LANE_FNS(Bool8x16, int8_t, 16, INT8, kCharSize) |
| 1620 #undef SIMD128_BOOLEAN_LANE_FNS |
1582 | 1621 |
1583 void Int32x4::set_lane(int lane, int32_t value) { | 1622 #undef SIMD128_READ_LANE |
1584 DCHECK(lane < 4 && lane >= 0); | 1623 #undef SIMD128_WRITE_LANE |
1585 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1586 WRITE_INT32_FIELD(this, kValueOffset + lane * kInt32Size, value); | |
1587 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1588 WRITE_INT32_FIELD(this, kValueOffset + (3 - lane) * kInt32Size, value); | |
1589 #else | |
1590 #error Unknown byte ordering | |
1591 #endif | |
1592 } | |
1593 | |
1594 | |
1595 bool Bool32x4::get_lane(int lane) const { | |
1596 DCHECK(lane < 4 && lane >= 0); | |
1597 int32_t value; | |
1598 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1599 value = READ_INT32_FIELD(this, kValueOffset + lane * kInt32Size); | |
1600 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1601 value = READ_INT32_FIELD(this, kValueOffset + (3 - lane) * kInt32Size); | |
1602 #else | |
1603 #error Unknown byte ordering | |
1604 #endif | |
1605 DCHECK(value == 0 || value == -1); | |
1606 return value != 0; | |
1607 } | |
1608 | |
1609 | |
1610 void Bool32x4::set_lane(int lane, bool value) { | |
1611 DCHECK(lane < 4 && lane >= 0); | |
1612 int32_t int_val = value ? -1 : 0; | |
1613 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1614 WRITE_INT32_FIELD(this, kValueOffset + lane * kInt32Size, int_val); | |
1615 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1616 WRITE_INT32_FIELD(this, kValueOffset + (3 - lane) * kInt32Size, int_val); | |
1617 #else | |
1618 #error Unknown byte ordering | |
1619 #endif | |
1620 } | |
1621 | |
1622 | |
1623 int16_t Int16x8::get_lane(int lane) const { | |
1624 DCHECK(lane < 8 && lane >= 0); | |
1625 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1626 return READ_INT16_FIELD(this, kValueOffset + lane * kShortSize); | |
1627 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1628 return READ_INT16_FIELD(this, kValueOffset + (7 - lane) * kShortSize); | |
1629 #else | |
1630 #error Unknown byte ordering | |
1631 #endif | |
1632 } | |
1633 | |
1634 | |
1635 void Int16x8::set_lane(int lane, int16_t value) { | |
1636 DCHECK(lane < 8 && lane >= 0); | |
1637 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1638 WRITE_INT16_FIELD(this, kValueOffset + lane * kShortSize, value); | |
1639 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1640 WRITE_INT16_FIELD(this, kValueOffset + (7 - lane) * kShortSize, value); | |
1641 #else | |
1642 #error Unknown byte ordering | |
1643 #endif | |
1644 } | |
1645 | |
1646 | |
1647 bool Bool16x8::get_lane(int lane) const { | |
1648 DCHECK(lane < 8 && lane >= 0); | |
1649 int16_t value; | |
1650 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1651 return READ_INT16_FIELD(this, kValueOffset + lane * kShortSize); | |
1652 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1653 return READ_INT16_FIELD(this, kValueOffset + (7 - lane) * kShortSize); | |
1654 #else | |
1655 #error Unknown byte ordering | |
1656 #endif | |
1657 DCHECK(value == 0 || value == -1); | |
1658 return value != 0; | |
1659 } | |
1660 | |
1661 | |
1662 void Bool16x8::set_lane(int lane, bool value) { | |
1663 DCHECK(lane < 8 && lane >= 0); | |
1664 int16_t int_val = value ? -1 : 0; | |
1665 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1666 WRITE_INT16_FIELD(this, kValueOffset + lane * kShortSize, int_val); | |
1667 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1668 WRITE_INT16_FIELD(this, kValueOffset + (7 - lane) * kShortSize, int_val); | |
1669 #else | |
1670 #error Unknown byte ordering | |
1671 #endif | |
1672 } | |
1673 | |
1674 | |
1675 int8_t Int8x16::get_lane(int lane) const { | |
1676 DCHECK(lane < 16 && lane >= 0); | |
1677 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1678 return READ_BYTE_FIELD(this, kValueOffset + lane * kCharSize); | |
1679 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1680 return READ_BYTE_FIELD(this, kValueOffset + (15 - lane) * kCharSize); | |
1681 #else | |
1682 #error Unknown byte ordering | |
1683 #endif | |
1684 } | |
1685 | |
1686 | |
1687 void Int8x16::set_lane(int lane, int8_t value) { | |
1688 DCHECK(lane < 16 && lane >= 0); | |
1689 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1690 WRITE_BYTE_FIELD(this, kValueOffset + lane * kCharSize, value); | |
1691 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1692 WRITE_BYTE_FIELD(this, kValueOffset + (15 - lane) * kCharSize, value); | |
1693 #else | |
1694 #error Unknown byte ordering | |
1695 #endif | |
1696 } | |
1697 | |
1698 | |
1699 bool Bool8x16::get_lane(int lane) const { | |
1700 DCHECK(lane < 16 && lane >= 0); | |
1701 int8_t value; | |
1702 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1703 value = READ_BYTE_FIELD(this, kValueOffset + lane * kCharSize); | |
1704 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1705 value = READ_BYTE_FIELD(this, kValueOffset + (15 - lane) * kCharSize); | |
1706 #else | |
1707 #error Unknown byte ordering | |
1708 #endif | |
1709 DCHECK(value == 0 || value == -1); | |
1710 return value != 0; | |
1711 } | |
1712 | |
1713 | |
1714 void Bool8x16::set_lane(int lane, bool value) { | |
1715 DCHECK(lane < 16 && lane >= 0); | |
1716 int8_t int_val = value ? -1 : 0; | |
1717 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
1718 WRITE_BYTE_FIELD(this, kValueOffset + lane * kCharSize, int_val); | |
1719 #elif defined(V8_TARGET_BIG_ENDIAN) | |
1720 WRITE_BYTE_FIELD(this, kValueOffset + (15 - lane) * kCharSize, int_val); | |
1721 #else | |
1722 #error Unknown byte ordering | |
1723 #endif | |
1724 } | |
1725 | 1624 |
1726 | 1625 |
1727 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) | 1626 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) |
1728 | 1627 |
1729 | 1628 |
1730 Object** FixedArray::GetFirstElementAddress() { | 1629 Object** FixedArray::GetFirstElementAddress() { |
1731 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); | 1630 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); |
1732 } | 1631 } |
1733 | 1632 |
1734 | 1633 |
(...skipping 6158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7893 #undef WRITE_FIELD | 7792 #undef WRITE_FIELD |
7894 #undef NOBARRIER_WRITE_FIELD | 7793 #undef NOBARRIER_WRITE_FIELD |
7895 #undef WRITE_BARRIER | 7794 #undef WRITE_BARRIER |
7896 #undef CONDITIONAL_WRITE_BARRIER | 7795 #undef CONDITIONAL_WRITE_BARRIER |
7897 #undef READ_DOUBLE_FIELD | 7796 #undef READ_DOUBLE_FIELD |
7898 #undef WRITE_DOUBLE_FIELD | 7797 #undef WRITE_DOUBLE_FIELD |
7899 #undef READ_INT_FIELD | 7798 #undef READ_INT_FIELD |
7900 #undef WRITE_INT_FIELD | 7799 #undef WRITE_INT_FIELD |
7901 #undef READ_INTPTR_FIELD | 7800 #undef READ_INTPTR_FIELD |
7902 #undef WRITE_INTPTR_FIELD | 7801 #undef WRITE_INTPTR_FIELD |
| 7802 #undef READ_UINT8_FIELD |
| 7803 #undef WRITE_UINT8_FIELD |
| 7804 #undef READ_INT8_FIELD |
| 7805 #undef WRITE_INT8_FIELD |
7903 #undef READ_UINT16_FIELD | 7806 #undef READ_UINT16_FIELD |
7904 #undef WRITE_UINT16_FIELD | 7807 #undef WRITE_UINT16_FIELD |
7905 #undef READ_INT16_FIELD | 7808 #undef READ_INT16_FIELD |
7906 #undef WRITE_INT16_FIELD | 7809 #undef WRITE_INT16_FIELD |
7907 #undef READ_UINT32_FIELD | 7810 #undef READ_UINT32_FIELD |
7908 #undef WRITE_UINT32_FIELD | 7811 #undef WRITE_UINT32_FIELD |
7909 #undef READ_INT32_FIELD | 7812 #undef READ_INT32_FIELD |
7910 #undef WRITE_INT32_FIELD | 7813 #undef WRITE_INT32_FIELD |
7911 #undef READ_FLOAT_FIELD | 7814 #undef READ_FLOAT_FIELD |
7912 #undef WRITE_FLOAT_FIELD | 7815 #undef WRITE_FLOAT_FIELD |
7913 #undef READ_UINT64_FIELD | 7816 #undef READ_UINT64_FIELD |
7914 #undef WRITE_UINT64_FIELD | 7817 #undef WRITE_UINT64_FIELD |
7915 #undef READ_INT64_FIELD | 7818 #undef READ_INT64_FIELD |
7916 #undef WRITE_INT64_FIELD | 7819 #undef WRITE_INT64_FIELD |
7917 #undef READ_BYTE_FIELD | 7820 #undef READ_BYTE_FIELD |
7918 #undef WRITE_BYTE_FIELD | 7821 #undef WRITE_BYTE_FIELD |
7919 #undef NOBARRIER_READ_BYTE_FIELD | 7822 #undef NOBARRIER_READ_BYTE_FIELD |
7920 #undef NOBARRIER_WRITE_BYTE_FIELD | 7823 #undef NOBARRIER_WRITE_BYTE_FIELD |
7921 | 7824 |
7922 } } // namespace v8::internal | 7825 } } // namespace v8::internal |
7923 | 7826 |
7924 #endif // V8_OBJECTS_INL_H_ | 7827 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |