static RawObject CloneDenseArray(JSContext *cx, HandleObject obj, CloneMemory &clonedObjects) { uint32_t len = obj->getArrayLength(); RootedObject clone(cx, NewDenseAllocatedArray(cx, len)); clone->setDenseArrayInitializedLength(len); for (uint32_t i = 0; i < len; i++) JSObject::initDenseArrayElementWithType(cx, clone, i, UndefinedValue()); RootedValue elt(cx); for (uint32_t i = 0; i < len; i++) { bool present; if (!obj->getElementIfPresent(cx, obj, obj, i, &elt, &present)) return NULL; if (present) { if (!CloneValue(cx, &elt, clonedObjects)) return NULL; JSObject::setDenseArrayElementWithType(cx, clone, i, elt); } } return clone; }