[ptr-compr] Using TaggedField<> in more places
Bug: v8:9353 Change-Id: Ie090f8f89eb4372845fe2c9d6aa74154c36f2d53 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1662291 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#62221}
This commit is contained in:
parent
b1c2160c2f
commit
b9591a58e9
@ -130,10 +130,7 @@ bool JSObject::PrototypeHasNoElements(Isolate* isolate, JSObject object) {
|
|||||||
|
|
||||||
ACCESSORS(JSReceiver, raw_properties_or_hash, Object, kPropertiesOrHashOffset)
|
ACCESSORS(JSReceiver, raw_properties_or_hash, Object, kPropertiesOrHashOffset)
|
||||||
|
|
||||||
FixedArrayBase JSObject::elements() const {
|
ACCESSORS(JSObject, elements, FixedArrayBase, kElementsOffset)
|
||||||
Object array = READ_FIELD(*this, kElementsOffset);
|
|
||||||
return FixedArrayBase::cast(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
|
void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
|
||||||
JSObject::ValidateElements(*object);
|
JSObject::ValidateElements(*object);
|
||||||
@ -238,14 +235,9 @@ void JSObject::SetMapAndElements(Handle<JSObject> object, Handle<Map> new_map,
|
|||||||
object->set_elements(*value);
|
object->set_elements(*value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSObject::set_elements(FixedArrayBase value, WriteBarrierMode mode) {
|
|
||||||
WRITE_FIELD(*this, kElementsOffset, value);
|
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, kElementsOffset, value, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSObject::initialize_elements() {
|
void JSObject::initialize_elements() {
|
||||||
FixedArrayBase elements = map().GetInitialElements();
|
FixedArrayBase elements = map().GetInitialElements();
|
||||||
WRITE_FIELD(*this, kElementsOffset, elements);
|
set_elements(elements, SKIP_WRITE_BARRIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
InterceptorInfo JSObject::GetIndexedInterceptor() {
|
InterceptorInfo JSObject::GetIndexedInterceptor() {
|
||||||
|
@ -31,19 +31,11 @@ OBJECT_CONSTRUCTORS_IMPL(Map, HeapObject)
|
|||||||
CAST_ACCESSOR(Map)
|
CAST_ACCESSOR(Map)
|
||||||
|
|
||||||
DescriptorArray Map::instance_descriptors() const {
|
DescriptorArray Map::instance_descriptors() const {
|
||||||
return DescriptorArray::cast(READ_FIELD(*this, kInstanceDescriptorsOffset));
|
return TaggedField<DescriptorArray, kInstanceDescriptorsOffset>::load(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorArray Map::synchronized_instance_descriptors() const {
|
SYNCHRONIZED_ACCESSORS(Map, synchronized_instance_descriptors, DescriptorArray,
|
||||||
return DescriptorArray::cast(
|
kInstanceDescriptorsOffset)
|
||||||
ACQUIRE_READ_FIELD(*this, kInstanceDescriptorsOffset));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::set_synchronized_instance_descriptors(DescriptorArray value,
|
|
||||||
WriteBarrierMode mode) {
|
|
||||||
RELEASE_WRITE_FIELD(*this, kInstanceDescriptorsOffset, value);
|
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, kInstanceDescriptorsOffset, value, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A freshly allocated layout descriptor can be set on an existing map.
|
// A freshly allocated layout descriptor can be set on an existing map.
|
||||||
// We need to use release-store and acquire-load accessor pairs to ensure
|
// We need to use release-store and acquire-load accessor pairs to ensure
|
||||||
@ -54,6 +46,12 @@ SYNCHRONIZED_ACCESSORS_CHECKED(Map, layout_descriptor, LayoutDescriptor,
|
|||||||
FLAG_unbox_double_fields)
|
FLAG_unbox_double_fields)
|
||||||
WEAK_ACCESSORS(Map, raw_transitions, kTransitionsOrPrototypeInfoOffset)
|
WEAK_ACCESSORS(Map, raw_transitions, kTransitionsOrPrototypeInfoOffset)
|
||||||
|
|
||||||
|
ACCESSORS_CHECKED2(Map, prototype, HeapObject, kPrototypeOffset, true,
|
||||||
|
value.IsNull() || value.IsJSReceiver())
|
||||||
|
|
||||||
|
ACCESSORS_CHECKED(Map, prototype_info, Object,
|
||||||
|
kTransitionsOrPrototypeInfoOffset, this->is_prototype_map())
|
||||||
|
|
||||||
// |bit_field| fields.
|
// |bit_field| fields.
|
||||||
// Concurrent access to |has_prototype_slot| and |has_non_instance_prototype|
|
// Concurrent access to |has_prototype_slot| and |has_non_instance_prototype|
|
||||||
// is explicitly whitelisted here. The former is never modified after the map
|
// is explicitly whitelisted here. The former is never modified after the map
|
||||||
@ -568,22 +566,13 @@ bool Map::IsPrimitiveMap() const {
|
|||||||
return instance_type() <= LAST_PRIMITIVE_TYPE;
|
return instance_type() <= LAST_PRIMITIVE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapObject Map::prototype() const {
|
|
||||||
return HeapObject::cast(READ_FIELD(*this, kPrototypeOffset));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::set_prototype(HeapObject value, WriteBarrierMode mode) {
|
|
||||||
DCHECK(value.IsNull() || value.IsJSReceiver());
|
|
||||||
WRITE_FIELD(*this, kPrototypeOffset, value);
|
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, kPrototypeOffset, value, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutDescriptor Map::layout_descriptor_gc_safe() const {
|
LayoutDescriptor Map::layout_descriptor_gc_safe() const {
|
||||||
DCHECK(FLAG_unbox_double_fields);
|
DCHECK(FLAG_unbox_double_fields);
|
||||||
// The loaded value can be dereferenced on background thread to load the
|
// The loaded value can be dereferenced on background thread to load the
|
||||||
// bitmap. We need acquire load in order to ensure that the bitmap
|
// bitmap. We need acquire load in order to ensure that the bitmap
|
||||||
// initializing stores are also visible to the background thread.
|
// initializing stores are also visible to the background thread.
|
||||||
Object layout_desc = ACQUIRE_READ_FIELD(*this, kLayoutDescriptorOffset);
|
Object layout_desc =
|
||||||
|
TaggedField<Object, kLayoutDescriptorOffset>::Acquire_Load(*this);
|
||||||
return LayoutDescriptor::cast_gc_safe(layout_desc);
|
return LayoutDescriptor::cast_gc_safe(layout_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +580,8 @@ bool Map::HasFastPointerLayout() const {
|
|||||||
DCHECK(FLAG_unbox_double_fields);
|
DCHECK(FLAG_unbox_double_fields);
|
||||||
// The loaded value is used for SMI check only and is not dereferenced,
|
// The loaded value is used for SMI check only and is not dereferenced,
|
||||||
// so relaxed load is safe.
|
// so relaxed load is safe.
|
||||||
Object layout_desc = RELAXED_READ_FIELD(*this, kLayoutDescriptorOffset);
|
Object layout_desc =
|
||||||
|
TaggedField<Object, kLayoutDescriptorOffset>::Relaxed_Load(*this);
|
||||||
return LayoutDescriptor::IsFastPointerLayout(layout_desc);
|
return LayoutDescriptor::IsFastPointerLayout(layout_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,18 +688,6 @@ Map Map::ElementsTransitionMap(Isolate* isolate) {
|
|||||||
.SearchSpecial(ReadOnlyRoots(isolate).elements_transition_symbol());
|
.SearchSpecial(ReadOnlyRoots(isolate).elements_transition_symbol());
|
||||||
}
|
}
|
||||||
|
|
||||||
Object Map::prototype_info() const {
|
|
||||||
DCHECK(is_prototype_map());
|
|
||||||
return READ_FIELD(*this, Map::kTransitionsOrPrototypeInfoOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::set_prototype_info(Object value, WriteBarrierMode mode) {
|
|
||||||
CHECK(is_prototype_map());
|
|
||||||
WRITE_FIELD(*this, Map::kTransitionsOrPrototypeInfoOffset, value);
|
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, Map::kTransitionsOrPrototypeInfoOffset,
|
|
||||||
value, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::SetBackPointer(Object value, WriteBarrierMode mode) {
|
void Map::SetBackPointer(Object value, WriteBarrierMode mode) {
|
||||||
CHECK_GE(instance_type(), FIRST_JS_RECEIVER_TYPE);
|
CHECK_GE(instance_type(), FIRST_JS_RECEIVER_TYPE);
|
||||||
CHECK(value.IsMap());
|
CHECK(value.IsMap());
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
#undef RELAXED_READ_FIELD
|
#undef RELAXED_READ_FIELD
|
||||||
#undef RELAXED_READ_WEAK_FIELD
|
#undef RELAXED_READ_WEAK_FIELD
|
||||||
#undef WRITE_FIELD
|
#undef WRITE_FIELD
|
||||||
#undef WRITE_WEAK_FIELD
|
|
||||||
#undef RELEASE_WRITE_FIELD
|
#undef RELEASE_WRITE_FIELD
|
||||||
#undef RELAXED_WRITE_FIELD
|
#undef RELAXED_WRITE_FIELD
|
||||||
#undef RELAXED_WRITE_WEAK_FIELD
|
#undef RELAXED_WRITE_WEAK_FIELD
|
||||||
|
@ -116,13 +116,18 @@
|
|||||||
#define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
|
#define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
|
||||||
set_condition) \
|
set_condition) \
|
||||||
type holder::name() const { \
|
type holder::name() const { \
|
||||||
type value = type::cast(READ_FIELD(*this, offset)); \
|
type value = TaggedField<type, offset>::load(*this); \
|
||||||
DCHECK(get_condition); \
|
DCHECK(get_condition); \
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
void holder::set_##name(type value, WriteBarrierMode mode) { \
|
void holder::set_##name(type value, WriteBarrierMode mode) { \
|
||||||
DCHECK(set_condition); \
|
DCHECK(set_condition); \
|
||||||
WRITE_FIELD(*this, offset, value); \
|
if (V8_CONCURRENT_MARKING_BOOL) { \
|
||||||
|
TaggedField<type, offset>::Relaxed_Store(*this, value); \
|
||||||
|
} else { \
|
||||||
|
TaggedField<type, offset>::store(*this, value); \
|
||||||
|
} \
|
||||||
|
TaggedField<type, offset>::store(*this, value); \
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
|
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,13 +140,13 @@
|
|||||||
#define SYNCHRONIZED_ACCESSORS_CHECKED2(holder, name, type, offset, \
|
#define SYNCHRONIZED_ACCESSORS_CHECKED2(holder, name, type, offset, \
|
||||||
get_condition, set_condition) \
|
get_condition, set_condition) \
|
||||||
type holder::name() const { \
|
type holder::name() const { \
|
||||||
type value = type::cast(ACQUIRE_READ_FIELD(*this, offset)); \
|
type value = TaggedField<type, offset>::Acquire_Load(*this); \
|
||||||
DCHECK(get_condition); \
|
DCHECK(get_condition); \
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
void holder::set_##name(type value, WriteBarrierMode mode) { \
|
void holder::set_##name(type value, WriteBarrierMode mode) { \
|
||||||
DCHECK(set_condition); \
|
DCHECK(set_condition); \
|
||||||
RELEASE_WRITE_FIELD(*this, offset, value); \
|
TaggedField<type, offset>::Release_Store(*this, value); \
|
||||||
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
|
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +166,11 @@
|
|||||||
} \
|
} \
|
||||||
void holder::set_##name(MaybeObject value, WriteBarrierMode mode) { \
|
void holder::set_##name(MaybeObject value, WriteBarrierMode mode) { \
|
||||||
DCHECK(set_condition); \
|
DCHECK(set_condition); \
|
||||||
WRITE_WEAK_FIELD(*this, offset, value); \
|
if (V8_CONCURRENT_MARKING_BOOL) { \
|
||||||
|
TaggedField<MaybeObject, offset>::Relaxed_Store(*this, value); \
|
||||||
|
} else { \
|
||||||
|
TaggedField<MaybeObject, offset>::store(*this, value); \
|
||||||
|
} \
|
||||||
CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \
|
CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,12 +184,16 @@
|
|||||||
#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
|
#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
|
||||||
int holder::name() const { \
|
int holder::name() const { \
|
||||||
DCHECK(condition); \
|
DCHECK(condition); \
|
||||||
Object value = READ_FIELD(*this, offset); \
|
Smi value = TaggedField<Smi, offset>::load(*this); \
|
||||||
return Smi::ToInt(value); \
|
return value.value(); \
|
||||||
} \
|
} \
|
||||||
void holder::set_##name(int value) { \
|
void holder::set_##name(int value) { \
|
||||||
DCHECK(condition); \
|
DCHECK(condition); \
|
||||||
WRITE_FIELD(*this, offset, Smi::FromInt(value)); \
|
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(holder, name, offset) \
|
#define SMI_ACCESSORS(holder, name, offset) \
|
||||||
@ -188,20 +201,20 @@
|
|||||||
|
|
||||||
#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \
|
#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \
|
||||||
int holder::synchronized_##name() const { \
|
int holder::synchronized_##name() const { \
|
||||||
Object value = ACQUIRE_READ_FIELD(*this, offset); \
|
Smi value = TaggedField<Smi, offset>::Acquire_Load(*this); \
|
||||||
return Smi::ToInt(value); \
|
return value.value(); \
|
||||||
} \
|
} \
|
||||||
void holder::synchronized_set_##name(int value) { \
|
void holder::synchronized_set_##name(int value) { \
|
||||||
RELEASE_WRITE_FIELD(*this, offset, Smi::FromInt(value)); \
|
TaggedField<Smi, offset>::Release_Store(*this, Smi::FromInt(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RELAXED_SMI_ACCESSORS(holder, name, offset) \
|
#define RELAXED_SMI_ACCESSORS(holder, name, offset) \
|
||||||
int holder::relaxed_read_##name() const { \
|
int holder::relaxed_read_##name() const { \
|
||||||
Object value = RELAXED_READ_FIELD(*this, offset); \
|
Smi value = TaggedField<Smi, offset>::Relaxed_Load(*this); \
|
||||||
return Smi::ToInt(value); \
|
return value.value(); \
|
||||||
} \
|
} \
|
||||||
void holder::relaxed_write_##name(int value) { \
|
void holder::relaxed_write_##name(int value) { \
|
||||||
RELAXED_WRITE_FIELD(*this, offset, Smi::FromInt(value)); \
|
TaggedField<Smi, offset>::Relaxed_Store(*this, Smi::FromInt(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BOOL_GETTER(holder, field, name, offset) \
|
#define BOOL_GETTER(holder, field, name, offset) \
|
||||||
@ -257,13 +270,9 @@
|
|||||||
#ifdef V8_CONCURRENT_MARKING
|
#ifdef V8_CONCURRENT_MARKING
|
||||||
#define WRITE_FIELD(p, offset, value) \
|
#define WRITE_FIELD(p, offset, value) \
|
||||||
ObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value)
|
ObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value)
|
||||||
#define WRITE_WEAK_FIELD(p, offset, value) \
|
|
||||||
MaybeObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value)
|
|
||||||
#else
|
#else
|
||||||
#define WRITE_FIELD(p, offset, value) \
|
#define WRITE_FIELD(p, offset, value) \
|
||||||
ObjectSlot(FIELD_ADDR(p, offset)).store(value)
|
ObjectSlot(FIELD_ADDR(p, offset)).store(value)
|
||||||
#define WRITE_WEAK_FIELD(p, offset, value) \
|
|
||||||
MaybeObjectSlot(FIELD_ADDR(p, offset)).store(value)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RELEASE_WRITE_FIELD(p, offset, value) \
|
#define RELEASE_WRITE_FIELD(p, offset, value) \
|
||||||
|
Loading…
Reference in New Issue
Block a user