Commit d2061e53 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Add Xxx::yyy(Isolate*) accessors

... in addition to existing Xxx::yyy().

The idea is to use these getters in hot C++ code since passing isolate
explicitly makes it trivial to compute isolate root value and reduces
the C++ code size.

For full-pointer mode the unused isolate argument will be optimized
away by the compiler, so full-pointer mode should not be affected
in any sense.

Bug: v8:9353
Change-Id: If6c43e3d5b3cbfc0db8b9eccee49dd8c4d168822
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1674035Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62348}
parent 18fcd0b4
...@@ -30,8 +30,11 @@ namespace internal { ...@@ -30,8 +30,11 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Map, HeapObject) OBJECT_CONSTRUCTORS_IMPL(Map, HeapObject)
CAST_ACCESSOR(Map) CAST_ACCESSOR(Map)
DescriptorArray Map::instance_descriptors() const { ISOLATELESS_GETTER(Map, instance_descriptors, DescriptorArray)
return TaggedField<DescriptorArray, kInstanceDescriptorsOffset>::load(*this);
DescriptorArray Map::instance_descriptors(Isolate* isolate) const {
return TaggedField<DescriptorArray, kInstanceDescriptorsOffset>::load(isolate,
*this);
} }
SYNCHRONIZED_ACCESSORS(Map, synchronized_instance_descriptors, DescriptorArray, SYNCHRONIZED_ACCESSORS(Map, synchronized_instance_descriptors, DescriptorArray,
......
...@@ -588,7 +588,7 @@ class Map : public HeapObject { ...@@ -588,7 +588,7 @@ class Map : public HeapObject {
// [instance descriptors]: describes the object. // [instance descriptors]: describes the object.
inline DescriptorArray instance_descriptors() const; inline DescriptorArray instance_descriptors() const;
inline DescriptorArray synchronized_instance_descriptors() const; inline DescriptorArray instance_descriptors(Isolate* isolate) const;
V8_EXPORT_PRIVATE void SetInstanceDescriptors(Isolate* isolate, V8_EXPORT_PRIVATE void SetInstanceDescriptors(Isolate* isolate,
DescriptorArray descriptors, DescriptorArray descriptors,
int number_of_own_descriptors); int number_of_own_descriptors);
...@@ -966,13 +966,13 @@ class Map : public HeapObject { ...@@ -966,13 +966,13 @@ class Map : public HeapObject {
MaybeHandle<FieldType> new_field_type, MaybeHandle<Object> new_value); MaybeHandle<FieldType> new_field_type, MaybeHandle<Object> new_value);
// Use the high-level instance_descriptors/SetInstanceDescriptors instead. // Use the high-level instance_descriptors/SetInstanceDescriptors instead.
inline void set_synchronized_instance_descriptors( DECL_ACCESSORS(synchronized_instance_descriptors, DescriptorArray)
DescriptorArray array, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
static const int kFastPropertiesSoftLimit = 12; static const int kFastPropertiesSoftLimit = 12;
static const int kMaxFastProperties = 128; static const int kMaxFastProperties = 128;
friend class MapUpdater; friend class MapUpdater;
friend class ConcurrentMarkingVisitor;
OBJECT_CONSTRUCTORS(Map, HeapObject); OBJECT_CONSTRUCTORS(Map, HeapObject);
}; };
......
...@@ -65,9 +65,10 @@ ...@@ -65,9 +65,10 @@
inline uint8_t name() const; \ inline uint8_t name() const; \
inline void set_##name(int value); inline void set_##name(int value);
#define DECL_ACCESSORS(name, type) \ #define DECL_ACCESSORS(name, type) \
inline type name() const; \ inline type name() const; \
inline void set_##name(type value, \ inline type name(Isolate* isolate) const; \
inline void set_##name(type value, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER); WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
#define DECL_CAST(Type) \ #define DECL_CAST(Type) \
...@@ -122,8 +123,9 @@ ...@@ -122,8 +123,9 @@
#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 { \ ISOLATELESS_GETTER(holder, name, type) \
type value = TaggedField<type, offset>::load(*this); \ type holder::name(Isolate* isolate) const { \
type value = TaggedField<type, offset>::load(isolate, *this); \
DCHECK(get_condition); \ DCHECK(get_condition); \
return value; \ return value; \
} \ } \
...@@ -143,17 +145,18 @@ ...@@ -143,17 +145,18 @@
#define ACCESSORS(holder, name, type, offset) \ #define ACCESSORS(holder, name, type, offset) \
ACCESSORS_CHECKED(holder, name, type, offset, true) ACCESSORS_CHECKED(holder, name, type, offset, true)
#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 { \ ISOLATELESS_GETTER(holder, name, type) \
type value = TaggedField<type, offset>::Acquire_Load(*this); \ type holder::name(Isolate* isolate) const { \
DCHECK(get_condition); \ type value = TaggedField<type, offset>::Acquire_Load(isolate, *this); \
return value; \ DCHECK(get_condition); \
} \ return value; \
void holder::set_##name(type value, WriteBarrierMode mode) { \ } \
DCHECK(set_condition); \ void holder::set_##name(type value, WriteBarrierMode mode) { \
TaggedField<type, offset>::Release_Store(*this, value); \ DCHECK(set_condition); \
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \ TaggedField<type, offset>::Release_Store(*this, value); \
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
} }
#define SYNCHRONIZED_ACCESSORS_CHECKED(holder, name, type, offset, condition) \ #define SYNCHRONIZED_ACCESSORS_CHECKED(holder, name, type, offset, condition) \
...@@ -165,8 +168,10 @@ ...@@ -165,8 +168,10 @@
#define WEAK_ACCESSORS_CHECKED2(holder, name, offset, get_condition, \ #define WEAK_ACCESSORS_CHECKED2(holder, name, offset, get_condition, \
set_condition) \ set_condition) \
MaybeObject holder::name() const { \ ISOLATELESS_GETTER(holder, name, MaybeObject) \
MaybeObject value = READ_WEAK_FIELD(*this, offset); \ MaybeObject holder::name(Isolate* isolate) const { \
MaybeObject value = \
TaggedField<MaybeObject, offset>::load(isolate, *this); \
DCHECK(get_condition); \ DCHECK(get_condition); \
return value; \ return value; \
} \ } \
......
...@@ -573,8 +573,10 @@ void ConsString::set_second(Isolate* isolate, String value, ...@@ -573,8 +573,10 @@ void ConsString::set_second(Isolate* isolate, String value,
ACCESSORS(ThinString, actual, String, kActualOffset) ACCESSORS(ThinString, actual, String, kActualOffset)
HeapObject ThinString::unchecked_actual() const { ISOLATELESS_GETTER(ThinString, unchecked_actual, HeapObject)
return HeapObject::unchecked_cast(READ_FIELD(*this, kActualOffset));
HeapObject ThinString::unchecked_actual(Isolate* isolate) const {
return TaggedField<HeapObject, kActualOffset>::load(isolate, *this);
} }
bool ExternalString::is_uncached() const { bool ExternalString::is_uncached() const {
......
...@@ -640,10 +640,10 @@ class ConsString : public String { ...@@ -640,10 +640,10 @@ class ConsString : public String {
class ThinString : public String { class ThinString : public String {
public: public:
// Actual string that this ThinString refers to. // Actual string that this ThinString refers to.
inline String actual() const; DECL_ACCESSORS(actual, String)
inline HeapObject unchecked_actual() const; inline HeapObject unchecked_actual() const;
inline void set_actual(String s, inline HeapObject unchecked_actual(Isolate* isolate) const;
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
V8_EXPORT_PRIVATE uint16_t Get(int index); V8_EXPORT_PRIVATE uint16_t Get(int index);
......
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