]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/GetterSetter.h
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / runtime / GetterSetter.h
index 4e47361ec8eb9d63103dcf25bd00ebd944e7d631..bc5cbe0afb1325f1d14f7af26fa9fc956e942ae4 100644 (file)
@@ -26,6 +26,7 @@
 #include "JSCell.h"
 
 #include "CallFrame.h"
+#include "Structure.h"
 
 namespace JSC {
 
@@ -34,39 +35,62 @@ namespace JSC {
     // This is an internal value object which stores getter and setter functions
     // for a property.
     class GetterSetter : public JSCell {
+        friend class JIT;
+
+    private:        
+        GetterSetter(VM& vm)
+            : JSCell(vm, vm.getterSetterStructure.get())
+        {
+        }
+
     public:
-        GetterSetter(ExecState* exec)
-            : JSCell(exec->globalData().getterSetterStructure.get())
-            , m_getter(0)
-            , m_setter(0)
+        typedef JSCell Base;
+
+        static GetterSetter* create(VM& vm)
         {
+            GetterSetter* getterSetter = new (NotNull, allocateCell<GetterSetter>(vm.heap)) GetterSetter(vm);
+            getterSetter->finishCreation(vm);
+            return getterSetter;
         }
 
-        virtual void markChildren(MarkStack&);
+        static void visitChildren(JSCell*, SlotVisitor&);
 
-        JSObject* getter() const { return m_getter; }
-        void setGetter(JSObject* getter) { m_getter = getter; }
-        JSObject* setter() const { return m_setter; }
-        void setSetter(JSObject* setter) { m_setter = setter; }
-        static PassRefPtr<Structure> createStructure(JSValue prototype)
+        JSObject* getter() const { return m_getter.get(); }
+        void setGetter(VM& vm, JSObject* getter) { m_getter.setMayBeNull(vm, this, getter); }
+        JSObject* setter() const { return m_setter.get(); }
+        void setSetter(VM& vm, JSObject* setter) { m_setter.setMayBeNull(vm, this, setter); }
+        static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
         {
-            return Structure::create(prototype, TypeInfo(GetterSetterType, OverridesMarkChildren), AnonymousSlotCount);
+            return Structure::create(vm, globalObject, prototype, TypeInfo(GetterSetterType, OverridesVisitChildren), info());
         }
-    private:
-        virtual bool isGetterSetter() const;
+        
+        static ptrdiff_t offsetOfGetter()
+        {
+            return OBJECT_OFFSETOF(GetterSetter, m_getter);
+        }
+        
+        static ptrdiff_t offsetOfSetter()
+        {
+            return OBJECT_OFFSETOF(GetterSetter, m_setter);
+        }
+        
+        DECLARE_INFO;
 
-        JSObject* m_getter;
-        JSObject* m_setter;  
+    private:
+        WriteBarrier<JSObject> m_getter;
+        WriteBarrier<JSObject> m_setter;  
     };
 
     GetterSetter* asGetterSetter(JSValue);
 
     inline GetterSetter* asGetterSetter(JSValue value)
     {
-        ASSERT(asCell(value)->isGetterSetter());
-        return static_cast<GetterSetter*>(asCell(value));
+        ASSERT_WITH_SECURITY_IMPLICATION(value.asCell()->isGetterSetter());
+        return static_cast<GetterSetter*>(value.asCell());
     }
 
+    JSValue callGetter(ExecState*, JSValue base, JSValue getterSetter);
+    void callSetter(ExecState*, JSValue base, JSValue getterSetter, JSValue value, ECMAMode);
 
 } // namespace JSC