OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 1632 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
1633 } | 1633 } |
1634 | 1634 |
1635 | 1635 |
1636 void ExternalAsciiString::set_resource( | 1636 void ExternalAsciiString::set_resource( |
1637 ExternalAsciiString::Resource* resource) { | 1637 ExternalAsciiString::Resource* resource) { |
1638 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; | 1638 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; |
1639 } | 1639 } |
1640 | 1640 |
1641 | 1641 |
| 1642 Map* ExternalAsciiString::StringMap(int length) { |
| 1643 Map* map; |
| 1644 // Number of characters: determines the map. |
| 1645 if (length <= String::kMaxShortStringSize) { |
| 1646 map = Heap::short_external_ascii_string_map(); |
| 1647 } else if (length <= String::kMaxMediumStringSize) { |
| 1648 map = Heap::medium_external_ascii_string_map(); |
| 1649 } else { |
| 1650 map = Heap::long_external_ascii_string_map(); |
| 1651 } |
| 1652 return map; |
| 1653 } |
| 1654 |
| 1655 |
| 1656 Map* ExternalAsciiString::SymbolMap(int length) { |
| 1657 Map* map; |
| 1658 // Number of characters: determines the map. |
| 1659 if (length <= String::kMaxShortStringSize) { |
| 1660 map = Heap::short_external_ascii_symbol_map(); |
| 1661 } else if (length <= String::kMaxMediumStringSize) { |
| 1662 map = Heap::medium_external_ascii_symbol_map(); |
| 1663 } else { |
| 1664 map = Heap::long_external_ascii_symbol_map(); |
| 1665 } |
| 1666 return map; |
| 1667 } |
| 1668 |
| 1669 |
1642 ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { | 1670 ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { |
1643 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 1671 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
1644 } | 1672 } |
1645 | 1673 |
1646 | 1674 |
1647 void ExternalTwoByteString::set_resource( | 1675 void ExternalTwoByteString::set_resource( |
1648 ExternalTwoByteString::Resource* resource) { | 1676 ExternalTwoByteString::Resource* resource) { |
1649 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; | 1677 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; |
1650 } | 1678 } |
1651 | 1679 |
1652 | 1680 |
| 1681 Map* ExternalTwoByteString::StringMap(int length) { |
| 1682 Map* map; |
| 1683 // Number of characters: determines the map. |
| 1684 if (length <= String::kMaxShortStringSize) { |
| 1685 map = Heap::short_external_string_map(); |
| 1686 } else if (length <= String::kMaxMediumStringSize) { |
| 1687 map = Heap::medium_external_string_map(); |
| 1688 } else { |
| 1689 map = Heap::long_external_string_map(); |
| 1690 } |
| 1691 return map; |
| 1692 } |
| 1693 |
| 1694 |
| 1695 Map* ExternalTwoByteString::SymbolMap(int length) { |
| 1696 Map* map; |
| 1697 // Number of characters: determines the map. |
| 1698 if (length <= String::kMaxShortStringSize) { |
| 1699 map = Heap::short_external_symbol_map(); |
| 1700 } else if (length <= String::kMaxMediumStringSize) { |
| 1701 map = Heap::medium_external_symbol_map(); |
| 1702 } else { |
| 1703 map = Heap::long_external_symbol_map(); |
| 1704 } |
| 1705 return map; |
| 1706 } |
| 1707 |
| 1708 |
1653 byte ByteArray::get(int index) { | 1709 byte ByteArray::get(int index) { |
1654 ASSERT(index >= 0 && index < this->length()); | 1710 ASSERT(index >= 0 && index < this->length()); |
1655 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 1711 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
1656 } | 1712 } |
1657 | 1713 |
1658 | 1714 |
1659 void ByteArray::set(int index, byte value) { | 1715 void ByteArray::set(int index, byte value) { |
1660 ASSERT(index >= 0 && index < this->length()); | 1716 ASSERT(index >= 0 && index < this->length()); |
1661 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 1717 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
1662 } | 1718 } |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 #undef WRITE_INT_FIELD | 2552 #undef WRITE_INT_FIELD |
2497 #undef READ_SHORT_FIELD | 2553 #undef READ_SHORT_FIELD |
2498 #undef WRITE_SHORT_FIELD | 2554 #undef WRITE_SHORT_FIELD |
2499 #undef READ_BYTE_FIELD | 2555 #undef READ_BYTE_FIELD |
2500 #undef WRITE_BYTE_FIELD | 2556 #undef WRITE_BYTE_FIELD |
2501 | 2557 |
2502 | 2558 |
2503 } } // namespace v8::internal | 2559 } } // namespace v8::internal |
2504 | 2560 |
2505 #endif // V8_OBJECTS_INL_H_ | 2561 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |