Commit 49c31ec1 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[map] Faster HasOutOfObjectProperties check

The used_or_unused_instance_size_in_words field already determines
whether the used fields are in- or out-of-object, so we can use it's
value for a fast HasOutOfObjectProperties check rather than using
NumberOfFields (which includes an iteration over the descriptor
array).

Change-Id: I6c5b4f3f793b8df7832def7465106f2af7306759
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1718152
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81828}
parent 9981f2e5
...@@ -313,6 +313,13 @@ void Map::SetInObjectPropertiesStartInWords(int value) { ...@@ -313,6 +313,13 @@ void Map::SetInObjectPropertiesStartInWords(int value) {
set_inobject_properties_start_or_constructor_function_index(value); set_inobject_properties_start_or_constructor_function_index(value);
} }
bool Map::HasOutOfObjectProperties() const {
bool ret = used_or_unused_instance_size_in_words() < JSObject::kFieldsAdded;
DCHECK_EQ(ret, GetInObjectProperties() <
NumberOfFields(ConcurrencyMode::kSynchronous));
return ret;
}
int Map::GetInObjectProperties() const { int Map::GetInObjectProperties() const {
DCHECK(IsJSObjectMap()); DCHECK(IsJSObjectMap());
return instance_size_in_words() - GetInObjectPropertiesStartInWords(); return instance_size_in_words() - GetInObjectPropertiesStartInWords();
......
...@@ -571,11 +571,6 @@ Map::FieldCounts Map::GetFieldCounts() const { ...@@ -571,11 +571,6 @@ Map::FieldCounts Map::GetFieldCounts() const {
return FieldCounts(mutable_count, const_count); return FieldCounts(mutable_count, const_count);
} }
bool Map::HasOutOfObjectProperties() const {
return GetInObjectProperties() <
NumberOfFields(ConcurrencyMode::kSynchronous);
}
void Map::DeprecateTransitionTree(Isolate* isolate) { void Map::DeprecateTransitionTree(Isolate* isolate) {
if (is_deprecated()) return; if (is_deprecated()) return;
TransitionsAccessor transitions(isolate, *this); TransitionsAccessor transitions(isolate, *this);
......
...@@ -240,6 +240,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> { ...@@ -240,6 +240,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
// is equal to the instance size). // is equal to the instance size).
inline int UsedInstanceSize() const; inline int UsedInstanceSize() const;
inline bool HasOutOfObjectProperties() const;
// Tells how many unused property fields (in-object or out-of object) are // Tells how many unused property fields (in-object or out-of object) are
// available in the instance (only used for JSObject in fast mode). // available in the instance (only used for JSObject in fast mode).
inline int UnusedPropertyFields() const; inline int UnusedPropertyFields() const;
...@@ -505,8 +507,6 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> { ...@@ -505,8 +507,6 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
FieldCounts GetFieldCounts() const; FieldCounts GetFieldCounts() const;
int NumberOfFields(ConcurrencyMode cmode) const; int NumberOfFields(ConcurrencyMode cmode) const;
bool HasOutOfObjectProperties() const;
// TODO(ishell): candidate with JSObject::MigrateToMap(). // TODO(ishell): candidate with JSObject::MigrateToMap().
bool InstancesNeedRewriting(Map target, ConcurrencyMode cmode) const; bool InstancesNeedRewriting(Map target, ConcurrencyMode cmode) const;
bool InstancesNeedRewriting(Map target, int target_number_of_fields, bool InstancesNeedRewriting(Map target, int target_number_of_fields,
......
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