Commit 2a440bb2 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Use [DECL|DEF]_GETTERS macros (part 1)

... for defining isolate-full getters.

Bug: v8:9353
Change-Id: I91aa11bfe41ab61b2fa72c21018fc38753a846bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1676286Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62375}
parent eb0dd1da
......@@ -523,10 +523,11 @@ void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) {
USE_TORQUE_VERIFIER(JSReceiver)
bool JSObject::ElementsAreSafeToExamine() const {
bool JSObject::ElementsAreSafeToExamine(Isolate* isolate) const {
// If a GC was caused while constructing this object, the elements
// pointer may point to a one pointer filler map.
return elements() != GetReadOnlyRoots().one_pointer_filler_map();
return elements(isolate) !=
GetReadOnlyRoots(isolate).one_pointer_filler_map();
}
namespace {
......@@ -632,7 +633,7 @@ void JSObject::JSObjectVerify(Isolate* isolate) {
// If a GC was caused while constructing this object, the elements
// pointer may point to a one pointer filler map.
if (ElementsAreSafeToExamine()) {
if (ElementsAreSafeToExamine(isolate)) {
CHECK_EQ((map().has_fast_smi_or_object_elements() ||
map().has_frozen_or_sealed_elements() ||
(elements() == GetReadOnlyRoots().empty_fixed_array()) ||
......@@ -1182,7 +1183,7 @@ void JSArray::JSArrayVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSArrayVerify(*this, isolate);
// If a GC was caused while constructing this array, the elements
// pointer may point to a one pointer filler map.
if (!ElementsAreSafeToExamine()) return;
if (!ElementsAreSafeToExamine(isolate)) return;
if (elements().IsUndefined(isolate)) return;
CHECK(elements().IsFixedArray() || elements().IsFixedDoubleArray());
if (elements().length() == 0) {
......
......@@ -2338,7 +2338,7 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<JSFunction> function(JSFunction::cast(New(map, allocation)),
isolate());
function->initialize_properties();
function->initialize_properties(isolate());
function->initialize_elements();
function->set_shared(*info);
function->set_code(info->GetCode());
......@@ -3292,7 +3292,7 @@ Handle<JSProxy> Factory::NewJSProxy(Handle<JSReceiver> target,
DCHECK(map->prototype().IsNull(isolate()));
Handle<JSProxy> result(JSProxy::cast(New(map, AllocationType::kYoung)),
isolate());
result->initialize_properties();
result->initialize_properties(isolate());
result->set_target(*target);
result->set_handler(*handler);
return result;
......
......@@ -201,7 +201,7 @@ class ElementsAccessor {
uint32_t destination_start, int copy_size) = 0;
private:
static ElementsAccessor** elements_accessors_;
V8_EXPORT_PRIVATE static ElementsAccessor** elements_accessors_;
DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
};
......
......@@ -29,8 +29,7 @@ class HeapObject : public Object {
// [map]: Contains a map which contains the object's reflective
// information.
inline Map map() const;
inline Map map(Isolate* isolate) const;
DECL_GETTER(map, Map)
inline void set_map(Map value);
inline ObjectSlot map_slot() const;
......@@ -59,8 +58,7 @@ class HeapObject : public Object {
// During garbage collection, the map word of a heap object does not
// necessarily contain a map pointer.
inline MapWord map_word() const;
inline MapWord map_word(Isolate* isolate) const;
DECL_GETTER(map_word, MapWord)
inline void set_map_word(MapWord map_word);
// TODO(v8:7464): Once RO_SPACE is shared between isolates, this method can be
......
This diff is collapsed.
......@@ -4480,10 +4480,6 @@ void JSObject::EnsureCanContainElements(Handle<JSObject> object,
object, args->slot_at(first_arg + arg_count - 1), arg_count, mode);
}
ElementsAccessor* JSObject::GetElementsAccessor() {
return ElementsAccessor::ForKind(GetElementsKind());
}
void JSObject::ValidateElements(JSObject object) {
#ifdef ENABLE_SLOW_DCHECKS
if (FLAG_enable_slow_asserts) {
......
......@@ -27,16 +27,16 @@ class JSReceiver : public HeapObject {
public:
NEVER_READ_ONLY_SPACE
// Returns true if there is no slow (ie, dictionary) backing store.
inline bool HasFastProperties() const;
DECL_GETTER(HasFastProperties, bool)
// Returns the properties array backing store if it
// exists. Otherwise, returns an empty_property_array when there's a
// Smi (hash code) or an empty_fixed_array for a fast properties
// map.
inline PropertyArray property_array() const;
DECL_GETTER(property_array, PropertyArray)
// Gets slow properties for non-global objects.
inline NameDictionary property_dictionary() const;
DECL_GETTER(property_dictionary, NameDictionary)
// Sets the properties backing store and makes sure any existing hash is moved
// to the new properties store. To clear out the properties store, pass in the
......@@ -62,7 +62,7 @@ class JSReceiver : public HeapObject {
// above typed getters and setters to access the properties.
DECL_ACCESSORS(raw_properties_or_hash, Object)
inline void initialize_properties();
inline void initialize_properties(Isolate* isolate);
// Deletes an existing named property in a normalized object.
static void DeleteNormalizedProperty(Handle<JSReceiver> object, int entry);
......@@ -311,58 +311,60 @@ class JSObject : public JSReceiver {
inline void initialize_elements();
static inline void SetMapAndElements(Handle<JSObject> object, Handle<Map> map,
Handle<FixedArrayBase> elements);
inline ElementsKind GetElementsKind() const;
V8_EXPORT_PRIVATE ElementsAccessor* GetElementsAccessor();
DECL_GETTER(GetElementsKind, ElementsKind)
DECL_GETTER(GetElementsAccessor, ElementsAccessor*)
// Returns true if an object has elements of PACKED_SMI_ELEMENTS or
// HOLEY_SMI_ELEMENTS ElementsKind.
inline bool HasSmiElements();
DECL_GETTER(HasSmiElements, bool)
// Returns true if an object has elements of PACKED_ELEMENTS or
// HOLEY_ELEMENTS ElementsKind.
inline bool HasObjectElements();
DECL_GETTER(HasObjectElements, bool)
// Returns true if an object has elements of PACKED_SMI_ELEMENTS,
// HOLEY_SMI_ELEMENTS, PACKED_ELEMENTS, or HOLEY_ELEMENTS.
inline bool HasSmiOrObjectElements();
DECL_GETTER(HasSmiOrObjectElements, bool)
// Returns true if an object has any of the "fast" elements kinds.
inline bool HasFastElements();
DECL_GETTER(HasFastElements, bool)
// Returns true if an object has any of the PACKED elements kinds.
inline bool HasFastPackedElements();
DECL_GETTER(HasFastPackedElements, bool)
// Returns true if an object has elements of PACKED_DOUBLE_ELEMENTS or
// HOLEY_DOUBLE_ELEMENTS ElementsKind.
inline bool HasDoubleElements();
DECL_GETTER(HasDoubleElements, bool)
// Returns true if an object has elements of HOLEY_SMI_ELEMENTS,
// HOLEY_DOUBLE_ELEMENTS, or HOLEY_ELEMENTS ElementsKind.
inline bool HasHoleyElements();
inline bool HasSloppyArgumentsElements();
inline bool HasStringWrapperElements();
inline bool HasDictionaryElements();
DECL_GETTER(HasHoleyElements, bool)
DECL_GETTER(HasSloppyArgumentsElements, bool)
DECL_GETTER(HasStringWrapperElements, bool)
DECL_GETTER(HasDictionaryElements, bool)
// Returns true if an object has elements of PACKED_ELEMENTS
inline bool HasPackedElements();
inline bool HasFrozenOrSealedElements();
inline bool HasSealedElements();
inline bool HasTypedArrayElements();
inline bool HasFixedUint8ClampedElements();
inline bool HasFixedArrayElements();
inline bool HasFixedInt8Elements();
inline bool HasFixedUint8Elements();
inline bool HasFixedInt16Elements();
inline bool HasFixedUint16Elements();
inline bool HasFixedInt32Elements();
inline bool HasFixedUint32Elements();
inline bool HasFixedFloat32Elements();
inline bool HasFixedFloat64Elements();
inline bool HasFixedBigInt64Elements();
inline bool HasFixedBigUint64Elements();
inline bool HasFastArgumentsElements();
inline bool HasSlowArgumentsElements();
inline bool HasFastStringWrapperElements();
inline bool HasSlowStringWrapperElements();
DECL_GETTER(HasPackedElements, bool)
DECL_GETTER(HasFrozenOrSealedElements, bool)
DECL_GETTER(HasSealedElements, bool)
DECL_GETTER(HasTypedArrayElements, bool)
DECL_GETTER(HasFixedUint8ClampedElements, bool)
DECL_GETTER(HasFixedArrayElements, bool)
DECL_GETTER(HasFixedInt8Elements, bool)
DECL_GETTER(HasFixedUint8Elements, bool)
DECL_GETTER(HasFixedInt16Elements, bool)
DECL_GETTER(HasFixedUint16Elements, bool)
DECL_GETTER(HasFixedInt32Elements, bool)
DECL_GETTER(HasFixedUint32Elements, bool)
DECL_GETTER(HasFixedFloat32Elements, bool)
DECL_GETTER(HasFixedFloat64Elements, bool)
DECL_GETTER(HasFixedBigInt64Elements, bool)
DECL_GETTER(HasFixedBigUint64Elements, bool)
DECL_GETTER(HasFastArgumentsElements, bool)
DECL_GETTER(HasSlowArgumentsElements, bool)
DECL_GETTER(HasFastStringWrapperElements, bool)
DECL_GETTER(HasSlowStringWrapperElements, bool)
bool HasEnumerableElements();
inline NumberDictionary element_dictionary(); // Gets slow elements.
// Gets slow elements.
DECL_GETTER(element_dictionary, NumberDictionary)
// Requires: HasFastElements().
static void EnsureWritableFastElements(Handle<JSObject> object);
......@@ -547,8 +549,8 @@ class JSObject : public JSReceiver {
// Lookup interceptors are used for handling properties controlled by host
// objects.
inline bool HasNamedInterceptor();
inline bool HasIndexedInterceptor();
DECL_GETTER(HasNamedInterceptor, bool)
DECL_GETTER(HasIndexedInterceptor, bool)
// Support functions for v8 api (needed for correct interceptor behavior).
V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealNamedProperty(
......@@ -728,7 +730,7 @@ class JSObject : public JSReceiver {
// If a GC was caused while constructing this object, the elements pointer
// may point to a one pointer filler map. The object won't be rooted, but
// our heap verification code could stumble across it.
V8_EXPORT_PRIVATE bool ElementsAreSafeToExamine() const;
V8_EXPORT_PRIVATE bool ElementsAreSafeToExamine(Isolate* isolate) const;
#endif
Object SlowReverseLookup(Object value);
......@@ -1080,13 +1082,14 @@ class JSFunction : public JSObject {
inline bool NeedsResetDueToFlushedBytecode();
inline void ResetIfBytecodeFlushed();
inline bool has_prototype_slot() const;
DECL_GETTER(has_prototype_slot, bool)
// The initial map for an object created by this constructor.
inline Map initial_map();
DECL_GETTER(initial_map, Map)
static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
Handle<HeapObject> prototype);
inline bool has_initial_map();
DECL_GETTER(has_initial_map, bool)
V8_EXPORT_PRIVATE static void EnsureHasInitialMap(
Handle<JSFunction> function);
......@@ -1101,12 +1104,12 @@ class JSFunction : public JSObject {
// function has an initial map the prototype is set on the initial
// map. Otherwise, the prototype is put in the initial map field
// until an initial map is needed.
inline bool has_prototype();
inline bool has_instance_prototype();
inline Object prototype();
inline HeapObject instance_prototype();
inline bool has_prototype_property();
inline bool PrototypeRequiresRuntimeLookup();
DECL_GETTER(has_prototype, bool)
DECL_GETTER(has_instance_prototype, bool)
DECL_GETTER(prototype, Object)
DECL_GETTER(instance_prototype, HeapObject)
DECL_GETTER(has_prototype_property, bool)
DECL_GETTER(PrototypeRequiresRuntimeLookup, bool)
static void SetPrototype(Handle<JSFunction> function, Handle<Object> value);
// Returns if this function has been compiled to native code yet.
......@@ -1207,7 +1210,7 @@ class JSGlobalObject : public JSObject {
DECL_ACCESSORS(global_proxy, JSGlobalProxy)
// Gets global object properties.
inline GlobalDictionary global_dictionary();
DECL_GETTER(global_dictionary, GlobalDictionary)
inline void set_global_dictionary(GlobalDictionary dictionary);
static void InvalidatePropertyCell(Handle<JSGlobalObject> object,
......
......@@ -686,21 +686,17 @@ void Map::AppendDescriptor(Isolate* isolate, Descriptor* desc) {
#endif
}
HeapObject Map::GetBackPointer() const {
Object object = constructor_or_backpointer();
if (object.IsMap()) {
DEF_GETTER(Map, GetBackPointer, HeapObject) {
Object object = constructor_or_backpointer(isolate);
if (object.IsMap(isolate)) {
return Map::cast(object);
}
return GetReadOnlyRoots().undefined_value();
// Can't use ReadOnlyRoots(isolate) as this isolate could be produced by
// i::GetIsolateForPtrCompr(HeapObject).
return GetReadOnlyRoots(isolate).undefined_value();
}
Map Map::ElementsTransitionMap(Isolate* isolate) {
DisallowHeapAllocation no_gc;
return TransitionsAccessor(isolate, *this, &no_gc)
.SearchSpecial(ReadOnlyRoots(isolate).elements_transition_symbol());
}
void Map::SetBackPointer(Object value, WriteBarrierMode mode) {
void Map::SetBackPointer(HeapObject value, WriteBarrierMode mode) {
CHECK_GE(instance_type(), FIRST_JS_RECEIVER_TYPE);
CHECK(value.IsMap());
CHECK(GetBackPointer().IsUndefined());
......@@ -709,6 +705,13 @@ void Map::SetBackPointer(Object value, WriteBarrierMode mode) {
set_constructor_or_backpointer(value, mode);
}
// static
Map Map::ElementsTransitionMap(Isolate* isolate) {
DisallowHeapAllocation no_gc;
return TransitionsAccessor(isolate, *this, &no_gc)
.SearchSpecial(ReadOnlyRoots(isolate).elements_transition_symbol());
}
ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(Map, prototype_validity_cell, Object, kPrototypeValidityCellOffset)
ACCESSORS(Map, constructor_or_backpointer, Object,
......@@ -721,23 +724,24 @@ bool Map::IsPrototypeValidityCellValid() const {
return value == Smi::FromInt(Map::kPrototypeChainValid);
}
Object Map::GetConstructor() const {
Object maybe_constructor = constructor_or_backpointer();
DEF_GETTER(Map, GetConstructor, Object) {
Object maybe_constructor = constructor_or_backpointer(isolate);
// Follow any back pointers.
while (maybe_constructor.IsMap()) {
while (maybe_constructor.IsMap(isolate)) {
maybe_constructor =
Map::cast(maybe_constructor).constructor_or_backpointer();
Map::cast(maybe_constructor).constructor_or_backpointer(isolate);
}
return maybe_constructor;
}
FunctionTemplateInfo Map::GetFunctionTemplateInfo() const {
Object constructor = GetConstructor();
if (constructor.IsJSFunction()) {
DCHECK(JSFunction::cast(constructor).shared().IsApiFunction());
return JSFunction::cast(constructor).shared().get_api_func_data();
DEF_GETTER(Map, GetFunctionTemplateInfo, FunctionTemplateInfo) {
Object constructor = GetConstructor(isolate);
if (constructor.IsJSFunction(isolate)) {
// TODO(ishell): IsApiFunction(isolate) and get_api_func_data(isolate)
DCHECK(JSFunction::cast(constructor).shared(isolate).IsApiFunction());
return JSFunction::cast(constructor).shared(isolate).get_api_func_data();
}
DCHECK(constructor.IsFunctionTemplateInfo());
DCHECK(constructor.IsFunctionTemplateInfo(isolate));
return FunctionTemplateInfo::cast(constructor);
}
......
......@@ -576,19 +576,18 @@ class Map : public HeapObject {
// Returns null_value if there's neither a constructor function nor a
// FunctionTemplateInfo available.
DECL_ACCESSORS(constructor_or_backpointer, Object)
inline Object GetConstructor() const;
inline FunctionTemplateInfo GetFunctionTemplateInfo() const;
DECL_GETTER(GetConstructor, Object)
DECL_GETTER(GetFunctionTemplateInfo, FunctionTemplateInfo)
inline void SetConstructor(Object constructor,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// [back pointer]: points back to the parent map from which a transition
// leads to this map. The field overlaps with the constructor (see above).
inline HeapObject GetBackPointer() const;
inline void SetBackPointer(Object value,
DECL_GETTER(GetBackPointer, HeapObject)
inline void SetBackPointer(HeapObject value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// [instance descriptors]: describes the object.
inline DescriptorArray instance_descriptors() const;
inline DescriptorArray instance_descriptors(Isolate* isolate) const;
DECL_GETTER(instance_descriptors, DescriptorArray)
V8_EXPORT_PRIVATE void SetInstanceDescriptors(Isolate* isolate,
DescriptorArray descriptors,
int number_of_own_descriptors);
......
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