#include "JSCell.h"
#include "CallFrame.h"
+#include "Structure.h"
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