Commit 349ed4cf authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[cleanup] Mechanically generate Map::Is*Map testers.

Tbr: hpayer@chromium.org
Change-Id: I3f10ee70a9f9990e0259095826ac40371a96bac5
Reviewed-on: https://chromium-review.googlesource.com/1225756
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55892}
parent 185fd388
......@@ -1810,7 +1810,7 @@ Handle<Map> Factory::NewMap(InstanceType type, int instance_size,
ElementsKind elements_kind,
int inobject_properties) {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
DCHECK_IMPLIES(Map::IsJSObject(type) &&
DCHECK_IMPLIES(InstanceTypeChecker::IsJSObject(type) &&
!Map::CanHaveFastTransitionableElementsKind(type),
IsDictionaryElementsKind(elements_kind) ||
IsTerminalElementsKind(elements_kind));
......
......@@ -91,7 +91,7 @@ AllocationResult Heap::AllocateMap(InstanceType instance_type,
ElementsKind elements_kind,
int inobject_properties) {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
bool is_js_object = Map::IsJSObject(instance_type);
bool is_js_object = InstanceTypeChecker::IsJSObject(instance_type);
DCHECK_IMPLIES(is_js_object &&
!Map::CanHaveFastTransitionableElementsKind(instance_type),
IsDictionaryElementsKind(elements_kind) ||
......
......@@ -117,6 +117,11 @@ V8_INLINE bool IsJSObject(InstanceType instance_type) {
return instance_type >= FIRST_JS_OBJECT_TYPE;
}
V8_INLINE bool IsJSReceiver(InstanceType instance_type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
return instance_type >= FIRST_JS_RECEIVER_TYPE;
}
} // namespace InstanceTypeChecker
// TODO(v8:7786): For instance types that have a single map instance on the
......@@ -287,13 +292,6 @@ bool HeapObject::IsFiller() const {
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
}
bool HeapObject::IsJSReceiver() const {
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
return map()->instance_type() >= FIRST_JS_RECEIVER_TYPE;
}
bool HeapObject::IsJSProxy() const { return map()->IsJSProxyMap(); }
bool HeapObject::IsJSWeakCollection() const {
return IsJSWeakMap() || IsJSWeakSet();
}
......
......@@ -1003,6 +1003,7 @@ class ZoneForwardList;
V(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) \
V(JSModuleNamespace, JS_MODULE_NAMESPACE_TYPE) \
V(JSPromise, JS_PROMISE_TYPE) \
V(JSProxy, JS_PROXY_TYPE) \
V(JSRegExp, JS_REGEXP_TYPE) \
V(JSRegExpResult, JS_ARRAY_TYPE) \
V(JSRegExpStringIterator, JS_REGEXP_STRING_ITERATOR_TYPE) \
......@@ -1084,7 +1085,8 @@ class ZoneForwardList;
#define INSTANCE_TYPE_CHECKERS_CUSTOM(V) \
V(FixedArrayBase) \
V(InternalizedString) \
V(JSObject)
V(JSObject) \
V(JSReceiver)
#define INSTANCE_TYPE_CHECKERS(V) \
INSTANCE_TYPE_CHECKERS_SINGLE(V) \
......
......@@ -511,57 +511,30 @@ void Map::NotifyLeafMapLayoutChange(Isolate* isolate) {
}
}
bool Map::IsJSObject(InstanceType type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
return type >= FIRST_JS_OBJECT_TYPE;
}
bool Map::CanTransition() const {
// Only JSObject and subtypes have map transitions and back pointers.
return IsJSObject(instance_type());
return InstanceTypeChecker::IsJSObject(instance_type());
}
#define DEF_TESTER(Type, ...) \
bool Map::Is##Type##Map() const { \
return InstanceTypeChecker::Is##Type(instance_type()); \
}
INSTANCE_TYPE_CHECKERS(DEF_TESTER)
#undef DEF_TESTER
bool Map::IsBooleanMap() const {
return this == GetReadOnlyRoots().boolean_map();
}
bool Map::IsNullMap() const { return this == GetReadOnlyRoots().null_map(); }
bool Map::IsUndefinedMap() const {
return this == GetReadOnlyRoots().undefined_map();
}
bool Map::IsNullOrUndefinedMap() const {
return IsNullMap() || IsUndefinedMap();
return this == GetReadOnlyRoots().null_map() ||
this == GetReadOnlyRoots().undefined_map();
}
bool Map::IsPrimitiveMap() const {
return instance_type() <= LAST_PRIMITIVE_TYPE;
}
bool Map::IsJSReceiverMap() const {
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
return instance_type() >= FIRST_JS_RECEIVER_TYPE;
}
bool Map::IsJSObjectMap() const { return IsJSObject(instance_type()); }
bool Map::IsJSPromiseMap() const { return instance_type() == JS_PROMISE_TYPE; }
bool Map::IsJSArrayMap() const { return instance_type() == JS_ARRAY_TYPE; }
bool Map::IsJSFunctionMap() const {
return instance_type() == JS_FUNCTION_TYPE;
}
bool Map::IsStringMap() const { return instance_type() < FIRST_NONSTRING_TYPE; }
bool Map::IsJSProxyMap() const { return instance_type() == JS_PROXY_TYPE; }
bool Map::IsJSGlobalProxyMap() const {
return instance_type() == JS_GLOBAL_PROXY_TYPE;
}
bool Map::IsJSGlobalObjectMap() const {
return instance_type() == JS_GLOBAL_OBJECT_TYPE;
}
bool Map::IsJSTypedArrayMap() const {
return instance_type() == JS_TYPED_ARRAY_TYPE;
}
bool Map::IsJSDataViewMap() const {
return instance_type() == JS_DATA_VIEW_TYPE;
}
Object* Map::prototype() const { return READ_FIELD(this, kPrototypeOffset); }
......
......@@ -751,27 +751,14 @@ class Map : public HeapObject {
Map* FindElementsKindTransitionedMap(Isolate* isolate,
MapHandles const& candidates);
inline static bool IsJSObject(InstanceType type);
inline bool CanTransition() const;
#define DECL_TESTER(Type, ...) inline bool Is##Type##Map() const;
INSTANCE_TYPE_CHECKERS(DECL_TESTER)
#undef DECL_TESTER
inline bool IsBooleanMap() const;
inline bool IsNullMap() const;
inline bool IsUndefinedMap() const;
inline bool IsNullOrUndefinedMap() const;
inline bool IsPrimitiveMap() const;
inline bool IsJSReceiverMap() const;
inline bool IsJSObjectMap() const;
inline bool IsJSPromiseMap() const;
inline bool IsJSArrayMap() const;
inline bool IsJSFunctionMap() const;
inline bool IsStringMap() const;
inline bool IsJSProxyMap() const;
inline bool IsModuleMap() const;
inline bool IsJSGlobalProxyMap() const;
inline bool IsJSGlobalObjectMap() const;
inline bool IsJSTypedArrayMap() const;
inline bool IsJSDataViewMap() const;
inline bool IsSpecialReceiverMap() const;
inline bool IsCustomElementsReceiverMap() const;
......
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