Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 2ed61579ab0d4820da15db836edc7259e0bc2c72..c1ba60e972ab35b3c6b72e783a04cf91d099e8c3 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -6723,10 +6723,18 @@ class Map: public HeapObject { |
| static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; |
| // Byte offsets within kInstanceAttributesOffset attributes. |
| +#if V8_TARGET_LITTLE_ENDIAN |
| + // Order instance type and bit field together such that they can be loaded |
| + // together as a 16-bit word with instance type in the lower 8 bits regardless |
| + // of endianess. |
| static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
| - static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
| - static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
| - static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
| + static const int kBitFieldOffset = kInstanceAttributesOffset + 1; |
| +#else |
| + static const int kBitFieldOffset = kInstanceAttributesOffset + 0; |
| + static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1; |
| +#endif |
| + static const int kBitField2Offset = kInstanceAttributesOffset + 2; |
| + static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3; |
| STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); |
|
mtbrandy
2014/06/17 13:45:40
This change introduces a mismatch between kInstanc
|
| @@ -9048,6 +9056,33 @@ class String: public Name { |
| public: |
| enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }; |
| + // Array index strings this short can keep their index in the hash field. |
| + static const int kMaxCachedArrayIndexLength = 7; |
| + |
| + // For strings which are array indexes the hash value has the string length |
| + // mixed into the hash, mainly to avoid a hash value of zero which would be |
| + // the case for the string '0'. 24 bits are used for the array index value. |
| + static const int kArrayIndexValueBits = 24; |
| + static const int kArrayIndexLengthBits = |
| + kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields; |
| + |
| + STATIC_ASSERT((kArrayIndexLengthBits > 0)); |
| + |
| + class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields, |
| + kArrayIndexValueBits> {}; // NOLINT |
| + class ArrayIndexLengthBits : public BitField<unsigned int, |
| + kNofHashBitFields + kArrayIndexValueBits, |
| + kArrayIndexLengthBits> {}; // NOLINT |
| + |
| + // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we |
| + // could use a mask to test if the length of string is less than or equal to |
| + // kMaxCachedArrayIndexLength. |
| + STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1)); |
| + |
| + static const unsigned int kContainsCachedArrayIndexMask = |
| + (~kMaxCachedArrayIndexLength << ArrayIndexLengthBits::kShift) | |
| + kIsNotArrayIndexMask; |
| + |
| // Representation of the flat content of a String. |
| // A non-flat string doesn't have flat content. |
| // A flat string has content that's encoded as a sequence of either |