/* static */ bool ObjectElements::MakeElementsCopyOnWrite(ExclusiveContext *cx, JSObject *obj) { // Make sure there is enough room for the owner object pointer at the end // of the elements. JS_STATIC_ASSERT(sizeof(HeapSlot) >= sizeof(HeapPtrObject)); if (!obj->ensureElements(cx, obj->getDenseInitializedLength() + 1)) return false; ObjectElements *header = obj->getElementsHeader(); // Note: this method doesn't update type information to indicate that the // elements might be copy on write. Handling this is left to the caller. JS_ASSERT(!header->isCopyOnWrite()); header->flags |= COPY_ON_WRITE; header->ownerObject().init(obj); return true; }