[ptr-compr] Use TaggedField<> in DescriptorArray

Bug: v8:9353
Change-Id: I2824e237ce52cd7434e181d033b346e603fe61c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1662296
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62225}
This commit is contained in:
Igor Sheludko 2019-06-17 18:15:53 +02:00 committed by Commit Bot
parent 2425885552
commit 595813c6c4
9 changed files with 162 additions and 133 deletions

View File

@ -1942,11 +1942,13 @@ TNode<IntPtrT> CodeStubAssembler::LoadArrayLength(
return LoadAndUntagWeakFixedArrayLength(array);
}
template <typename Array>
TNode<MaybeObject> CodeStubAssembler::LoadArrayElement(
TNode<Array> array, int array_header_size, Node* index_node,
int additional_offset, ParameterMode parameter_mode,
LoadSensitivity needs_poisoning) {
template <typename Array, typename T>
TNode<T> CodeStubAssembler::LoadArrayElement(TNode<Array> array,
int array_header_size,
Node* index_node,
int additional_offset,
ParameterMode parameter_mode,
LoadSensitivity needs_poisoning) {
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(
ParameterToIntPtr(index_node, parameter_mode),
IntPtrConstant(0)));
@ -1956,13 +1958,12 @@ TNode<MaybeObject> CodeStubAssembler::LoadArrayElement(
parameter_mode, header_size);
CSA_ASSERT(this, IsOffsetInBounds(offset, LoadArrayLength(array),
array_header_size));
constexpr MachineType machine_type = MachineTypeOf<T>::value;
// TODO(gsps): Remove the Load case once LoadFromObject supports poisoning
if (needs_poisoning == LoadSensitivity::kSafe) {
return UncheckedCast<MaybeObject>(
LoadFromObject(MachineType::AnyTagged(), array, offset));
return UncheckedCast<T>(LoadFromObject(machine_type, array, offset));
} else {
return UncheckedCast<MaybeObject>(
Load(MachineType::AnyTagged(), array, offset, needs_poisoning));
return UncheckedCast<T>(Load(machine_type, array, offset, needs_poisoning));
}
}
@ -8359,40 +8360,41 @@ TNode<IntPtrT> CodeStubAssembler::EntryToIndex(TNode<IntPtrT> entry,
field_index));
}
TNode<MaybeObject> CodeStubAssembler::LoadDescriptorArrayElement(
TNode<DescriptorArray> object, Node* index, int additional_offset) {
return LoadArrayElement(object, DescriptorArray::kHeaderSize, index,
additional_offset);
template <typename T>
TNode<T> CodeStubAssembler::LoadDescriptorArrayElement(
TNode<DescriptorArray> object, TNode<IntPtrT> index,
int additional_offset) {
return LoadArrayElement<DescriptorArray, T>(
object, DescriptorArray::kHeaderSize, index, additional_offset);
}
TNode<Name> CodeStubAssembler::LoadKeyByKeyIndex(
TNode<DescriptorArray> container, TNode<IntPtrT> key_index) {
return CAST(LoadDescriptorArrayElement(container, key_index, 0));
return CAST(LoadDescriptorArrayElement<HeapObject>(container, key_index, 0));
}
TNode<Uint32T> CodeStubAssembler::LoadDetailsByKeyIndex(
TNode<DescriptorArray> container, TNode<IntPtrT> key_index) {
const int kKeyToDetails =
DescriptorArray::ToDetailsIndex(0) - DescriptorArray::ToKeyIndex(0);
return Unsigned(
LoadAndUntagToWord32ArrayElement(container, DescriptorArray::kHeaderSize,
key_index, kKeyToDetails * kTaggedSize));
const int kKeyToDetailsOffset =
DescriptorArray::kEntryDetailsOffset - DescriptorArray::kEntryKeyOffset;
return Unsigned(LoadAndUntagToWord32ArrayElement(
container, DescriptorArray::kHeaderSize, key_index, kKeyToDetailsOffset));
}
TNode<Object> CodeStubAssembler::LoadValueByKeyIndex(
TNode<DescriptorArray> container, TNode<IntPtrT> key_index) {
const int kKeyToValue =
DescriptorArray::ToValueIndex(0) - DescriptorArray::ToKeyIndex(0);
return CAST(LoadDescriptorArrayElement(container, key_index,
kKeyToValue * kTaggedSize));
const int kKeyToValueOffset =
DescriptorArray::kEntryValueOffset - DescriptorArray::kEntryKeyOffset;
return LoadDescriptorArrayElement<Object>(container, key_index,
kKeyToValueOffset);
}
TNode<MaybeObject> CodeStubAssembler::LoadFieldTypeByKeyIndex(
TNode<DescriptorArray> container, TNode<IntPtrT> key_index) {
const int kKeyToValue =
DescriptorArray::ToValueIndex(0) - DescriptorArray::ToKeyIndex(0);
return LoadDescriptorArrayElement(container, key_index,
kKeyToValue * kTaggedSize);
const int kKeyToValueOffset =
DescriptorArray::kEntryValueOffset - DescriptorArray::kEntryKeyOffset;
return LoadDescriptorArrayElement<MaybeObject>(container, key_index,
kKeyToValueOffset);
}
TNode<IntPtrT> CodeStubAssembler::DescriptorEntryToIndex(
@ -8403,14 +8405,14 @@ TNode<IntPtrT> CodeStubAssembler::DescriptorEntryToIndex(
TNode<Name> CodeStubAssembler::LoadKeyByDescriptorEntry(
TNode<DescriptorArray> container, TNode<IntPtrT> descriptor_entry) {
return CAST(LoadDescriptorArrayElement(
return CAST(LoadDescriptorArrayElement<HeapObject>(
container, DescriptorEntryToIndex(descriptor_entry),
DescriptorArray::ToKeyIndex(0) * kTaggedSize));
}
TNode<Name> CodeStubAssembler::LoadKeyByDescriptorEntry(
TNode<DescriptorArray> container, int descriptor_entry) {
return CAST(LoadDescriptorArrayElement(
return CAST(LoadDescriptorArrayElement<HeapObject>(
container, IntPtrConstant(0),
DescriptorArray::ToKeyIndex(descriptor_entry) * kTaggedSize));
}
@ -8432,14 +8434,14 @@ TNode<Uint32T> CodeStubAssembler::LoadDetailsByDescriptorEntry(
TNode<Object> CodeStubAssembler::LoadValueByDescriptorEntry(
TNode<DescriptorArray> container, int descriptor_entry) {
return CAST(LoadDescriptorArrayElement(
return LoadDescriptorArrayElement<Object>(
container, IntPtrConstant(0),
DescriptorArray::ToValueIndex(descriptor_entry) * kTaggedSize));
DescriptorArray::ToValueIndex(descriptor_entry) * kTaggedSize);
}
TNode<MaybeObject> CodeStubAssembler::LoadFieldTypeByDescriptorEntry(
TNode<DescriptorArray> container, TNode<IntPtrT> descriptor_entry) {
return LoadDescriptorArrayElement(
return LoadDescriptorArrayElement<MaybeObject>(
container, DescriptorEntryToIndex(descriptor_entry),
DescriptorArray::ToValueIndex(0) * kTaggedSize);
}

View File

@ -1085,8 +1085,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Array is any array-like type that has a fixed header followed by
// tagged elements.
template <typename Array>
TNode<MaybeObject> LoadArrayElement(
template <typename Array, typename T = MaybeObject>
TNode<T> LoadArrayElement(
TNode<Array> array, int array_header_size, Node* index,
int additional_offset = 0,
ParameterMode parameter_mode = INTPTR_PARAMETERS,
@ -3600,9 +3600,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
private:
// Low-level accessors for Descriptor arrays.
TNode<MaybeObject> LoadDescriptorArrayElement(TNode<DescriptorArray> object,
Node* index,
int additional_offset = 0);
template <typename T>
TNode<T> LoadDescriptorArrayElement(TNode<DescriptorArray> object,
TNode<IntPtrT> index,
int additional_offset);
};
class V8_EXPORT_PRIVATE CodeStubArguments {

View File

@ -789,16 +789,17 @@ void FeedbackMetadata::FeedbackMetadataVerify(Isolate* isolate) {
void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::DescriptorArrayVerify(*this, isolate);
for (int i = 0; i < number_of_all_descriptors(); i++) {
MaybeObject::VerifyMaybeObjectPointer(isolate, get(ToKeyIndex(i)));
MaybeObject::VerifyMaybeObjectPointer(isolate, get(ToDetailsIndex(i)));
MaybeObject::VerifyMaybeObjectPointer(isolate, get(ToValueIndex(i)));
MaybeObjectSlot slot(GetDescriptorSlot(i));
MaybeObject::VerifyMaybeObjectPointer(isolate, *(slot + kEntryKeyIndex));
MaybeObject::VerifyMaybeObjectPointer(isolate,
*(slot + kEntryDetailsIndex));
MaybeObject::VerifyMaybeObjectPointer(isolate, *(slot + kEntryValueIndex));
}
if (number_of_all_descriptors() == 0) {
Heap* heap = isolate->heap();
CHECK_EQ(ReadOnlyRoots(heap).empty_descriptor_array(), *this);
CHECK_EQ(ReadOnlyRoots(isolate).empty_descriptor_array(), *this);
CHECK_EQ(0, number_of_all_descriptors());
CHECK_EQ(0, number_of_descriptors());
CHECK_EQ(ReadOnlyRoots(heap).empty_enum_cache(), enum_cache());
CHECK_EQ(ReadOnlyRoots(isolate).empty_enum_cache(), enum_cache());
} else {
CHECK_LT(0, number_of_all_descriptors());
CHECK_LE(number_of_descriptors(), number_of_all_descriptors());
@ -806,7 +807,7 @@ void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
// Check that properties with private symbols names are non-enumerable.
for (int descriptor = 0; descriptor < number_of_descriptors();
descriptor++) {
Object key = get(ToKeyIndex(descriptor))->cast<Object>();
Object key = *(GetDescriptorSlot(descriptor) + kEntryKeyIndex);
// number_of_descriptors() may be out of sync with the actual descriptors
// written during descriptor array construction.
if (key.IsUndefined(isolate)) continue;
@ -814,7 +815,7 @@ void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
if (Name::cast(key).IsPrivate()) {
CHECK_NE(details.attributes() & DONT_ENUM, 0);
}
MaybeObject value = get(ToValueIndex(descriptor));
MaybeObject value = GetValue(descriptor);
HeapObject heap_object;
if (details.location() == kField) {
CHECK(

View File

@ -106,17 +106,17 @@ ObjectSlot DescriptorArray::GetDescriptorSlot(int descriptor) {
return RawField(OffsetOfDescriptorAt(descriptor));
}
ObjectSlot DescriptorArray::GetKeySlot(int descriptor) {
DCHECK_LE(descriptor, number_of_all_descriptors());
ObjectSlot slot = GetDescriptorSlot(descriptor) + kEntryKeyIndex;
DCHECK((*slot).IsObject());
return slot;
Name DescriptorArray::GetKey(int descriptor_number) const {
DCHECK_LT(descriptor_number, number_of_descriptors());
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
return Name::cast(EntryKeyField::Relaxed_Load(*this, entry_offset));
}
Name DescriptorArray::GetKey(int descriptor_number) const {
DCHECK(descriptor_number < number_of_descriptors());
return Name::cast(
get(ToKeyIndex(descriptor_number))->GetHeapObjectAssumeStrong());
void DescriptorArray::SetKey(int descriptor_number, Name key) {
DCHECK_LT(descriptor_number, number_of_descriptors());
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
EntryKeyField::Relaxed_Store(*this, entry_offset, key);
WRITE_BARRIER(*this, entry_offset + kEntryKeyOffset, key);
}
int DescriptorArray::GetSortedKeyIndex(int descriptor_number) {
@ -127,35 +127,40 @@ Name DescriptorArray::GetSortedKey(int descriptor_number) {
return GetKey(GetSortedKeyIndex(descriptor_number));
}
void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) {
PropertyDetails details = GetDetails(descriptor_index);
set(ToDetailsIndex(descriptor_index),
MaybeObject::FromObject(details.set_pointer(pointer).AsSmi()));
}
MaybeObjectSlot DescriptorArray::GetValueSlot(int descriptor) {
DCHECK_LT(descriptor, number_of_descriptors());
return MaybeObjectSlot(GetDescriptorSlot(descriptor) + kEntryValueIndex);
void DescriptorArray::SetSortedKey(int descriptor_number, int pointer) {
PropertyDetails details = GetDetails(descriptor_number);
SetDetails(descriptor_number, details.set_pointer(pointer));
}
Object DescriptorArray::GetStrongValue(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return get(ToValueIndex(descriptor_number))->cast<Object>();
return GetValue(descriptor_number).cast<Object>();
}
void DescriptorArray::SetValue(int descriptor_index, Object value) {
set(ToValueIndex(descriptor_index), MaybeObject::FromObject(value));
void DescriptorArray::SetValue(int descriptor_number, MaybeObject value) {
DCHECK_LT(descriptor_number, number_of_descriptors());
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
EntryValueField::Relaxed_Store(*this, entry_offset, value);
WEAK_WRITE_BARRIER(*this, entry_offset + kEntryValueOffset, value);
}
MaybeObject DescriptorArray::GetValue(int descriptor_number) {
DCHECK_LT(descriptor_number, number_of_descriptors());
return get(ToValueIndex(descriptor_number));
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
return EntryValueField::Relaxed_Load(*this, entry_offset);
}
PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
MaybeObject details = get(ToDetailsIndex(descriptor_number));
return PropertyDetails(details->ToSmi());
DCHECK_LT(descriptor_number, number_of_descriptors());
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
Smi details = EntryDetailsField::Relaxed_Load(*this, entry_offset);
return PropertyDetails(details);
}
void DescriptorArray::SetDetails(int descriptor_number,
PropertyDetails details) {
DCHECK_LT(descriptor_number, number_of_descriptors());
int entry_offset = OffsetOfDescriptorAt(descriptor_number);
EntryDetailsField::Relaxed_Store(*this, entry_offset, details.AsSmi());
}
int DescriptorArray::GetFieldIndex(int descriptor_number) {
@ -171,12 +176,9 @@ FieldType DescriptorArray::GetFieldType(int descriptor_number) {
void DescriptorArray::Set(int descriptor_number, Name key, MaybeObject value,
PropertyDetails details) {
// Range check.
DCHECK(descriptor_number < number_of_descriptors());
set(ToKeyIndex(descriptor_number), MaybeObject::FromObject(key));
set(ToValueIndex(descriptor_number), value);
set(ToDetailsIndex(descriptor_number),
MaybeObject::FromObject(details.AsSmi()));
SetKey(descriptor_number, key);
SetDetails(descriptor_number, details);
SetValue(descriptor_number, value);
}
void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
@ -211,21 +213,6 @@ void DescriptorArray::SwapSortedKeys(int first, int second) {
SetSortedKey(second, first_key);
}
int DescriptorArray::length() const {
return number_of_all_descriptors() * kEntrySize;
}
MaybeObject DescriptorArray::get(int index) const {
DCHECK(index >= 0 && index < this->length());
return RELAXED_READ_WEAK_FIELD(*this, offset(index));
}
void DescriptorArray::set(int index, MaybeObject value) {
DCHECK(index >= 0 && index < this->length());
RELAXED_WRITE_WEAK_FIELD(*this, offset(index), value);
WEAK_WRITE_BARRIER(*this, offset(index), value);
}
} // namespace internal
} // namespace v8

View File

@ -74,7 +74,6 @@ class DescriptorArray : public HeapObject {
// Accessors for fetching instance descriptor at descriptor number.
inline Name GetKey(int descriptor_number) const;
inline Object GetStrongValue(int descriptor_number);
inline void SetValue(int descriptor_number, Object value);
inline MaybeObject GetValue(int descriptor_number);
inline PropertyDetails GetDetails(int descriptor_number);
inline int GetFieldIndex(int descriptor_number);
@ -153,15 +152,13 @@ class DescriptorArray : public HeapObject {
int16_t number_of_marked_descriptors);
static constexpr int SizeFor(int number_of_all_descriptors) {
return offset(number_of_all_descriptors * kEntrySize);
return OffsetOfDescriptorAt(number_of_all_descriptors);
}
static constexpr int OffsetOfDescriptorAt(int descriptor) {
return offset(descriptor * kEntrySize);
return kHeaderSize + descriptor * kEntrySize * kTaggedSize;
}
inline ObjectSlot GetFirstPointerSlot();
inline ObjectSlot GetDescriptorSlot(int descriptor);
inline ObjectSlot GetKeySlot(int descriptor);
inline MaybeObjectSlot GetValueSlot(int descriptor);
static_assert(kEndOfStrongFieldsOffset == kStartOfWeakFieldsOffset,
"Weak fields follow strong fields.");
@ -178,6 +175,10 @@ class DescriptorArray : public HeapObject {
static const int kEntryValueIndex = 2;
static const int kEntrySize = 3;
static const int kEntryKeyOffset = kEntryKeyIndex * kTaggedSize;
static const int kEntryDetailsOffset = kEntryDetailsIndex * kTaggedSize;
static const int kEntryValueOffset = kEntryValueIndex * kTaggedSize;
// Print all the descriptors.
void PrintDescriptors(std::ostream& os);
void PrintDescriptorDetails(std::ostream& os, int descriptor,
@ -207,15 +208,20 @@ class DescriptorArray : public HeapObject {
return (descriptor_number * kEntrySize) + kEntryValueIndex;
}
using EntryKeyField = TaggedField<HeapObject, kEntryKeyOffset>;
using EntryDetailsField = TaggedField<Smi, kEntryDetailsOffset>;
using EntryValueField = TaggedField<MaybeObject, kEntryValueOffset>;
private:
DECL_INT16_ACCESSORS(filler16bits)
// Low-level per-element accessors.
static constexpr int offset(int index) {
return kHeaderSize + index * kTaggedSize;
}
inline int length() const;
inline MaybeObject get(int index) const;
inline void set(int index, MaybeObject value);
inline void SetKey(int descriptor_number, Name key);
inline void SetValue(int descriptor_number, MaybeObject value);
inline void SetDetails(int descriptor_number, PropertyDetails details);
// inline int length() const;
// inline MaybeObject get(int index) const;
// inline void set(int index, MaybeObject value);
// Transfer a complete descriptor from the src descriptor array to this
// descriptor array.

View File

@ -181,19 +181,15 @@
WEAK_ACCESSORS_CHECKED(holder, name, offset, true)
// Getter that returns a Smi as an int and writes an int as a Smi.
#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
int holder::name() const { \
DCHECK(condition); \
Smi value = TaggedField<Smi, offset>::load(*this); \
return value.value(); \
} \
void holder::set_##name(int value) { \
DCHECK(condition); \
if (V8_CONCURRENT_MARKING_BOOL) { \
TaggedField<Smi, offset>::Relaxed_Store(*this, Smi::FromInt(value)); \
} else { \
TaggedField<Smi, offset>::store(*this, Smi::FromInt(value)); \
} \
#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
int holder::name() const { \
DCHECK(condition); \
Smi value = TaggedField<Smi, offset>::load(*this); \
return value.value(); \
} \
void holder::set_##name(int value) { \
DCHECK(condition); \
TaggedField<Smi, offset>::store(*this, Smi::FromInt(value)); \
}
#define SMI_ACCESSORS(holder, name, offset) \

View File

@ -2387,9 +2387,9 @@ void DescriptorArray::GeneralizeAllFields() {
if (details.location() == kField) {
DCHECK_EQ(kData, details.kind());
details = details.CopyWithConstness(PropertyConstness::kMutable);
SetValue(i, FieldType::Any());
SetValue(i, MaybeObject::FromObject(FieldType::Any()));
}
set(ToDetailsIndex(i), MaybeObject::FromObject(details.AsSmi()));
SetDetails(i, details);
}
}
@ -4294,8 +4294,10 @@ bool DescriptorArray::IsEqualTo(DescriptorArray other) {
if (number_of_all_descriptors() != other.number_of_all_descriptors()) {
return false;
}
for (int i = 0; i < number_of_all_descriptors(); ++i) {
if (get(i) != other.get(i)) return false;
for (int i = 0; i < number_of_descriptors(); ++i) {
if (GetKey(i) != other.GetKey(i)) return false;
if (GetDetails(i).AsSmi() != other.GetDetails(i).AsSmi()) return false;
if (GetValue(i) != other.GetValue(i)) return false;
}
return true;
}

View File

@ -14,14 +14,14 @@ namespace internal {
// static
template <typename T, int kFieldOffset>
Address TaggedField<T, kFieldOffset>::address(HeapObject host) {
return host.address() + kFieldOffset;
Address TaggedField<T, kFieldOffset>::address(HeapObject host, int offset) {
return host.address() + kFieldOffset + offset;
}
// static
template <typename T, int kFieldOffset>
Tagged_t* TaggedField<T, kFieldOffset>::location(HeapObject host) {
return reinterpret_cast<Tagged_t*>(address(host));
Tagged_t* TaggedField<T, kFieldOffset>::location(HeapObject host, int offset) {
return reinterpret_cast<Tagged_t*>(address(host, offset));
}
// static
@ -54,15 +54,16 @@ Tagged_t TaggedField<T, kFieldOffset>::full_to_tagged(Address value) {
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::load(HeapObject host) {
Tagged_t value = *location(host);
T TaggedField<T, kFieldOffset>::load(HeapObject host, int offset) {
Tagged_t value = *location(host, offset);
return T(tagged_to_full(host.ptr(), value));
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::load(Isolate* isolate, HeapObject host) {
Tagged_t value = *location(host);
T TaggedField<T, kFieldOffset>::load(Isolate* isolate, HeapObject host,
int offset) {
Tagged_t value = *location(host, offset);
return T(tagged_to_full(isolate, value));
}
@ -72,6 +73,12 @@ void TaggedField<T, kFieldOffset>::store(HeapObject host, T value) {
*location(host) = full_to_tagged(value.ptr());
}
// static
template <typename T, int kFieldOffset>
void TaggedField<T, kFieldOffset>::store(HeapObject host, int offset, T value) {
*location(host, offset) = full_to_tagged(value.ptr());
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Relaxed_Load(HeapObject host) {
@ -79,6 +86,13 @@ T TaggedField<T, kFieldOffset>::Relaxed_Load(HeapObject host) {
return T(tagged_to_full(host.ptr(), value));
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Relaxed_Load(HeapObject host, int offset) {
AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location(host, offset));
return T(tagged_to_full(host.ptr(), value));
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Relaxed_Load(Isolate* isolate,
@ -87,12 +101,28 @@ T TaggedField<T, kFieldOffset>::Relaxed_Load(Isolate* isolate,
return T(tagged_to_full(isolate, value));
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Relaxed_Load(Isolate* isolate, HeapObject host,
int offset) {
AtomicTagged_t value = AsAtomicTagged::Relaxed_Load(location(host, offset));
return T(tagged_to_full(isolate, value));
}
// static
template <typename T, int kFieldOffset>
void TaggedField<T, kFieldOffset>::Relaxed_Store(HeapObject host, T value) {
AsAtomicTagged::Relaxed_Store(location(host), full_to_tagged(value.ptr()));
}
// static
template <typename T, int kFieldOffset>
void TaggedField<T, kFieldOffset>::Relaxed_Store(HeapObject host, int offset,
T value) {
AsAtomicTagged::Relaxed_Store(location(host, offset),
full_to_tagged(value.ptr()));
}
// static
template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Acquire_Load(HeapObject host) {

View File

@ -35,17 +35,21 @@ class TaggedField : public AllStatic {
static constexpr bool kIsHeapObject =
std::is_base_of<HeapObject, T>::value || std::is_same<MapWord, T>::value;
static inline Address address(HeapObject host);
static inline Address address(HeapObject host, int offset = 0);
static inline T load(HeapObject host);
static inline T load(Isolate* isolate, HeapObject host);
static inline T load(HeapObject host, int offset = 0);
static inline T load(Isolate* isolate, HeapObject host, int offset = 0);
static inline void store(HeapObject host, T value);
static inline void store(HeapObject host, int offset, T value);
static inline T Relaxed_Load(HeapObject host);
static inline T Relaxed_Load(HeapObject host, int offset);
static inline T Relaxed_Load(Isolate* isolate, HeapObject host);
static inline T Relaxed_Load(Isolate* isolate, HeapObject host, int offset);
static inline void Relaxed_Store(HeapObject host, T value);
static inline void Relaxed_Store(HeapObject host, int offset, T value);
static inline T Acquire_Load(HeapObject host);
static inline T Acquire_Load(Isolate* isolate, HeapObject host);
@ -56,7 +60,7 @@ class TaggedField : public AllStatic {
T value);
private:
static inline Tagged_t* location(HeapObject host);
static inline Tagged_t* location(HeapObject host, int offset = 0);
template <typename TOnHeapAddress>
static inline Address tagged_to_full(TOnHeapAddress on_heap_addr,