diff --git a/src/compiler/code-assembler.cc b/src/compiler/code-assembler.cc index c6deeed386..67a469ab05 100644 --- a/src/compiler/code-assembler.cc +++ b/src/compiler/code-assembler.cc @@ -1909,6 +1909,8 @@ Address CheckObjectType(Address raw_value, Address raw_type, break; TYPE_CASE(Object) + TYPE_CASE(Smi) + TYPE_CASE(HeapObject) OBJECT_TYPE_LIST(TYPE_CASE) HEAP_OBJECT_TYPE_LIST(TYPE_CASE) STRUCT_LIST(TYPE_STRUCT_CASE) diff --git a/src/compiler/code-assembler.h b/src/compiler/code-assembler.h index 30dc505303..7b9a3702e0 100644 --- a/src/compiler/code-assembler.h +++ b/src/compiler/code-assembler.h @@ -66,14 +66,12 @@ class JSFinalizationGroupCleanupIterator; class JSWeakMap; class JSWeakRef; class JSWeakSet; -class MaybeObject; class PromiseCapability; class PromiseFulfillReactionJobTask; class PromiseReaction; class PromiseReactionJobTask; class PromiseRejectReactionJobTask; class WasmDebugInfo; -class WeakCell; class Zone; template @@ -280,9 +278,12 @@ class int31_t { #define ENUM_ELEMENT(Name) k##Name, #define ENUM_STRUCT_ELEMENT(NAME, Name, name) k##Name, enum class ObjectType { - kObject, - OBJECT_TYPE_LIST(ENUM_ELEMENT) HEAP_OBJECT_TYPE_LIST(ENUM_ELEMENT) - STRUCT_LIST(ENUM_STRUCT_ELEMENT) + ENUM_ELEMENT(Object) // + ENUM_ELEMENT(Smi) // + ENUM_ELEMENT(HeapObject) // + OBJECT_TYPE_LIST(ENUM_ELEMENT) // + HEAP_OBJECT_TYPE_LIST(ENUM_ELEMENT) // + STRUCT_LIST(ENUM_STRUCT_ELEMENT) // }; #undef ENUM_ELEMENT #undef ENUM_STRUCT_ELEMENT @@ -349,6 +350,8 @@ struct ObjectTypeOf {}; static const ObjectType value = ObjectType::k##Name; \ }; OBJECT_TYPE_CASE(Object) +OBJECT_TYPE_CASE(Smi) +OBJECT_TYPE_CASE(HeapObject) OBJECT_TYPE_LIST(OBJECT_TYPE_CASE) HEAP_OBJECT_ORDINARY_TYPE_LIST(OBJECT_TYPE_CASE) STRUCT_LIST(OBJECT_TYPE_STRUCT_CASE) diff --git a/src/objects-inl.h b/src/objects-inl.h index 42055e7073..8bf77cdc0a 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -35,6 +35,7 @@ #include "src/objects/shared-function-info.h" #include "src/objects/slots-inl.h" #include "src/objects/smi-inl.h" +#include "src/objects/tagged-impl-inl.h" #include "src/objects/templates.h" #include "src/property-details.h" #include "src/property.h" @@ -749,21 +750,6 @@ bool Object::ToArrayIndex(uint32_t* index) const { return Object::ToUint32(index) && *index != kMaxUInt32; } -bool Object::GetHeapObjectIfStrong(HeapObject* result) const { - return GetHeapObject(result); -} - -bool Object::GetHeapObject(HeapObject* result) const { - if (!IsHeapObject()) return false; - *result = HeapObject::cast(*this); - return true; -} - -HeapObject Object::GetHeapObject() const { - DCHECK(IsHeapObject()); - return HeapObject::cast(*this); -} - int RegExpMatchInfo::NumberOfCaptureRegisters() { DCHECK_GE(length(), kLastMatchOverhead); Object obj = get(kNumberOfCapturesIndex); diff --git a/src/objects.h b/src/objects.h index bfdd2c88a4..af6f563960 100644 --- a/src/objects.h +++ b/src/objects.h @@ -265,29 +265,15 @@ ShouldThrow GetShouldThrow(Isolate* isolate, Maybe should_throw); // There must only be a single data member in Object: the Address ptr, // containing the tagged heap pointer that this Object instance refers to. // For a design overview, see https://goo.gl/Ph4CGz. -class Object { +class Object : public TaggedImpl { public: - constexpr Object() : ptr_(kNullAddress) {} - explicit constexpr Object(Address ptr) : ptr_(ptr) {} - - // Make clang on Linux catch what MSVC complains about on Windows: - operator bool() const = delete; - - bool operator==(const Object that) const { return this->ptr() == that.ptr(); } - bool operator!=(const Object that) const { return this->ptr() != that.ptr(); } - // Usage in std::set requires operator<. - bool operator<(const Object that) const { return this->ptr() < that.ptr(); } - - // Returns the tagged "(heap) object pointer" representation of this object. - constexpr Address ptr() const { return ptr_; } + constexpr Object() : TaggedImpl(kNullAddress) {} + explicit constexpr Object(Address ptr) : TaggedImpl(ptr) {} // These operator->() overloads are required for handlified code. Object* operator->() { return this; } const Object* operator->() const { return this; } - // Type testing. - bool IsObject() const { return true; } - #define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const; OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) @@ -588,34 +574,6 @@ class Object { // and length. bool IterationHasObservableEffects(); - // - // The following GetHeapObjectXX methods mimic corresponding functionality - // in MaybeObject. Having them here allows us to unify code that processes - // ObjectSlots and MaybeObjectSlots. - // - - // If this Object is a strong pointer to a HeapObject, returns true and - // sets *result. Otherwise returns false. - inline bool GetHeapObjectIfStrong(HeapObject* result) const; - - // If this Object is a strong pointer to a HeapObject (weak pointers are not - // expected), returns true and sets *result. Otherwise returns false. - inline bool GetHeapObject(HeapObject* result) const; - - // DCHECKs that this Object is a strong pointer to a HeapObject and returns - // the HeapObject. - inline HeapObject GetHeapObject() const; - - // Always returns false because Object is not expected to be a weak pointer - // to a HeapObject. - inline bool GetHeapObjectIfWeak(HeapObject* result) const { - DCHECK(!HAS_WEAK_HEAP_OBJECT_TAG(ptr_)); - return false; - } - // Always returns false because Object is not expected to be a weak pointer - // to a HeapObject. - inline bool IsCleared() const { return false; } - EXPORT_DECL_VERIFIER(Object) #ifdef VERIFY_HEAP @@ -706,19 +664,10 @@ class Object { Isolate* isolate, Handle input); V8_WARN_UNUSED_RESULT static MaybeHandle ConvertToIndex( Isolate* isolate, Handle input, MessageTemplate error_index); - - Address ptr_; }; V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Object& obj); -// In objects.h to be usable without objects-inl.h inclusion. -bool Object::IsSmi() const { return HAS_SMI_TAG(ptr()); } -bool Object::IsHeapObject() const { - DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr())); - return !IsSmi(); -} - struct Brief { template explicit Brief(TObject v) : value{v.ptr()} {} diff --git a/src/objects/object-list-macros.h b/src/objects/object-list-macros.h index 15efb69ad7..01ca3db62b 100644 --- a/src/objects/object-list-macros.h +++ b/src/objects/object-list-macros.h @@ -66,9 +66,7 @@ template class ZoneForwardList; #define OBJECT_TYPE_LIST(V) \ - V(Smi) \ V(LayoutDescriptor) \ - V(HeapObject) \ V(Primitive) \ V(Number) \ V(Numeric) diff --git a/tools/gen-postmortem-metadata.py b/tools/gen-postmortem-metadata.py index 9145e15fdf..e1c84ef323 100644 --- a/tools/gen-postmortem-metadata.py +++ b/tools/gen-postmortem-metadata.py @@ -402,7 +402,11 @@ def load_objects_from_file(objfilename, checktypes): klass = match.group(1).strip(); pklass = match.group(2); if (pklass): - pklass = pklass.strip(); + # Strip potential template arguments from parent + # class. + match = re.match(r'(\w+)(<.*>)?', pklass.strip()); + pklass = match.group(1).strip(); + klasses[klass] = { 'parent': pklass }; #