/* static */ size_t ArgumentsObject::objectMovedDuringMinorGC(JSTracer* trc, JSObject* dst, JSObject* src) { ArgumentsObject* ndst = &dst->as<ArgumentsObject>(); ArgumentsObject* nsrc = &src->as<ArgumentsObject>(); MOZ_ASSERT(ndst->data() == nsrc->data()); Nursery& nursery = trc->runtime()->gc.nursery; if (!nursery.isInside(nsrc->data())) { nursery.removeMallocedBuffer(nsrc->data()); return 0; } AutoEnterOOMUnsafeRegion oomUnsafe; uint32_t nbytes = nsrc->data()->dataBytes; uint8_t* data = nsrc->zone()->pod_malloc<uint8_t>(nbytes); if (!data) oomUnsafe.crash("Failed to allocate ArgumentsObject data while tenuring."); ndst->initFixedSlot(DATA_SLOT, PrivateValue(data)); mozilla::PodCopy(data, reinterpret_cast<uint8_t*>(nsrc->data()), nbytes); ArgumentsData* dstData = ndst->data(); dstData->deletedBits = reinterpret_cast<size_t*>(dstData->args + dstData->numArgs); return nbytes; }
/* static */ size_t ArgumentsObject::objectMoved(JSObject* dst, JSObject* src) { ArgumentsObject* ndst = &dst->as<ArgumentsObject>(); const ArgumentsObject* nsrc = &src->as<ArgumentsObject>(); MOZ_ASSERT(ndst->data() == nsrc->data()); if (!IsInsideNursery(src)) return 0; Nursery& nursery = dst->zone()->group()->nursery(); size_t nbytesTotal = 0; if (!nursery.isInside(nsrc->data())) { nursery.removeMallocedBuffer(nsrc->data()); } else { AutoEnterOOMUnsafeRegion oomUnsafe; uint32_t nbytes = ArgumentsData::bytesRequired(nsrc->data()->numArgs); uint8_t* data = nsrc->zone()->pod_malloc<uint8_t>(nbytes); if (!data) oomUnsafe.crash("Failed to allocate ArgumentsObject data while tenuring."); ndst->initFixedSlot(DATA_SLOT, PrivateValue(data)); mozilla::PodCopy(data, reinterpret_cast<uint8_t*>(nsrc->data()), nbytes); nbytesTotal += nbytes; } if (RareArgumentsData* srcRareData = nsrc->maybeRareData()) { if (!nursery.isInside(srcRareData)) { nursery.removeMallocedBuffer(srcRareData); } else { AutoEnterOOMUnsafeRegion oomUnsafe; uint32_t nbytes = RareArgumentsData::bytesRequired(nsrc->initialLength()); uint8_t* dstRareData = nsrc->zone()->pod_malloc<uint8_t>(nbytes); if (!dstRareData) oomUnsafe.crash("Failed to allocate RareArgumentsData data while tenuring."); ndst->data()->rareData = (RareArgumentsData*)dstRareData; mozilla::PodCopy(dstRareData, reinterpret_cast<uint8_t*>(srcRareData), nbytes); nbytesTotal += nbytes; } } return nbytesTotal; }
PutArg(JSCompartment *comp, ArgumentsObject &argsobj) : compartment(comp), argsobj(argsobj), dst(argsobj.data()->slots) {}