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 4041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4052 } | 4052 } |
4053 | 4053 |
4054 | 4054 |
4055 int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } | 4055 int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } |
4056 | 4056 |
4057 byte ByteArray::get(int index) { | 4057 byte ByteArray::get(int index) { |
4058 DCHECK(index >= 0 && index < this->length()); | 4058 DCHECK(index >= 0 && index < this->length()); |
4059 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 4059 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
4060 } | 4060 } |
4061 | 4061 |
4062 const byte* ByteArray::data() const { | |
4063 return reinterpret_cast<const byte*>(FIELD_ADDR_CONST(this, kHeaderSize)); | |
4064 } | |
4065 | |
4066 void ByteArray::set(int index, byte value) { | 4062 void ByteArray::set(int index, byte value) { |
4067 DCHECK(index >= 0 && index < this->length()); | 4063 DCHECK(index >= 0 && index < this->length()); |
4068 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 4064 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
4069 } | 4065 } |
4070 | 4066 |
4071 void ByteArray::copy_in(int index, const byte* buffer, int length) { | 4067 void ByteArray::copy_in(int index, const byte* buffer, int length) { |
4072 DCHECK(index >= 0 && length >= 0 && index + length >= index && | 4068 DCHECK(index >= 0 && length >= 0 && index + length >= index && |
4073 index + length <= this->length()); | 4069 index + length <= this->length()); |
4074 byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); | 4070 byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize); |
4075 memcpy(dst_addr, buffer, length); | 4071 memcpy(dst_addr, buffer, length); |
(...skipping 4243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8319 #undef WRITE_INT64_FIELD | 8315 #undef WRITE_INT64_FIELD |
8320 #undef READ_BYTE_FIELD | 8316 #undef READ_BYTE_FIELD |
8321 #undef WRITE_BYTE_FIELD | 8317 #undef WRITE_BYTE_FIELD |
8322 #undef NOBARRIER_READ_BYTE_FIELD | 8318 #undef NOBARRIER_READ_BYTE_FIELD |
8323 #undef NOBARRIER_WRITE_BYTE_FIELD | 8319 #undef NOBARRIER_WRITE_BYTE_FIELD |
8324 | 8320 |
8325 } // namespace internal | 8321 } // namespace internal |
8326 } // namespace v8 | 8322 } // namespace v8 |
8327 | 8323 |
8328 #endif // V8_OBJECTS_INL_H_ | 8324 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |