| 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 3888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 void StringCharacterStream::VisitTwoByteString( | 3899 void StringCharacterStream::VisitTwoByteString( |
| 3900 const uint16_t* chars, int length) { | 3900 const uint16_t* chars, int length) { |
| 3901 is_one_byte_ = false; | 3901 is_one_byte_ = false; |
| 3902 buffer16_ = chars; | 3902 buffer16_ = chars; |
| 3903 end_ = reinterpret_cast<const uint8_t*>(chars + length); | 3903 end_ = reinterpret_cast<const uint8_t*>(chars + length); |
| 3904 } | 3904 } |
| 3905 | 3905 |
| 3906 | 3906 |
| 3907 int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } | 3907 int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } |
| 3908 | 3908 |
| 3909 | |
| 3910 byte ByteArray::get(int index) { | 3909 byte ByteArray::get(int index) { |
| 3911 DCHECK(index >= 0 && index < this->length()); | 3910 DCHECK(index >= 0 && index < this->length()); |
| 3912 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 3911 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| 3913 } | 3912 } |
| 3914 | 3913 |
| 3915 | 3914 |
| 3916 void ByteArray::set(int index, byte value) { | 3915 void ByteArray::set(int index, byte value) { |
| 3917 DCHECK(index >= 0 && index < this->length()); | 3916 DCHECK(index >= 0 && index < this->length()); |
| 3918 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 3917 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
| 3919 } | 3918 } |
| 3920 | 3919 |
| 3920 void ByteArray::copy_in(int index, const byte* buffer, int length) { |
| 3921 DCHECK(index >= 0 && length >= 0 && index + length >= index && |
| 3922 index + length <= this->length()); |
| 3923 byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); |
| 3924 memcpy(dst_addr, buffer, length); |
| 3925 } |
| 3926 |
| 3927 void ByteArray::copy_out(int index, byte* buffer, int length) { |
| 3928 DCHECK(index >= 0 && length >= 0 && index + length >= index && |
| 3929 index + length <= this->length()); |
| 3930 const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); |
| 3931 memcpy(buffer, src_addr, length); |
| 3932 } |
| 3921 | 3933 |
| 3922 int ByteArray::get_int(int index) { | 3934 int ByteArray::get_int(int index) { |
| 3923 DCHECK(index >= 0 && (index * kIntSize) < this->length()); | 3935 DCHECK(index >= 0 && index < this->length() / kIntSize); |
| 3924 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); | 3936 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); |
| 3925 } | 3937 } |
| 3926 | 3938 |
| 3939 void ByteArray::set_int(int index, int value) { |
| 3940 DCHECK(index >= 0 && index < this->length() / kIntSize); |
| 3941 WRITE_INT_FIELD(this, kHeaderSize + index * kIntSize, value); |
| 3942 } |
| 3927 | 3943 |
| 3928 ByteArray* ByteArray::FromDataStartAddress(Address address) { | 3944 ByteArray* ByteArray::FromDataStartAddress(Address address) { |
| 3929 DCHECK_TAG_ALIGNED(address); | 3945 DCHECK_TAG_ALIGNED(address); |
| 3930 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); | 3946 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); |
| 3931 } | 3947 } |
| 3932 | 3948 |
| 3933 | 3949 |
| 3934 int ByteArray::ByteArraySize() { return SizeFor(this->length()); } | 3950 int ByteArray::ByteArraySize() { return SizeFor(this->length()); } |
| 3935 | 3951 |
| 3936 | 3952 |
| (...skipping 3898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7835 #undef WRITE_INT64_FIELD | 7851 #undef WRITE_INT64_FIELD |
| 7836 #undef READ_BYTE_FIELD | 7852 #undef READ_BYTE_FIELD |
| 7837 #undef WRITE_BYTE_FIELD | 7853 #undef WRITE_BYTE_FIELD |
| 7838 #undef NOBARRIER_READ_BYTE_FIELD | 7854 #undef NOBARRIER_READ_BYTE_FIELD |
| 7839 #undef NOBARRIER_WRITE_BYTE_FIELD | 7855 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7840 | 7856 |
| 7841 } // namespace internal | 7857 } // namespace internal |
| 7842 } // namespace v8 | 7858 } // namespace v8 |
| 7843 | 7859 |
| 7844 #endif // V8_OBJECTS_INL_H_ | 7860 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |