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 4108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4119 DCHECK(index >= 0 && index < this->length()); | 4119 DCHECK(index >= 0 && index < this->length()); |
4120 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 4120 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
4121 } | 4121 } |
4122 | 4122 |
4123 void ByteArray::set(int index, byte value) { | 4123 void ByteArray::set(int index, byte value) { |
4124 DCHECK(index >= 0 && index < this->length()); | 4124 DCHECK(index >= 0 && index < this->length()); |
4125 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 4125 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
4126 } | 4126 } |
4127 | 4127 |
4128 void ByteArray::copy_in(int index, const byte* buffer, int length) { | 4128 void ByteArray::copy_in(int index, const byte* buffer, int length) { |
4129 DCHECK(index >= 0 && length >= 0 && index + length >= index && | 4129 DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index && |
4130 index + length <= this->length()); | 4130 index + length <= this->length()); |
4131 byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); | 4131 byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); |
4132 memcpy(dst_addr, buffer, length); | 4132 memcpy(dst_addr, buffer, length); |
4133 } | 4133 } |
4134 | 4134 |
4135 void ByteArray::copy_out(int index, byte* buffer, int length) { | 4135 void ByteArray::copy_out(int index, byte* buffer, int length) { |
4136 DCHECK(index >= 0 && length >= 0 && index + length >= index && | 4136 DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index && |
4137 index + length <= this->length()); | 4137 index + length <= this->length()); |
4138 const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); | 4138 const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); |
4139 memcpy(buffer, src_addr, length); | 4139 memcpy(buffer, src_addr, length); |
4140 } | 4140 } |
4141 | 4141 |
4142 int ByteArray::get_int(int index) { | 4142 int ByteArray::get_int(int index) { |
4143 DCHECK(index >= 0 && index < this->length() / kIntSize); | 4143 DCHECK(index >= 0 && index < this->length() / kIntSize); |
4144 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); | 4144 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); |
4145 } | 4145 } |
4146 | 4146 |
(...skipping 4293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8440 #undef WRITE_INT64_FIELD | 8440 #undef WRITE_INT64_FIELD |
8441 #undef READ_BYTE_FIELD | 8441 #undef READ_BYTE_FIELD |
8442 #undef WRITE_BYTE_FIELD | 8442 #undef WRITE_BYTE_FIELD |
8443 #undef NOBARRIER_READ_BYTE_FIELD | 8443 #undef NOBARRIER_READ_BYTE_FIELD |
8444 #undef NOBARRIER_WRITE_BYTE_FIELD | 8444 #undef NOBARRIER_WRITE_BYTE_FIELD |
8445 | 8445 |
8446 } // namespace internal | 8446 } // namespace internal |
8447 } // namespace v8 | 8447 } // namespace v8 |
8448 | 8448 |
8449 #endif // V8_OBJECTS_INL_H_ | 8449 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |