Commit 7b38d42a authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

Make reading fields uniform via a template


Change-Id: I377e96fca2dff89a986b43f092ef7684d164cd9d
Bug: v8:9264
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1617679
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61695}
parent 786c34e5
...@@ -238,7 +238,7 @@ Map Context::GetInitialJSArrayMap(ElementsKind kind) const { ...@@ -238,7 +238,7 @@ Map Context::GetInitialJSArrayMap(ElementsKind kind) const {
MicrotaskQueue* NativeContext::microtask_queue() const { MicrotaskQueue* NativeContext::microtask_queue() const {
return reinterpret_cast<MicrotaskQueue*>( return reinterpret_cast<MicrotaskQueue*>(
READ_INTPTR_FIELD(*this, kMicrotaskQueueOffset)); ReadField<Address>(kMicrotaskQueueOffset));
} }
void NativeContext::set_microtask_queue(MicrotaskQueue* microtask_queue) { void NativeContext::set_microtask_queue(MicrotaskQueue* microtask_queue) {
......
...@@ -3804,7 +3804,7 @@ void TranslatedState::InitializeJSObjectAt( ...@@ -3804,7 +3804,7 @@ void TranslatedState::InitializeJSObjectAt(
// what the markers in the storage say (note that all heap numbers // what the markers in the storage say (note that all heap numbers
// should be fully initialized by now). // should be fully initialized by now).
int offset = i * kTaggedSize; int offset = i * kTaggedSize;
uint8_t marker = READ_UINT8_FIELD(*object_storage, offset); uint8_t marker = object_storage->ReadField<uint8_t>(offset);
if (marker == kStoreUnboxedDouble) { if (marker == kStoreUnboxedDouble) {
double double_field_value; double double_field_value;
if (field_value->IsSmi()) { if (field_value->IsSmi()) {
...@@ -3848,7 +3848,7 @@ void TranslatedState::InitializeObjectWithTaggedFieldsAt( ...@@ -3848,7 +3848,7 @@ void TranslatedState::InitializeObjectWithTaggedFieldsAt(
for (int i = 1; i < slot->GetChildrenCount(); i++) { for (int i = 1; i < slot->GetChildrenCount(); i++) {
Handle<Object> field_value = GetValueAndAdvance(frame, value_index); Handle<Object> field_value = GetValueAndAdvance(frame, value_index);
int offset = i * kTaggedSize; int offset = i * kTaggedSize;
uint8_t marker = READ_UINT8_FIELD(*object_storage, offset); uint8_t marker = object_storage->ReadField<uint8_t>(offset);
if (i > 1 && marker == kStoreMutableHeapNumber) { if (i > 1 && marker == kStoreMutableHeapNumber) {
CHECK(field_value->IsMutableHeapNumber()); CHECK(field_value->IsMutableHeapNumber());
} else { } else {
......
...@@ -45,7 +45,7 @@ int32_t FeedbackMetadata::synchronized_slot_count() const { ...@@ -45,7 +45,7 @@ int32_t FeedbackMetadata::synchronized_slot_count() const {
int32_t FeedbackMetadata::get(int index) const { int32_t FeedbackMetadata::get(int index) const {
DCHECK(index >= 0 && index < length()); DCHECK(index >= 0 && index < length());
int offset = kHeaderSize + index * kInt32Size; int offset = kHeaderSize + index * kInt32Size;
return READ_INT32_FIELD(*this, offset); return ReadField<int32_t>(offset);
} }
void FeedbackMetadata::set(int index, int32_t value) { void FeedbackMetadata::set(int index, int32_t value) {
......
...@@ -625,6 +625,28 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> { ...@@ -625,6 +625,28 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
} }
}; };
template <class T, typename std::enable_if<std::is_arithmetic<T>::value,
int>::type = 0>
inline T ReadField(size_t offset) const {
// Pointer compression causes types larger than kTaggedSize to be unaligned.
#ifdef V8_COMPRESS_POINTERS
constexpr bool v8_pointer_compression_unaligned = sizeof(T) > kTaggedSize;
#else
constexpr bool v8_pointer_compression_unaligned = false;
#endif
if (std::is_same<T, double>::value || v8_pointer_compression_unaligned) {
// Bug(v8:8875) Double fields may be unaligned.
return ReadUnalignedValue<T>(field_address(offset));
} else {
return Memory<T>(field_address(offset));
}
}
protected:
inline Address field_address(size_t offset) const {
return ptr() + offset - kHeapObjectTag;
}
private: private:
friend class CompressedObjectSlot; friend class CompressedObjectSlot;
friend class FullObjectSlot; friend class FullObjectSlot;
......
...@@ -87,7 +87,7 @@ class BigIntBase : public HeapObject { ...@@ -87,7 +87,7 @@ class BigIntBase : public HeapObject {
inline digit_t digit(int n) const { inline digit_t digit(int n) const {
SLOW_DCHECK(0 <= n && n < length()); SLOW_DCHECK(0 <= n && n < length());
return READ_UINTPTR_FIELD(*this, kDigitsOffset + n * kDigitSize); return ReadField<digit_t>(kDigitsOffset + n * kDigitSize);
} }
bool is_zero() const { return length() == 0; } bool is_zero() const { return length() == 0; }
......
...@@ -297,8 +297,7 @@ int Code::GetUnwindingInfoSizeOffset() const { ...@@ -297,8 +297,7 @@ int Code::GetUnwindingInfoSizeOffset() const {
int Code::unwinding_info_size() const { int Code::unwinding_info_size() const {
DCHECK(has_unwinding_info()); DCHECK(has_unwinding_info());
return static_cast<int>( return static_cast<int>(ReadField<uint64_t>(GetUnwindingInfoSizeOffset()));
READ_UINT64_FIELD(*this, GetUnwindingInfoSizeOffset()));
} }
void Code::set_unwinding_info_size(int value) { void Code::set_unwinding_info_size(int value) {
...@@ -378,7 +377,7 @@ void Code::CopyRelocInfoToByteArray(ByteArray dest, const CodeDesc& desc) { ...@@ -378,7 +377,7 @@ void Code::CopyRelocInfoToByteArray(ByteArray dest, const CodeDesc& desc) {
int Code::CodeSize() const { return SizeFor(body_size()); } int Code::CodeSize() const { return SizeFor(body_size()); }
Code::Kind Code::kind() const { Code::Kind Code::kind() const {
return KindField::decode(READ_UINT32_FIELD(*this, kFlagsOffset)); return KindField::decode(ReadField<uint32_t>(kFlagsOffset));
} }
void Code::initialize_flags(Kind kind, bool has_unwinding_info, void Code::initialize_flags(Kind kind, bool has_unwinding_info,
...@@ -417,11 +416,11 @@ inline bool Code::has_tagged_params() const { ...@@ -417,11 +416,11 @@ inline bool Code::has_tagged_params() const {
} }
inline bool Code::has_unwinding_info() const { inline bool Code::has_unwinding_info() const {
return HasUnwindingInfoField::decode(READ_UINT32_FIELD(*this, kFlagsOffset)); return HasUnwindingInfoField::decode(ReadField<uint32_t>(kFlagsOffset));
} }
inline bool Code::is_turbofanned() const { inline bool Code::is_turbofanned() const {
return IsTurbofannedField::decode(READ_UINT32_FIELD(*this, kFlagsOffset)); return IsTurbofannedField::decode(ReadField<uint32_t>(kFlagsOffset));
} }
inline bool Code::can_have_weak_objects() const { inline bool Code::can_have_weak_objects() const {
...@@ -464,7 +463,7 @@ inline void Code::set_is_exception_caught(bool value) { ...@@ -464,7 +463,7 @@ inline void Code::set_is_exception_caught(bool value) {
} }
inline bool Code::is_off_heap_trampoline() const { inline bool Code::is_off_heap_trampoline() const {
return IsOffHeapTrampoline::decode(READ_UINT32_FIELD(*this, kFlagsOffset)); return IsOffHeapTrampoline::decode(ReadField<uint32_t>(kFlagsOffset));
} }
inline HandlerTable::CatchPrediction Code::GetBuiltinCatchPrediction() { inline HandlerTable::CatchPrediction Code::GetBuiltinCatchPrediction() {
...@@ -474,7 +473,7 @@ inline HandlerTable::CatchPrediction Code::GetBuiltinCatchPrediction() { ...@@ -474,7 +473,7 @@ inline HandlerTable::CatchPrediction Code::GetBuiltinCatchPrediction() {
} }
int Code::builtin_index() const { int Code::builtin_index() const {
int index = READ_INT_FIELD(*this, kBuiltinIndexOffset); int index = ReadField<int>(kBuiltinIndexOffset);
DCHECK(index == -1 || Builtins::IsBuiltinId(index)); DCHECK(index == -1 || Builtins::IsBuiltinId(index));
return index; return index;
} }
...@@ -492,7 +491,7 @@ bool Code::has_safepoint_info() const { ...@@ -492,7 +491,7 @@ bool Code::has_safepoint_info() const {
int Code::stack_slots() const { int Code::stack_slots() const {
DCHECK(has_safepoint_info()); DCHECK(has_safepoint_info());
return StackSlotsField::decode(READ_UINT32_FIELD(*this, kFlagsOffset)); return StackSlotsField::decode(ReadField<uint32_t>(kFlagsOffset));
} }
bool Code::marked_for_deoptimization() const { bool Code::marked_for_deoptimization() const {
...@@ -542,7 +541,7 @@ bool Code::is_wasm_code() const { return kind() == WASM_FUNCTION; } ...@@ -542,7 +541,7 @@ bool Code::is_wasm_code() const { return kind() == WASM_FUNCTION; }
int Code::constant_pool_offset() const { int Code::constant_pool_offset() const {
if (!FLAG_enable_embedded_constant_pool) return code_comments_offset(); if (!FLAG_enable_embedded_constant_pool) return code_comments_offset();
return READ_INT_FIELD(*this, kConstantPoolOffsetOffset); return ReadField<int>(kConstantPoolOffsetOffset);
} }
void Code::set_constant_pool_offset(int value) { void Code::set_constant_pool_offset(int value) {
...@@ -615,7 +614,7 @@ void CodeDataContainer::clear_padding() { ...@@ -615,7 +614,7 @@ void CodeDataContainer::clear_padding() {
byte BytecodeArray::get(int index) const { byte BytecodeArray::get(int index) const {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
return READ_BYTE_FIELD(*this, kHeaderSize + index * kCharSize); return ReadField<byte>(kHeaderSize + index * kCharSize);
} }
void BytecodeArray::set(int index, byte value) { void BytecodeArray::set(int index, byte value) {
...@@ -630,7 +629,7 @@ void BytecodeArray::set_frame_size(int frame_size) { ...@@ -630,7 +629,7 @@ void BytecodeArray::set_frame_size(int frame_size) {
} }
int BytecodeArray::frame_size() const { int BytecodeArray::frame_size() const {
return READ_INT_FIELD(*this, kFrameSizeOffset); return ReadField<int>(kFrameSizeOffset);
} }
int BytecodeArray::register_count() const { int BytecodeArray::register_count() const {
...@@ -648,7 +647,7 @@ void BytecodeArray::set_parameter_count(int number_of_parameters) { ...@@ -648,7 +647,7 @@ void BytecodeArray::set_parameter_count(int number_of_parameters) {
interpreter::Register BytecodeArray::incoming_new_target_or_generator_register() interpreter::Register BytecodeArray::incoming_new_target_or_generator_register()
const { const {
int register_operand = int register_operand =
READ_INT_FIELD(*this, kIncomingNewTargetOrGeneratorRegisterOffset); ReadField<int>(kIncomingNewTargetOrGeneratorRegisterOffset);
if (register_operand == 0) { if (register_operand == 0) {
return interpreter::Register::invalid_value(); return interpreter::Register::invalid_value();
} else { } else {
...@@ -670,7 +669,7 @@ void BytecodeArray::set_incoming_new_target_or_generator_register( ...@@ -670,7 +669,7 @@ void BytecodeArray::set_incoming_new_target_or_generator_register(
} }
int BytecodeArray::osr_loop_nesting_level() const { int BytecodeArray::osr_loop_nesting_level() const {
return READ_INT8_FIELD(*this, kOSRNestingLevelOffset); return ReadField<int8_t>(kOSRNestingLevelOffset);
} }
void BytecodeArray::set_osr_loop_nesting_level(int depth) { void BytecodeArray::set_osr_loop_nesting_level(int depth) {
...@@ -695,7 +694,7 @@ void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) { ...@@ -695,7 +694,7 @@ void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) {
int BytecodeArray::parameter_count() const { int BytecodeArray::parameter_count() const {
// Parameter count is stored as the size on stack of the parameters to allow // Parameter count is stored as the size on stack of the parameters to allow
// it to be used directly by generated code. // it to be used directly by generated code.
return READ_INT_FIELD(*this, kParameterSizeOffset) >> kSystemPointerSizeLog2; return ReadField<int>(kParameterSizeOffset) >> kSystemPointerSizeLog2;
} }
ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset) ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
......
...@@ -351,7 +351,7 @@ double FixedDoubleArray::get_scalar(int index) { ...@@ -351,7 +351,7 @@ double FixedDoubleArray::get_scalar(int index) {
map() != GetReadOnlyRoots().fixed_array_map()); map() != GetReadOnlyRoots().fixed_array_map());
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
DCHECK(!is_the_hole(index)); DCHECK(!is_the_hole(index));
return READ_DOUBLE_FIELD(*this, kHeaderSize + index * kDoubleSize); return ReadField<double>(kHeaderSize + index * kDoubleSize);
} }
uint64_t FixedDoubleArray::get_representation(int index) { uint64_t FixedDoubleArray::get_representation(int index) {
...@@ -360,7 +360,7 @@ uint64_t FixedDoubleArray::get_representation(int index) { ...@@ -360,7 +360,7 @@ uint64_t FixedDoubleArray::get_representation(int index) {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
int offset = kHeaderSize + index * kDoubleSize; int offset = kHeaderSize + index * kDoubleSize;
// Bug(v8:8875): Doubles may be unaligned. // Bug(v8:8875): Doubles may be unaligned.
return ReadUnalignedValue<uint64_t>(FIELD_ADDR(*this, offset)); return ReadUnalignedValue<uint64_t>(field_address(offset));
} }
Handle<Object> FixedDoubleArray::get(FixedDoubleArray array, int index, Handle<Object> FixedDoubleArray::get(FixedDoubleArray array, int index,
...@@ -533,7 +533,7 @@ int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kTaggedSize); } ...@@ -533,7 +533,7 @@ int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kTaggedSize); }
byte ByteArray::get(int index) const { byte ByteArray::get(int index) const {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
return READ_BYTE_FIELD(*this, kHeaderSize + index * kCharSize); return ReadField<byte>(kHeaderSize + index * kCharSize);
} }
void ByteArray::set(int index, byte value) { void ByteArray::set(int index, byte value) {
...@@ -557,7 +557,7 @@ void ByteArray::copy_out(int index, byte* buffer, int length) { ...@@ -557,7 +557,7 @@ void ByteArray::copy_out(int index, byte* buffer, int length) {
int ByteArray::get_int(int index) const { int ByteArray::get_int(int index) const {
DCHECK(index >= 0 && index < this->length() / kIntSize); DCHECK(index >= 0 && index < this->length() / kIntSize);
return READ_INT_FIELD(*this, kHeaderSize + index * kIntSize); return ReadField<int>(kHeaderSize + index * kIntSize);
} }
void ByteArray::set_int(int index, int value) { void ByteArray::set_int(int index, int value) {
...@@ -567,7 +567,7 @@ void ByteArray::set_int(int index, int value) { ...@@ -567,7 +567,7 @@ void ByteArray::set_int(int index, int value) {
uint32_t ByteArray::get_uint32(int index) const { uint32_t ByteArray::get_uint32(int index) const {
DCHECK(index >= 0 && index < this->length() / kUInt32Size); DCHECK(index >= 0 && index < this->length() / kUInt32Size);
return READ_UINT32_FIELD(*this, kHeaderSize + index * kUInt32Size); return ReadField<uint32_t>(kHeaderSize + index * kUInt32Size);
} }
void ByteArray::set_uint32(int index, uint32_t value) { void ByteArray::set_uint32(int index, uint32_t value) {
...@@ -619,8 +619,7 @@ int PodArray<T>::length() const { ...@@ -619,8 +619,7 @@ int PodArray<T>::length() const {
} }
void* FixedTypedArrayBase::external_pointer() const { void* FixedTypedArrayBase::external_pointer() const {
intptr_t ptr = READ_INTPTR_FIELD(*this, kExternalPointerOffset); return reinterpret_cast<void*>(ReadField<Address>(kExternalPointerOffset));
return reinterpret_cast<void*>(ptr);
} }
void FixedTypedArrayBase::set_external_pointer(void* value) { void FixedTypedArrayBase::set_external_pointer(void* value) {
......
...@@ -27,7 +27,7 @@ bool Foreign::IsNormalized(Object value) { ...@@ -27,7 +27,7 @@ bool Foreign::IsNormalized(Object value) {
} }
Address Foreign::foreign_address() { Address Foreign::foreign_address() {
return READ_UINTPTR_FIELD(*this, kForeignAddressOffset); return ReadField<Address>(kForeignAddressOffset);
} }
void Foreign::set_foreign_address(Address value) { void Foreign::set_foreign_address(Address value) {
......
...@@ -23,9 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(MutableHeapNumber, HeapNumberBase) ...@@ -23,9 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(MutableHeapNumber, HeapNumberBase)
CAST_ACCESSOR(HeapNumber) CAST_ACCESSOR(HeapNumber)
CAST_ACCESSOR(MutableHeapNumber) CAST_ACCESSOR(MutableHeapNumber)
double HeapNumberBase::value() const { double HeapNumberBase::value() const { return ReadField<double>(kValueOffset); }
return READ_DOUBLE_FIELD(*this, kValueOffset);
}
void HeapNumberBase::set_value(double value) { void HeapNumberBase::set_value(double value) {
WRITE_DOUBLE_FIELD(*this, kValueOffset, value); WRITE_DOUBLE_FIELD(*this, kValueOffset, value);
...@@ -33,7 +31,7 @@ void HeapNumberBase::set_value(double value) { ...@@ -33,7 +31,7 @@ void HeapNumberBase::set_value(double value) {
uint64_t HeapNumberBase::value_as_bits() const { uint64_t HeapNumberBase::value_as_bits() const {
// Bug(v8:8875): HeapNumber's double may be unaligned. // Bug(v8:8875): HeapNumber's double may be unaligned.
return ReadUnalignedValue<uint64_t>(FIELD_ADDR(*this, kValueOffset)); return ReadUnalignedValue<uint64_t>(field_address(kValueOffset));
} }
void HeapNumberBase::set_value_as_bits(uint64_t bits) { void HeapNumberBase::set_value_as_bits(uint64_t bits) {
...@@ -41,13 +39,12 @@ void HeapNumberBase::set_value_as_bits(uint64_t bits) { ...@@ -41,13 +39,12 @@ void HeapNumberBase::set_value_as_bits(uint64_t bits) {
} }
int HeapNumberBase::get_exponent() { int HeapNumberBase::get_exponent() {
return ((READ_INT_FIELD(*this, kExponentOffset) & kExponentMask) >> return ((ReadField<int>(kExponentOffset) & kExponentMask) >> kExponentShift) -
kExponentShift) -
kExponentBias; kExponentBias;
} }
int HeapNumberBase::get_sign() { int HeapNumberBase::get_sign() {
return READ_INT_FIELD(*this, kExponentOffset) & kSignMask; return ReadField<int>(kExponentOffset) & kSignMask;
} }
} // namespace internal } // namespace internal
......
...@@ -29,7 +29,7 @@ CAST_ACCESSOR(JSTypedArray) ...@@ -29,7 +29,7 @@ CAST_ACCESSOR(JSTypedArray)
CAST_ACCESSOR(JSDataView) CAST_ACCESSOR(JSDataView)
size_t JSArrayBuffer::byte_length() const { size_t JSArrayBuffer::byte_length() const {
return READ_UINTPTR_FIELD(*this, kByteLengthOffset); return ReadField<size_t>(kByteLengthOffset);
} }
void JSArrayBuffer::set_byte_length(size_t value) { void JSArrayBuffer::set_byte_length(size_t value) {
...@@ -37,8 +37,7 @@ void JSArrayBuffer::set_byte_length(size_t value) { ...@@ -37,8 +37,7 @@ void JSArrayBuffer::set_byte_length(size_t value) {
} }
void* JSArrayBuffer::backing_store() const { void* JSArrayBuffer::backing_store() const {
intptr_t ptr = READ_INTPTR_FIELD(*this, kBackingStoreOffset); return reinterpret_cast<void*>(ReadField<Address>(kBackingStoreOffset));
return reinterpret_cast<void*>(ptr);
} }
void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) { void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) {
...@@ -97,7 +96,7 @@ void JSArrayBuffer::set_bit_field(uint32_t bits) { ...@@ -97,7 +96,7 @@ void JSArrayBuffer::set_bit_field(uint32_t bits) {
} }
uint32_t JSArrayBuffer::bit_field() const { uint32_t JSArrayBuffer::bit_field() const {
return READ_UINT32_FIELD(*this, kBitFieldOffset); return ReadField<uint32_t>(kBitFieldOffset);
} }
// |bit_field| fields. // |bit_field| fields.
...@@ -111,7 +110,7 @@ BIT_FIELD_ACCESSORS(JSArrayBuffer, bit_field, is_shared, ...@@ -111,7 +110,7 @@ BIT_FIELD_ACCESSORS(JSArrayBuffer, bit_field, is_shared,
JSArrayBuffer::IsSharedBit) JSArrayBuffer::IsSharedBit)
size_t JSArrayBufferView::byte_offset() const { size_t JSArrayBufferView::byte_offset() const {
return READ_UINTPTR_FIELD(*this, kByteOffsetOffset); return ReadField<size_t>(kByteOffsetOffset);
} }
void JSArrayBufferView::set_byte_offset(size_t value) { void JSArrayBufferView::set_byte_offset(size_t value) {
...@@ -119,7 +118,7 @@ void JSArrayBufferView::set_byte_offset(size_t value) { ...@@ -119,7 +118,7 @@ void JSArrayBufferView::set_byte_offset(size_t value) {
} }
size_t JSArrayBufferView::byte_length() const { size_t JSArrayBufferView::byte_length() const {
return READ_UINTPTR_FIELD(*this, kByteLengthOffset); return ReadField<size_t>(kByteLengthOffset);
} }
void JSArrayBufferView::set_byte_length(size_t value) { void JSArrayBufferView::set_byte_length(size_t value) {
...@@ -132,9 +131,7 @@ bool JSArrayBufferView::WasDetached() const { ...@@ -132,9 +131,7 @@ bool JSArrayBufferView::WasDetached() const {
return JSArrayBuffer::cast(buffer())->was_detached(); return JSArrayBuffer::cast(buffer())->was_detached();
} }
size_t JSTypedArray::length() const { size_t JSTypedArray::length() const { return ReadField<size_t>(kLengthOffset); }
return READ_UINTPTR_FIELD(*this, kLengthOffset);
}
void JSTypedArray::set_length(size_t value) { void JSTypedArray::set_length(size_t value) {
WRITE_UINTPTR_FIELD(*this, kLengthOffset, value); WRITE_UINTPTR_FIELD(*this, kLengthOffset, value);
...@@ -171,8 +168,7 @@ MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate, ...@@ -171,8 +168,7 @@ MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
} }
void* JSDataView::data_pointer() const { void* JSDataView::data_pointer() const {
intptr_t ptr = READ_INTPTR_FIELD(*this, kDataPointerOffset); return reinterpret_cast<void*>(ReadField<Address>(kDataPointerOffset));
return reinterpret_cast<void*>(ptr);
} }
void JSDataView::set_data_pointer(void* value) { void JSDataView::set_data_pointer(void* value) {
......
...@@ -333,12 +333,12 @@ Object JSObject::RawFastPropertyAt(FieldIndex index) { ...@@ -333,12 +333,12 @@ Object JSObject::RawFastPropertyAt(FieldIndex index) {
double JSObject::RawFastDoublePropertyAt(FieldIndex index) { double JSObject::RawFastDoublePropertyAt(FieldIndex index) {
DCHECK(IsUnboxedDoubleField(index)); DCHECK(IsUnboxedDoubleField(index));
return READ_DOUBLE_FIELD(*this, index.offset()); return ReadField<double>(index.offset());
} }
uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) { uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) {
DCHECK(IsUnboxedDoubleField(index)); DCHECK(IsUnboxedDoubleField(index));
return READ_UINT64_FIELD(*this, index.offset()); return ReadField<uint64_t>(index.offset());
} }
void JSObject::RawFastPropertyAtPut(FieldIndex index, Object value, void JSObject::RawFastPropertyAtPut(FieldIndex index, Object value,
......
...@@ -291,8 +291,7 @@ Handle<Map> Map::AddMissingTransitionsForTesting( ...@@ -291,8 +291,7 @@ Handle<Map> Map::AddMissingTransitionsForTesting(
} }
InstanceType Map::instance_type() const { InstanceType Map::instance_type() const {
return static_cast<InstanceType>( return static_cast<InstanceType>(ReadField<uint16_t>(kInstanceTypeOffset));
READ_UINT16_FIELD(*this, kInstanceTypeOffset));
} }
void Map::set_instance_type(InstanceType value) { void Map::set_instance_type(InstanceType value) {
...@@ -418,7 +417,7 @@ void Map::AccountAddedOutOfObjectPropertyField(int unused_in_property_array) { ...@@ -418,7 +417,7 @@ void Map::AccountAddedOutOfObjectPropertyField(int unused_in_property_array) {
DCHECK_EQ(unused_in_property_array, UnusedPropertyFields()); DCHECK_EQ(unused_in_property_array, UnusedPropertyFields());
} }
byte Map::bit_field() const { return READ_BYTE_FIELD(*this, kBitFieldOffset); } byte Map::bit_field() const { return ReadField<byte>(kBitFieldOffset); }
void Map::set_bit_field(byte value) { void Map::set_bit_field(byte value) {
WRITE_BYTE_FIELD(*this, kBitFieldOffset, value); WRITE_BYTE_FIELD(*this, kBitFieldOffset, value);
...@@ -432,9 +431,7 @@ void Map::set_relaxed_bit_field(byte value) { ...@@ -432,9 +431,7 @@ void Map::set_relaxed_bit_field(byte value) {
RELAXED_WRITE_BYTE_FIELD(*this, kBitFieldOffset, value); RELAXED_WRITE_BYTE_FIELD(*this, kBitFieldOffset, value);
} }
byte Map::bit_field2() const { byte Map::bit_field2() const { return ReadField<byte>(kBitField2Offset); }
return READ_BYTE_FIELD(*this, kBitField2Offset);
}
void Map::set_bit_field2(byte value) { void Map::set_bit_field2(byte value) {
WRITE_BYTE_FIELD(*this, kBitField2Offset, value); WRITE_BYTE_FIELD(*this, kBitField2Offset, value);
......
...@@ -52,9 +52,7 @@ bool Name::IsUniqueName() const { ...@@ -52,9 +52,7 @@ bool Name::IsUniqueName() const {
return result; return result;
} }
uint32_t Name::hash_field() { uint32_t Name::hash_field() { return ReadField<uint32_t>(kHashFieldOffset); }
return READ_UINT32_FIELD(*this, kHashFieldOffset);
}
void Name::set_hash_field(uint32_t value) { void Name::set_hash_field(uint32_t value) {
WRITE_UINT32_FIELD(*this, kHashFieldOffset, value); WRITE_UINT32_FIELD(*this, kHashFieldOffset, value);
......
...@@ -61,41 +61,28 @@ ...@@ -61,41 +61,28 @@
#undef CONDITIONAL_WRITE_BARRIER #undef CONDITIONAL_WRITE_BARRIER
#undef CONDITIONAL_WEAK_WRITE_BARRIER #undef CONDITIONAL_WEAK_WRITE_BARRIER
#undef CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER #undef CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER
#undef READ_DOUBLE_FIELD
#undef WRITE_DOUBLE_FIELD #undef WRITE_DOUBLE_FIELD
#undef READ_INT_FIELD
#undef WRITE_INT_FIELD #undef WRITE_INT_FIELD
#undef ACQUIRE_READ_INT32_FIELD #undef ACQUIRE_READ_INT32_FIELD
#undef READ_UINT8_FIELD
#undef WRITE_UINT8_FIELD #undef WRITE_UINT8_FIELD
#undef RELAXED_WRITE_INT8_FIELD #undef RELAXED_WRITE_INT8_FIELD
#undef READ_INT8_FIELD
#undef RELAXED_READ_INT8_FIELD #undef RELAXED_READ_INT8_FIELD
#undef WRITE_INT8_FIELD #undef WRITE_INT8_FIELD
#undef READ_UINT16_FIELD
#undef WRITE_UINT16_FIELD #undef WRITE_UINT16_FIELD
#undef READ_INT16_FIELD
#undef WRITE_INT16_FIELD #undef WRITE_INT16_FIELD
#undef RELAXED_READ_INT16_FIELD #undef RELAXED_READ_INT16_FIELD
#undef RELAXED_WRITE_INT16_FIELD #undef RELAXED_WRITE_INT16_FIELD
#undef READ_UINT32_FIELD
#undef RELAXED_READ_UINT32_FIELD #undef RELAXED_READ_UINT32_FIELD
#undef WRITE_UINT32_FIELD #undef WRITE_UINT32_FIELD
#undef RELAXED_WRITE_UINT32_FIELD #undef RELAXED_WRITE_UINT32_FIELD
#undef READ_INT32_FIELD
#undef RELAXED_READ_INT32_FIELD #undef RELAXED_READ_INT32_FIELD
#undef WRITE_INT32_FIELD #undef WRITE_INT32_FIELD
#undef RELEASE_WRITE_INT32_FIELD #undef RELEASE_WRITE_INT32_FIELD
#undef RELAXED_WRITE_INT32_FIELD #undef RELAXED_WRITE_INT32_FIELD
#undef READ_FLOAT_FIELD
#undef WRITE_FLOAT_FIELD #undef WRITE_FLOAT_FIELD
#undef READ_INTPTR_FIELD
#undef WRITE_INTPTR_FIELD #undef WRITE_INTPTR_FIELD
#undef READ_UINTPTR_FIELD
#undef WRITE_UINTPTR_FIELD #undef WRITE_UINTPTR_FIELD
#undef READ_UINT64_FIELD
#undef WRITE_UINT64_FIELD #undef WRITE_UINT64_FIELD
#undef READ_BYTE_FIELD
#undef RELAXED_READ_BYTE_FIELD #undef RELAXED_READ_BYTE_FIELD
#undef WRITE_BYTE_FIELD #undef WRITE_BYTE_FIELD
#undef RELAXED_WRITE_BYTE_FIELD #undef RELAXED_WRITE_BYTE_FIELD
......
...@@ -80,14 +80,14 @@ ...@@ -80,14 +80,14 @@
#define CAST_ACCESSOR(Type) \ #define CAST_ACCESSOR(Type) \
Type Type::cast(Object object) { return Type(object.ptr()); } Type Type::cast(Object object) { return Type(object.ptr()); }
#define INT_ACCESSORS(holder, name, offset) \ #define INT_ACCESSORS(holder, name, offset) \
int holder::name() const { return READ_INT_FIELD(*this, offset); } \ int holder::name() const { return ReadField<int>(offset); } \
void holder::set_##name(int value) { WRITE_INT_FIELD(*this, offset, value); } void holder::set_##name(int value) { WRITE_INT_FIELD(*this, offset, value); }
#define INT32_ACCESSORS(holder, name, offset) \ #define INT32_ACCESSORS(holder, name, offset) \
int32_t holder::name() const { return READ_INT32_FIELD(*this, offset); } \ int32_t holder::name() const { return ReadField<int32_t>(offset); } \
void holder::set_##name(int32_t value) { \ void holder::set_##name(int32_t value) { \
WRITE_INT32_FIELD(*this, offset, value); \ WRITE_INT32_FIELD(*this, offset, value); \
} }
#define RELAXED_INT32_ACCESSORS(holder, name, offset) \ #define RELAXED_INT32_ACCESSORS(holder, name, offset) \
...@@ -98,20 +98,20 @@ ...@@ -98,20 +98,20 @@
RELAXED_WRITE_INT32_FIELD(*this, offset, value); \ RELAXED_WRITE_INT32_FIELD(*this, offset, value); \
} }
#define UINT16_ACCESSORS(holder, name, offset) \ #define UINT16_ACCESSORS(holder, name, offset) \
uint16_t holder::name() const { return READ_UINT16_FIELD(*this, offset); } \ uint16_t holder::name() const { return ReadField<uint16_t>(offset); } \
void holder::set_##name(int value) { \ void holder::set_##name(int value) { \
DCHECK_GE(value, 0); \ DCHECK_GE(value, 0); \
DCHECK_LE(value, static_cast<uint16_t>(-1)); \ DCHECK_LE(value, static_cast<uint16_t>(-1)); \
WRITE_UINT16_FIELD(*this, offset, value); \ WRITE_UINT16_FIELD(*this, offset, value); \
} }
#define UINT8_ACCESSORS(holder, name, offset) \ #define UINT8_ACCESSORS(holder, name, offset) \
uint8_t holder::name() const { return READ_UINT8_FIELD(*this, offset); } \ uint8_t holder::name() const { return ReadField<uint8_t>(offset); } \
void holder::set_##name(int value) { \ void holder::set_##name(int value) { \
DCHECK_GE(value, 0); \ DCHECK_GE(value, 0); \
DCHECK_LE(value, static_cast<uint8_t>(-1)); \ DCHECK_LE(value, static_cast<uint8_t>(-1)); \
WRITE_UINT8_FIELD(*this, offset, value); \ WRITE_UINT8_FIELD(*this, offset, value); \
} }
#define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \ #define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
...@@ -337,14 +337,9 @@ ...@@ -337,14 +337,9 @@
} while (false) } while (false)
// BUG(v8:8875): Double fields may be unaligned. // BUG(v8:8875): Double fields may be unaligned.
#define READ_DOUBLE_FIELD(p, offset) \
ReadUnalignedValue<double>(FIELD_ADDR(p, offset))
#define WRITE_DOUBLE_FIELD(p, offset, value) \ #define WRITE_DOUBLE_FIELD(p, offset, value) \
WriteUnalignedValue<double>(FIELD_ADDR(p, offset), value) WriteUnalignedValue<double>(FIELD_ADDR(p, offset), value)
#define READ_INT_FIELD(p, offset) (Memory<const int>(FIELD_ADDR(p, offset)))
#define WRITE_INT_FIELD(p, offset, value) \ #define WRITE_INT_FIELD(p, offset, value) \
(*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
...@@ -352,18 +347,12 @@ ...@@ -352,18 +347,12 @@
static_cast<int32_t>(base::Acquire_Load( \ static_cast<int32_t>(base::Acquire_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
#define READ_UINT8_FIELD(p, offset) \
(Memory<const uint8_t>(FIELD_ADDR(p, offset)))
#define WRITE_UINT8_FIELD(p, offset, value) \ #define WRITE_UINT8_FIELD(p, offset, value) \
(*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value)
#define RELAXED_WRITE_INT8_FIELD(p, offset, value) \ #define RELAXED_WRITE_INT8_FIELD(p, offset, value) \
base::Relaxed_Store(reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \ base::Relaxed_Store(reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic8>(value)); static_cast<base::Atomic8>(value));
#define READ_INT8_FIELD(p, offset) (Memory<const int8_t>(FIELD_ADDR(p, offset)))
#define RELAXED_READ_INT8_FIELD(p, offset) \ #define RELAXED_READ_INT8_FIELD(p, offset) \
static_cast<int8_t>(base::Relaxed_Load( \ static_cast<int8_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset))))
...@@ -371,15 +360,9 @@ ...@@ -371,15 +360,9 @@
#define WRITE_INT8_FIELD(p, offset, value) \ #define WRITE_INT8_FIELD(p, offset, value) \
(*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_UINT16_FIELD(p, offset) \
(Memory<const uint16_t>(FIELD_ADDR(p, offset)))
#define WRITE_UINT16_FIELD(p, offset, value) \ #define WRITE_UINT16_FIELD(p, offset, value) \
(*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_INT16_FIELD(p, offset) \
(Memory<const int16_t>(FIELD_ADDR(p, offset)))
#define WRITE_INT16_FIELD(p, offset, value) \ #define WRITE_INT16_FIELD(p, offset, value) \
(*reinterpret_cast<int16_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<int16_t*>(FIELD_ADDR(p, offset)) = value)
...@@ -392,8 +375,6 @@ ...@@ -392,8 +375,6 @@
reinterpret_cast<base::Atomic16*>(FIELD_ADDR(p, offset)), \ reinterpret_cast<base::Atomic16*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic16>(value)); static_cast<base::Atomic16>(value));
#define READ_UINT32_FIELD(p, offset) (Memory<uint32_t>(FIELD_ADDR(p, offset)))
#define RELAXED_READ_UINT32_FIELD(p, offset) \ #define RELAXED_READ_UINT32_FIELD(p, offset) \
static_cast<uint32_t>(base::Relaxed_Load( \ static_cast<uint32_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
...@@ -406,8 +387,6 @@ ...@@ -406,8 +387,6 @@
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \ reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value)); static_cast<base::Atomic32>(value));
#define READ_INT32_FIELD(p, offset) (Memory<int32_t>(FIELD_ADDR(p, offset)))
#define RELAXED_READ_INT32_FIELD(p, offset) \ #define RELAXED_READ_INT32_FIELD(p, offset) \
static_cast<int32_t>(base::Relaxed_Load( \ static_cast<int32_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
...@@ -425,8 +404,6 @@ ...@@ -425,8 +404,6 @@
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \ reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value)); static_cast<base::Atomic32>(value));
#define READ_FLOAT_FIELD(p, offset) (Memory<const float>(FIELD_ADDR(p, offset)))
#define WRITE_FLOAT_FIELD(p, offset, value) \ #define WRITE_FLOAT_FIELD(p, offset, value) \
(*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value)
...@@ -436,45 +413,28 @@ ...@@ -436,45 +413,28 @@
// avoid undefined behavior in C++ code. // avoid undefined behavior in C++ code.
#ifdef V8_COMPRESS_POINTERS #ifdef V8_COMPRESS_POINTERS
#define READ_INTPTR_FIELD(p, offset) \
ReadUnalignedValue<intptr_t>(FIELD_ADDR(p, offset))
#define WRITE_INTPTR_FIELD(p, offset, value) \ #define WRITE_INTPTR_FIELD(p, offset, value) \
WriteUnalignedValue<intptr_t>(FIELD_ADDR(p, offset), value) WriteUnalignedValue<intptr_t>(FIELD_ADDR(p, offset), value)
#define READ_UINTPTR_FIELD(p, offset) \
ReadUnalignedValue<uintptr_t>(FIELD_ADDR(p, offset))
#define WRITE_UINTPTR_FIELD(p, offset, value) \ #define WRITE_UINTPTR_FIELD(p, offset, value) \
WriteUnalignedValue<uintptr_t>(FIELD_ADDR(p, offset), value) WriteUnalignedValue<uintptr_t>(FIELD_ADDR(p, offset), value)
#define READ_UINT64_FIELD(p, offset) \
ReadUnalignedValue<uint64_t>(FIELD_ADDR(p, offset))
#define WRITE_UINT64_FIELD(p, offset, value) \ #define WRITE_UINT64_FIELD(p, offset, value) \
WriteUnalignedValue<uint64_t>(FIELD_ADDR(p, offset), value) WriteUnalignedValue<uint64_t>(FIELD_ADDR(p, offset), value)
#else // V8_COMPRESS_POINTERS #else // V8_COMPRESS_POINTERS
#define READ_INTPTR_FIELD(p, offset) (Memory<intptr_t>(FIELD_ADDR(p, offset)))
#define WRITE_INTPTR_FIELD(p, offset, value) \ #define WRITE_INTPTR_FIELD(p, offset, value) \
(*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_UINTPTR_FIELD(p, offset) (Memory<uintptr_t>(FIELD_ADDR(p, offset)))
#define WRITE_UINTPTR_FIELD(p, offset, value) \ #define WRITE_UINTPTR_FIELD(p, offset, value) \
(*reinterpret_cast<uintptr_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<uintptr_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_UINT64_FIELD(p, offset) (Memory<uint64_t>(FIELD_ADDR(p, offset)))
#define WRITE_UINT64_FIELD(p, offset, value) \ #define WRITE_UINT64_FIELD(p, offset, value) \
(*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value)
#endif // V8_COMPRESS_POINTERS #endif // V8_COMPRESS_POINTERS
#define READ_BYTE_FIELD(p, offset) (Memory<byte>(FIELD_ADDR(p, offset)))
#define RELAXED_READ_BYTE_FIELD(p, offset) \ #define RELAXED_READ_BYTE_FIELD(p, offset) \
static_cast<byte>(base::Relaxed_Load( \ static_cast<byte>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset))))
......
...@@ -23,7 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(Oddball, HeapObject) ...@@ -23,7 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(Oddball, HeapObject)
CAST_ACCESSOR(Oddball) CAST_ACCESSOR(Oddball)
double Oddball::to_number_raw() const { double Oddball::to_number_raw() const {
return READ_DOUBLE_FIELD(*this, kToNumberRawOffset); return ReadField<double>(kToNumberRawOffset);
} }
void Oddball::set_to_number_raw(double value) { void Oddball::set_to_number_raw(double value) {
......
...@@ -196,7 +196,7 @@ inline void SmallOrderedNameDictionary::SetHash(int hash) { ...@@ -196,7 +196,7 @@ inline void SmallOrderedNameDictionary::SetHash(int hash) {
} }
inline int SmallOrderedNameDictionary::Hash() { inline int SmallOrderedNameDictionary::Hash() {
int hash = READ_INT_FIELD(*this, PrefixOffset()); int hash = ReadField<int>(PrefixOffset());
DCHECK(PropertyArray::HashField::is_valid(hash)); DCHECK(PropertyArray::HashField::is_valid(hash));
return hash; return hash;
} }
......
...@@ -540,7 +540,7 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -540,7 +540,7 @@ class SmallOrderedHashTable : public HeapObject {
byte getByte(Offset offset, ByteIndex index) const { byte getByte(Offset offset, ByteIndex index) const {
DCHECK(offset < DataTableStartOffset() || DCHECK(offset < DataTableStartOffset() ||
offset >= GetBucketsStartOffset()); offset >= GetBucketsStartOffset());
return READ_BYTE_FIELD(*this, offset + (index * kOneByteSize)); return ReadField<byte>(offset + (index * kOneByteSize));
} }
void setByte(Offset offset, ByteIndex index, byte value) { void setByte(Offset offset, ByteIndex index, byte value) {
......
...@@ -47,7 +47,7 @@ byte PreparseData::get(int index) const { ...@@ -47,7 +47,7 @@ byte PreparseData::get(int index) const {
DCHECK_LE(0, index); DCHECK_LE(0, index);
DCHECK_LT(index, data_length()); DCHECK_LT(index, data_length());
int offset = kDataStartOffset + index * kByteSize; int offset = kDataStartOffset + index * kByteSize;
return READ_BYTE_FIELD(*this, offset); return ReadField<byte>(offset);
} }
void PreparseData::set(int index, byte value) { void PreparseData::set(int index, byte value) {
......
...@@ -484,7 +484,7 @@ uint32_t String::ToValidIndex(Object number) { ...@@ -484,7 +484,7 @@ uint32_t String::ToValidIndex(Object number) {
uint8_t SeqOneByteString::Get(int index) { uint8_t SeqOneByteString::Get(int index) {
DCHECK(index >= 0 && index < length()); DCHECK(index >= 0 && index < length());
return READ_BYTE_FIELD(*this, kHeaderSize + index * kCharSize); return ReadField<byte>(kHeaderSize + index * kCharSize);
} }
void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) { void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) {
...@@ -513,7 +513,7 @@ uc16* SeqTwoByteString::GetChars(const DisallowHeapAllocation& no_gc) { ...@@ -513,7 +513,7 @@ uc16* SeqTwoByteString::GetChars(const DisallowHeapAllocation& no_gc) {
uint16_t SeqTwoByteString::Get(int index) { uint16_t SeqTwoByteString::Get(int index) {
DCHECK(index >= 0 && index < length()); DCHECK(index >= 0 && index < length());
return READ_UINT16_FIELD(*this, kHeaderSize + index * kShortSize); return ReadField<uint16_t>(kHeaderSize + index * kShortSize);
} }
void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) { void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) {
...@@ -580,7 +580,7 @@ bool ExternalString::is_uncached() const { ...@@ -580,7 +580,7 @@ bool ExternalString::is_uncached() const {
} }
Address ExternalString::resource_as_address() { Address ExternalString::resource_as_address() {
return READ_UINTPTR_FIELD(*this, kResourceOffset); return ReadField<Address>(kResourceOffset);
} }
void ExternalString::set_address_as_resource(Address address) { void ExternalString::set_address_as_resource(Address address) {
...@@ -593,7 +593,7 @@ void ExternalString::set_address_as_resource(Address address) { ...@@ -593,7 +593,7 @@ void ExternalString::set_address_as_resource(Address address) {
} }
uint32_t ExternalString::resource_as_uint32() { uint32_t ExternalString::resource_as_uint32() {
return static_cast<uint32_t>(READ_UINTPTR_FIELD(*this, kResourceOffset)); return static_cast<uint32_t>(ReadField<Address>(kResourceOffset));
} }
void ExternalString::set_uint32_as_resource(uint32_t value) { void ExternalString::set_uint32_as_resource(uint32_t value) {
...@@ -605,7 +605,7 @@ void ExternalString::set_uint32_as_resource(uint32_t value) { ...@@ -605,7 +605,7 @@ void ExternalString::set_uint32_as_resource(uint32_t value) {
void ExternalString::DisposeResource() { void ExternalString::DisposeResource() {
v8::String::ExternalStringResourceBase* resource = v8::String::ExternalStringResourceBase* resource =
reinterpret_cast<v8::String::ExternalStringResourceBase*>( reinterpret_cast<v8::String::ExternalStringResourceBase*>(
READ_UINTPTR_FIELD(*this, ExternalString::kResourceOffset)); ReadField<Address>(ExternalString::kResourceOffset));
// Dispose of the C++ object if it has not already been disposed. // Dispose of the C++ object if it has not already been disposed.
if (resource != nullptr) { if (resource != nullptr) {
...@@ -615,8 +615,7 @@ void ExternalString::DisposeResource() { ...@@ -615,8 +615,7 @@ void ExternalString::DisposeResource() {
} }
const ExternalOneByteString::Resource* ExternalOneByteString::resource() { const ExternalOneByteString::Resource* ExternalOneByteString::resource() {
return reinterpret_cast<Resource*>( return reinterpret_cast<Resource*>(ReadField<Address>(kResourceOffset));
READ_UINTPTR_FIELD(*this, kResourceOffset));
} }
void ExternalOneByteString::update_data_cache() { void ExternalOneByteString::update_data_cache() {
...@@ -651,8 +650,7 @@ uint8_t ExternalOneByteString::Get(int index) { ...@@ -651,8 +650,7 @@ uint8_t ExternalOneByteString::Get(int index) {
} }
const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() {
return reinterpret_cast<Resource*>( return reinterpret_cast<Resource*>(ReadField<Address>(kResourceOffset));
READ_UINTPTR_FIELD(*this, kResourceOffset));
} }
void ExternalTwoByteString::update_data_cache() { void ExternalTwoByteString::update_data_cache() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment