X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..40a37d088818fc2fbeba2ef850dbcaaf294befbf:/runtime/JSWrapperObject.h diff --git a/runtime/JSWrapperObject.h b/runtime/JSWrapperObject.h index 7381128..349c75e 100644 --- a/runtime/JSWrapperObject.h +++ b/runtime/JSWrapperObject.h @@ -22,37 +22,65 @@ #ifndef JSWrapperObject_h #define JSWrapperObject_h -#include "JSObject.h" +#include "JSDestructibleObject.h" namespace JSC { - + // This class is used as a base for classes such as String, // Number, Boolean and Date which are wrappers for primitive types. - class JSWrapperObject : public JSObject { - protected: - explicit JSWrapperObject(PassRefPtr); - + class JSWrapperObject : public JSDestructibleObject { public: - JSValuePtr internalValue() const { return m_internalValue; } - void setInternalValue(JSValuePtr); - - virtual void mark(); + typedef JSDestructibleObject Base; + + static size_t allocationSize(size_t inlineCapacity) + { + ASSERT_UNUSED(inlineCapacity, !inlineCapacity); + return sizeof(JSWrapperObject); + } + + JSValue internalValue() const; + void setInternalValue(VM&, JSValue); + + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) + { + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); + } + static ptrdiff_t internalValueOffset() { return OBJECT_OFFSETOF(JSWrapperObject, m_internalValue); } + static ptrdiff_t internalValueCellOffset() + { +#if USE(JSVALUE64) + return internalValueOffset(); +#else + return internalValueOffset() + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload); +#endif + } + + protected: + explicit JSWrapperObject(VM&, Structure*); + static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags; + + static void visitChildren(JSCell*, SlotVisitor&); + private: - JSValuePtr m_internalValue; + WriteBarrier m_internalValue; }; - - inline JSWrapperObject::JSWrapperObject(PassRefPtr structure) - : JSObject(structure) - , m_internalValue(noValue()) + + inline JSWrapperObject::JSWrapperObject(VM& vm, Structure* structure) + : JSDestructibleObject(vm, structure) { } - - inline void JSWrapperObject::setInternalValue(JSValuePtr value) + + inline JSValue JSWrapperObject::internalValue() const + { + return m_internalValue.get(); + } + + inline void JSWrapperObject::setInternalValue(VM& vm, JSValue value) { ASSERT(value); ASSERT(!value.isObject()); - m_internalValue = value; + m_internalValue.set(vm, this, value); } } // namespace JSC