Bug 803376 - Add JSObject::setCrossCompartmentSlot (r=terrence)

This commit is contained in:
Bill McCloskey 2012-09-14 16:58:50 -07:00
parent a6d1aea15e
commit d53bc493a0
4 changed files with 27 additions and 1 deletions

View File

@ -332,6 +332,18 @@ HeapSlot::set(JSCompartment *comp, JSObject *obj, uint32_t slot, const Value &v)
post(comp, obj, slot);
}
inline void
HeapSlot::setCrossCompartment(JSObject *obj, uint32_t slot, const Value &v, JSCompartment *vcomp)
{
JS_ASSERT_IF(!obj->isArray(), &const_cast<JSObject *>(obj)->getSlotRef(slot) == this);
JS_ASSERT_IF(obj->isDenseArray(), &obj->getDenseArrayElement(slot) == (const Value *)this);
pre();
JS_ASSERT(!IsPoisonedValue(v));
value = v;
post(vcomp, obj, slot);
}
inline void
HeapSlot::writeBarrierPost(JSObject *obj, uint32_t slot)
{

View File

@ -476,6 +476,8 @@ class HeapSlot : public EncapsulatedValue
inline void set(JSObject *owner, uint32_t slot, const Value &v);
inline void set(JSCompartment *comp, JSObject *owner, uint32_t slot, const Value &v);
inline void setCrossCompartment(JSObject *owner, uint32_t slot, const Value &v,
JSCompartment *vcomp);
static inline void writeBarrierPost(JSObject *obj, uint32_t slot);
static inline void writeBarrierPost(JSCompartment *comp, JSObject *obj, uint32_t slot);

View File

@ -265,6 +265,17 @@ js::ObjectImpl::setSlot(uint32_t slot, const js::Value &value)
getSlotRef(slot).set(this->asObjectPtr(), slot, value);
}
inline void
js::ObjectImpl::setCrossCompartmentSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slotInRange(slot));
if (value.isMarkable())
getSlotRef(slot).setCrossCompartment(this->asObjectPtr(), slot, value,
ValueCompartment(value));
else
setSlot(slot, value);
}
inline void
js::ObjectImpl::initSlot(uint32_t slot, const js::Value &value)
{

View File

@ -1227,8 +1227,9 @@ class ObjectImpl : public gc::Cell
inline const Value &nativeGetSlot(uint32_t slot) const;
inline void setSlot(uint32_t slot, const Value &value);
inline void setCrossCompartmentSlot(uint32_t slot, const Value &value);
inline void initSlot(uint32_t slot, const Value &value);
inline void initCrossCompartmentSlot(uint32_t slot, const js::Value &value);
inline void initCrossCompartmentSlot(uint32_t slot, const Value &value);
inline void initSlotUnchecked(uint32_t slot, const Value &value);
/* For slots which are known to always be fixed, due to the way they are allocated. */