Bug 1033442 - Add allocation functions to Cell to make it more obvious which allocator to use; r=jonco

This commit is contained in:
Terrence Cole
2014-08-08 17:00:46 -07:00
parent 3aee64737f
commit b2e7fa6fbc
15 changed files with 109 additions and 65 deletions

View File

@@ -2487,13 +2487,13 @@ JSObject::ReserveForTradeGuts(JSContext *cx, JSObject *aArg, JSObject *bArg,
unsigned bdynamic = dynamicSlotsCount(reserved.newbfixed, a->slotSpan(), a->getClass());
if (adynamic) {
reserved.newaslots = a->zone()->pod_malloc<HeapSlot>(adynamic);
reserved.newaslots = a->pod_malloc<HeapSlot>(adynamic);
if (!reserved.newaslots)
return false;
Debug_SetSlotRangeToCrashOnTouch(reserved.newaslots, adynamic);
}
if (bdynamic) {
reserved.newbslots = b->zone()->pod_malloc<HeapSlot>(bdynamic);
reserved.newbslots = b->pod_malloc<HeapSlot>(bdynamic);
if (!reserved.newbslots)
return false;
Debug_SetSlotRangeToCrashOnTouch(reserved.newbslots, bdynamic);
@@ -2972,7 +2972,7 @@ AllocateSlots(ThreadSafeContext *cx, JSObject *obj, uint32_t nslots)
if (cx->isForkJoinContext())
return cx->asForkJoinContext()->nursery().allocateSlots(obj, nslots);
#endif
return obj->zone()->pod_malloc<HeapSlot>(nslots);
return obj->pod_malloc<HeapSlot>(nslots);
}
// This will not run the garbage collector. If a nursery cannot accomodate the slot array
@@ -2995,7 +2995,7 @@ ReallocateSlots(ThreadSafeContext *cx, JSObject *obj, HeapSlot *oldSlots,
oldCount, newCount);
}
#endif
return obj->zone()->pod_realloc<HeapSlot>(oldSlots, oldCount, newCount);
return obj->pod_realloc<HeapSlot>(oldSlots, oldCount, newCount);
}
/* static */ bool
@@ -3310,7 +3310,7 @@ AllocateElements(ThreadSafeContext *cx, JSObject *obj, uint32_t nelems)
return cx->asForkJoinContext()->nursery().allocateElements(obj, nelems);
#endif
return reinterpret_cast<js::ObjectElements *>(obj->zone()->pod_malloc<HeapSlot>(nelems));
return reinterpret_cast<js::ObjectElements *>(obj->pod_malloc<HeapSlot>(nelems));
}
// This will not run the garbage collector. If a nursery cannot accomodate the element array
@@ -3333,8 +3333,8 @@ ReallocateElements(ThreadSafeContext *cx, JSObject *obj, ObjectElements *oldHead
#endif
return reinterpret_cast<js::ObjectElements *>(
obj->zone()->pod_realloc<HeapSlot>(reinterpret_cast<HeapSlot *>(oldHeader),
oldCount, newCount));
obj->pod_realloc<HeapSlot>(reinterpret_cast<HeapSlot *>(oldHeader),
oldCount, newCount));
}
// Round up |reqAllocated| to a good size. Up to 1 Mebi (i.e. 1,048,576) the