Commit 32392279 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Split UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR macro

... into UNIQUE_LEAF_INSTANCE_TYPE_MAP_LIST_GENERATOR and the rest
where the former list contains only those maps which have 1:1 relation
to instance type values.

Bug: v8:11880
Change-Id: Ibe20ec7a7c432680dcf23a5c0102ae89c0689d47
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3218065
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77394}
parent 571eca5c
...@@ -19,7 +19,13 @@ namespace internal { ...@@ -19,7 +19,13 @@ namespace internal {
namespace InstanceTypeChecker { namespace InstanceTypeChecker {
// Define type checkers for classes with single instance type. // Define type checkers for classes with single instance type.
#define INSTANCE_TYPE_CHECKER(type, forinstancetype) \
V8_INLINE constexpr bool Is##type(InstanceType instance_type) { \
return instance_type == forinstancetype; \
}
INSTANCE_TYPE_CHECKERS_SINGLE(INSTANCE_TYPE_CHECKER) INSTANCE_TYPE_CHECKERS_SINGLE(INSTANCE_TYPE_CHECKER)
#undef INSTANCE_TYPE_CHECKER
// Checks if value is in range [lower_limit, higher_limit] using a single // Checks if value is in range [lower_limit, higher_limit] using a single
// branch. Assumes that the input instance type is valid. // branch. Assumes that the input instance type is valid.
...@@ -47,36 +53,48 @@ struct InstanceRangeChecker<lower_limit, LAST_TYPE> { ...@@ -47,36 +53,48 @@ struct InstanceRangeChecker<lower_limit, LAST_TYPE> {
// Define type checkers for classes with ranges of instance types. // Define type checkers for classes with ranges of instance types.
#define INSTANCE_TYPE_CHECKER_RANGE(type, first_instance_type, \ #define INSTANCE_TYPE_CHECKER_RANGE(type, first_instance_type, \
last_instance_type) \ last_instance_type) \
V8_INLINE bool Is##type(InstanceType instance_type) { \ V8_INLINE constexpr bool Is##type(InstanceType instance_type) { \
return InstanceRangeChecker<first_instance_type, \ return InstanceRangeChecker<first_instance_type, \
last_instance_type>::Check(instance_type); \ last_instance_type>::Check(instance_type); \
} }
INSTANCE_TYPE_CHECKERS_RANGE(INSTANCE_TYPE_CHECKER_RANGE) INSTANCE_TYPE_CHECKERS_RANGE(INSTANCE_TYPE_CHECKER_RANGE)
#undef INSTANCE_TYPE_CHECKER_RANGE #undef INSTANCE_TYPE_CHECKER_RANGE
V8_INLINE bool IsHeapObject(InstanceType instance_type) { return true; } V8_INLINE constexpr bool IsHeapObject(InstanceType instance_type) {
return true;
}
V8_INLINE bool IsInternalizedString(InstanceType instance_type) { V8_INLINE constexpr bool IsInternalizedString(InstanceType instance_type) {
STATIC_ASSERT(kNotInternalizedTag != 0); STATIC_ASSERT(kNotInternalizedTag != 0);
return (instance_type & (kIsNotStringMask | kIsNotInternalizedMask)) == return (instance_type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
(kStringTag | kInternalizedTag); (kStringTag | kInternalizedTag);
} }
V8_INLINE bool IsExternalString(InstanceType instance_type) { V8_INLINE constexpr bool IsExternalString(InstanceType instance_type) {
return (instance_type & (kIsNotStringMask | kStringRepresentationMask)) == return (instance_type & (kIsNotStringMask | kStringRepresentationMask)) ==
kExternalStringTag; kExternalStringTag;
} }
V8_INLINE bool IsThinString(InstanceType instance_type) { V8_INLINE constexpr bool IsThinString(InstanceType instance_type) {
return (instance_type & kStringRepresentationMask) == kThinStringTag; return (instance_type & kStringRepresentationMask) == kThinStringTag;
} }
V8_INLINE constexpr bool IsFreeSpaceOrFiller(InstanceType instance_type) {
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
}
} // namespace InstanceTypeChecker } // namespace InstanceTypeChecker
// TODO(v8:7786): For instance types that have a single map instance on the // TODO(v8:7786): For instance types that have a single map instance on the
// roots, and when that map is a embedded in the binary, compare against the map // roots, and when that map is a embedded in the binary, compare against the map
// pointer rather than looking up the instance type. // pointer rather than looking up the instance type.
#define TYPE_CHECKER(type, ...) \
DEF_GETTER(HeapObject, Is##type, bool) { \
return InstanceTypeChecker::Is##type(map(cage_base).instance_type()); \
}
INSTANCE_TYPE_CHECKERS(TYPE_CHECKER) INSTANCE_TYPE_CHECKERS(TYPE_CHECKER)
#undef TYPE_CHECKER
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -231,6 +231,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, ...@@ -231,6 +231,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
TORQUE_INSTANCE_CHECKERS_RANGE_ONLY_DECLARED(V) TORQUE_INSTANCE_CHECKERS_RANGE_ONLY_DECLARED(V)
#define INSTANCE_TYPE_CHECKERS_CUSTOM(V) \ #define INSTANCE_TYPE_CHECKERS_CUSTOM(V) \
V(FreeSpaceOrFiller) \
V(ExternalString) \ V(ExternalString) \
V(InternalizedString) V(InternalizedString)
...@@ -241,7 +242,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, ...@@ -241,7 +242,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
namespace InstanceTypeChecker { namespace InstanceTypeChecker {
#define IS_TYPE_FUNCTION_DECL(Type, ...) \ #define IS_TYPE_FUNCTION_DECL(Type, ...) \
V8_INLINE bool Is##Type(InstanceType instance_type); V8_INLINE constexpr bool Is##Type(InstanceType instance_type);
INSTANCE_TYPE_CHECKERS(IS_TYPE_FUNCTION_DECL) INSTANCE_TYPE_CHECKERS(IS_TYPE_FUNCTION_DECL)
...@@ -254,8 +255,11 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) ...@@ -254,8 +255,11 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL)
} // namespace InstanceTypeChecker } // namespace InstanceTypeChecker
// This list must contain only maps that are shared by all objects of their // This list must contain only maps that are shared by all objects of their
// instance type. // instance type AND respective object must not represent a parent class for
#define UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \ // multiple instance types (e.g. DescriptorArray has a unique map, but it has
// a subclass StrongDescriptorArray which is included into the "DescriptorArray"
// range of instance types).
#define UNIQUE_LEAF_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \
V(_, AccessorInfoMap, accessor_info_map, AccessorInfo) \ V(_, AccessorInfoMap, accessor_info_map, AccessorInfo) \
V(_, AccessorPairMap, accessor_pair_map, AccessorPair) \ V(_, AccessorPairMap, accessor_pair_map, AccessorPair) \
V(_, AllocationMementoMap, allocation_memento_map, AllocationMemento) \ V(_, AllocationMementoMap, allocation_memento_map, AllocationMemento) \
...@@ -263,6 +267,7 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) ...@@ -263,6 +267,7 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL)
ArrayBoilerplateDescription) \ ArrayBoilerplateDescription) \
V(_, BreakPointMap, break_point_map, BreakPoint) \ V(_, BreakPointMap, break_point_map, BreakPoint) \
V(_, BreakPointInfoMap, break_point_info_map, BreakPointInfo) \ V(_, BreakPointInfoMap, break_point_info_map, BreakPointInfo) \
V(_, BytecodeArrayMap, bytecode_array_map, BytecodeArray) \
V(_, CachedTemplateObjectMap, cached_template_object_map, \ V(_, CachedTemplateObjectMap, cached_template_object_map, \
CachedTemplateObject) \ CachedTemplateObject) \
V(_, CellMap, cell_map, Cell) \ V(_, CellMap, cell_map, Cell) \
...@@ -271,14 +276,15 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) ...@@ -271,14 +276,15 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL)
V(_, CodeDataContainerMap, code_data_container_map, CodeDataContainer) \ V(_, CodeDataContainerMap, code_data_container_map, CodeDataContainer) \
V(_, CoverageInfoMap, coverage_info_map, CoverageInfo) \ V(_, CoverageInfoMap, coverage_info_map, CoverageInfo) \
V(_, DebugInfoMap, debug_info_map, DebugInfo) \ V(_, DebugInfoMap, debug_info_map, DebugInfo) \
V(_, FreeSpaceMap, free_space_map, FreeSpace) \
V(_, FeedbackVectorMap, feedback_vector_map, FeedbackVector) \ V(_, FeedbackVectorMap, feedback_vector_map, FeedbackVector) \
V(_, FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArray) \ V(_, FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArray) \
V(_, FunctionTemplateInfoMap, function_template_info_map, \ V(_, FunctionTemplateInfoMap, function_template_info_map, \
FunctionTemplateInfo) \ FunctionTemplateInfo) \
V(_, HeapNumberMap, heap_number_map, HeapNumber) \
V(_, MegaDomHandlerMap, mega_dom_handler_map, MegaDomHandler) \ V(_, MegaDomHandlerMap, mega_dom_handler_map, MegaDomHandler) \
V(_, MetaMap, meta_map, Map) \ V(_, MetaMap, meta_map, Map) \
V(_, PreparseDataMap, preparse_data_map, PreparseData) \ V(_, PreparseDataMap, preparse_data_map, PreparseData) \
V(_, PropertyArrayMap, property_array_map, PropertyArray) \
V(_, PrototypeInfoMap, prototype_info_map, PrototypeInfo) \ V(_, PrototypeInfoMap, prototype_info_map, PrototypeInfo) \
V(_, SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfo) \ V(_, SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfo) \
V(_, SmallOrderedHashSetMap, small_ordered_hash_set_map, \ V(_, SmallOrderedHashSetMap, small_ordered_hash_set_map, \
...@@ -290,8 +296,14 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) ...@@ -290,8 +296,14 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL)
V(_, SwissNameDictionaryMap, swiss_name_dictionary_map, SwissNameDictionary) \ V(_, SwissNameDictionaryMap, swiss_name_dictionary_map, SwissNameDictionary) \
V(_, SymbolMap, symbol_map, Symbol) \ V(_, SymbolMap, symbol_map, Symbol) \
V(_, TransitionArrayMap, transition_array_map, TransitionArray) \ V(_, TransitionArrayMap, transition_array_map, TransitionArray) \
V(_, Tuple2Map, tuple2_map, Tuple2) \ V(_, Tuple2Map, tuple2_map, Tuple2)
V(_, WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArray) \
// This list must contain only maps that are shared by all objects of their
// instance type.
#define UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \
UNIQUE_LEAF_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \
V(_, HeapNumberMap, heap_number_map, HeapNumber) \
V(_, WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArray) \
TORQUE_DEFINED_MAP_CSA_LIST_GENERATOR(V, _) TORQUE_DEFINED_MAP_CSA_LIST_GENERATOR(V, _)
} // namespace internal } // namespace internal
......
...@@ -74,8 +74,6 @@ ...@@ -74,8 +74,6 @@
#undef RELAXED_BOOL_ACCESSORS #undef RELAXED_BOOL_ACCESSORS
#undef BIT_FIELD_ACCESSORS2 #undef BIT_FIELD_ACCESSORS2
#undef BIT_FIELD_ACCESSORS #undef BIT_FIELD_ACCESSORS
#undef INSTANCE_TYPE_CHECKER
#undef TYPE_CHECKER
#undef RELAXED_INT16_ACCESSORS #undef RELAXED_INT16_ACCESSORS
#undef FIELD_ADDR #undef FIELD_ADDR
#undef ACQUIRE_READ_FIELD #undef ACQUIRE_READ_FIELD
......
...@@ -401,16 +401,6 @@ ...@@ -401,16 +401,6 @@
#define BIT_FIELD_ACCESSORS(holder, field, name, BitField) \ #define BIT_FIELD_ACCESSORS(holder, field, name, BitField) \
BIT_FIELD_ACCESSORS2(holder, field, field, name, BitField) BIT_FIELD_ACCESSORS2(holder, field, field, name, BitField)
#define INSTANCE_TYPE_CHECKER(type, forinstancetype) \
V8_INLINE bool Is##type(InstanceType instance_type) { \
return instance_type == forinstancetype; \
}
#define TYPE_CHECKER(type, ...) \
DEF_GETTER(HeapObject, Is##type, bool) { \
return InstanceTypeChecker::Is##type(map(cage_base).instance_type()); \
}
#define RELAXED_INT16_ACCESSORS(holder, name, offset) \ #define RELAXED_INT16_ACCESSORS(holder, name, offset) \
int16_t holder::name() const { \ int16_t holder::name() const { \
return RELAXED_READ_INT16_FIELD(*this, offset); \ return RELAXED_READ_INT16_FIELD(*this, offset); \
......
...@@ -272,11 +272,6 @@ bool Object::IsNumeric(PtrComprCageBase cage_base) const { ...@@ -272,11 +272,6 @@ bool Object::IsNumeric(PtrComprCageBase cage_base) const {
return IsNumber(cage_base) || IsBigInt(cage_base); return IsNumber(cage_base) || IsBigInt(cage_base);
} }
DEF_GETTER(HeapObject, IsFreeSpaceOrFiller, bool) {
InstanceType instance_type = map(cage_base).instance_type();
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
}
DEF_GETTER(HeapObject, IsArrayList, bool) { DEF_GETTER(HeapObject, IsArrayList, bool) {
ReadOnlyRoots roots = GetReadOnlyRoots(cage_base); ReadOnlyRoots roots = GetReadOnlyRoots(cage_base);
return *this == roots.empty_fixed_array() || return *this == roots.empty_fixed_array() ||
......
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