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 3835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3846 } | 3846 } |
3847 | 3847 |
3848 | 3848 |
3849 template <> | 3849 template <> |
3850 inline Vector<const uc16> String::GetCharVector() { | 3850 inline Vector<const uc16> String::GetCharVector() { |
3851 String::FlatContent flat = GetFlatContent(); | 3851 String::FlatContent flat = GetFlatContent(); |
3852 DCHECK(flat.IsTwoByte()); | 3852 DCHECK(flat.IsTwoByte()); |
3853 return flat.ToUC16Vector(); | 3853 return flat.ToUC16Vector(); |
3854 } | 3854 } |
3855 | 3855 |
| 3856 uint32_t String::ToValidIndex(Object* number) { |
| 3857 uint32_t index = PositiveNumberToUint32(number); |
| 3858 uint32_t length_value = static_cast<uint32_t>(length()); |
| 3859 if (index > length_value) return length_value; |
| 3860 return index; |
| 3861 } |
3856 | 3862 |
3857 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) { | 3863 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) { |
3858 DCHECK(index >= 0 && index < length()); | 3864 DCHECK(index >= 0 && index < length()); |
3859 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 3865 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
3860 } | 3866 } |
3861 | 3867 |
3862 | 3868 |
3863 void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) { | 3869 void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) { |
3864 DCHECK(index >= 0 && index < length() && value <= kMaxOneByteCharCode); | 3870 DCHECK(index >= 0 && index < length() && value <= kMaxOneByteCharCode); |
3865 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, | 3871 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, |
(...skipping 4619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8485 #undef WRITE_INT64_FIELD | 8491 #undef WRITE_INT64_FIELD |
8486 #undef READ_BYTE_FIELD | 8492 #undef READ_BYTE_FIELD |
8487 #undef WRITE_BYTE_FIELD | 8493 #undef WRITE_BYTE_FIELD |
8488 #undef NOBARRIER_READ_BYTE_FIELD | 8494 #undef NOBARRIER_READ_BYTE_FIELD |
8489 #undef NOBARRIER_WRITE_BYTE_FIELD | 8495 #undef NOBARRIER_WRITE_BYTE_FIELD |
8490 | 8496 |
8491 } // namespace internal | 8497 } // namespace internal |
8492 } // namespace v8 | 8498 } // namespace v8 |
8493 | 8499 |
8494 #endif // V8_OBJECTS_INL_H_ | 8500 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |