JSDestructibleObject.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef JSDestructibleObject_h
  2. #define JSDestructibleObject_h
  3. #include "JSObject.h"
  4. namespace JSC {
  5. struct ClassInfo;
  6. class JSDestructibleObject : public JSNonFinalObject {
  7. public:
  8. typedef JSNonFinalObject Base;
  9. static const bool needsDestruction = true;
  10. const ClassInfo* classInfo() const { return m_classInfo; }
  11. static ptrdiff_t classInfoOffset() { return OBJECT_OFFSETOF(JSDestructibleObject, m_classInfo); }
  12. protected:
  13. JSDestructibleObject(VM& vm, Structure* structure, Butterfly* butterfly = 0)
  14. : JSNonFinalObject(vm, structure, butterfly)
  15. , m_classInfo(structure->classInfo())
  16. {
  17. ASSERT(m_classInfo);
  18. }
  19. private:
  20. const ClassInfo* m_classInfo;
  21. };
  22. inline const ClassInfo* JSCell::classInfo() const
  23. {
  24. if (MarkedBlock::blockFor(this)->destructorType() == MarkedBlock::Normal)
  25. return static_cast<const JSDestructibleObject*>(this)->classInfo();
  26. #if ENABLE(GC_VALIDATION)
  27. return m_structure.unvalidatedGet()->classInfo();
  28. #else
  29. return m_structure->classInfo();
  30. #endif
  31. }
  32. } // namespace JSC
  33. #endif