Bug 1033442 - Add allocation functions to Cell to make it more obvious which allocator to use; r=jonco
This commit is contained in:
@@ -499,16 +499,12 @@ NativeIterator *
|
||||
NativeIterator::allocateIterator(JSContext *cx, uint32_t slength, const AutoIdVector &props)
|
||||
{
|
||||
size_t plength = props.length();
|
||||
size_t nbytes = sizeof(NativeIterator) +
|
||||
plength * sizeof(JSString *) +
|
||||
slength * sizeof(Shape *);
|
||||
uint8_t *bytes = cx->zone()->pod_malloc<uint8_t>(nbytes);
|
||||
if (!bytes)
|
||||
NativeIterator *ni = cx->zone()->pod_malloc_with_extra<NativeIterator, void *>(plength + slength);
|
||||
if (!ni)
|
||||
return nullptr;
|
||||
|
||||
NativeIterator *ni = (NativeIterator *)bytes;
|
||||
AutoValueVector strings(cx);
|
||||
ni->props_array = ni->props_cursor = (HeapPtrFlatString *) (ni + 1);
|
||||
ni->props_array = ni->props_cursor = reinterpret_cast<HeapPtrFlatString *>(ni + 1);
|
||||
ni->props_end = ni->props_array + plength;
|
||||
if (plength) {
|
||||
for (size_t i = 0; i < plength; i++) {
|
||||
@@ -526,7 +522,7 @@ NativeIterator::allocateIterator(JSContext *cx, uint32_t slength, const AutoIdVe
|
||||
NativeIterator *
|
||||
NativeIterator::allocateSentinel(JSContext *cx)
|
||||
{
|
||||
NativeIterator *ni = (NativeIterator *)js_malloc(sizeof(NativeIterator));
|
||||
NativeIterator *ni = js_pod_malloc<NativeIterator>();
|
||||
if (!ni)
|
||||
return nullptr;
|
||||
|
||||
@@ -1778,22 +1774,15 @@ js_NewGenerator(JSContext *cx, const InterpreterRegs &stackRegs)
|
||||
Value *stackvp = stackfp->generatorArgsSnapshotBegin();
|
||||
unsigned vplen = stackfp->generatorArgsSnapshotEnd() - stackvp;
|
||||
|
||||
/* Compute JSGenerator size. */
|
||||
unsigned nbytes = sizeof(JSGenerator) +
|
||||
(-1 + /* one Value included in JSGenerator */
|
||||
vplen +
|
||||
VALUES_PER_STACK_FRAME +
|
||||
stackfp->script()->nslots()) * sizeof(HeapValue);
|
||||
|
||||
JS_ASSERT(nbytes % sizeof(Value) == 0);
|
||||
JS_STATIC_ASSERT(sizeof(InterpreterFrame) % sizeof(HeapValue) == 0);
|
||||
|
||||
JSGenerator *gen = (JSGenerator *) obj->zone()->pod_calloc<uint8_t>(nbytes);
|
||||
static_assert(sizeof(InterpreterFrame) % sizeof(HeapValue) == 0,
|
||||
"The Values stored after InterpreterFrame must be aligned.");
|
||||
unsigned nvals = vplen + VALUES_PER_STACK_FRAME + stackfp->script()->nslots();
|
||||
JSGenerator *gen = obj->pod_calloc_with_extra<JSGenerator, HeapValue>(nvals);
|
||||
if (!gen)
|
||||
return nullptr;
|
||||
|
||||
/* Cut up floatingStack space. */
|
||||
HeapValue *genvp = gen->stackSnapshot;
|
||||
HeapValue *genvp = gen->stackSnapshot();
|
||||
SetValueRangeToUndefined((Value *)genvp, vplen);
|
||||
|
||||
InterpreterFrame *genfp = reinterpret_cast<InterpreterFrame *>(genvp + vplen);
|
||||
|
||||
Reference in New Issue
Block a user