зеркало из https://github.com/mozilla/pjs.git
Bug 417999 - removed JS_ArenaFreeAllocation, r+/a+=brendan
This commit is contained in:
Родитель
2efcff54e6
Коммит
f972713d57
|
@ -338,72 +338,6 @@ JS_ArenaRelease(JSArenaPool *pool, char *mark)
|
|||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ArenaFreeAllocation(JSArenaPool *pool, void *p, size_t size)
|
||||
{
|
||||
JSArena **ap, *a, *b;
|
||||
jsuword q;
|
||||
|
||||
/*
|
||||
* If the allocation is oversized, it consumes an entire arena, and it has
|
||||
* a header just before the allocation pointing back to its predecessor's
|
||||
* next member. Otherwise, we have to search pool for a.
|
||||
*/
|
||||
if (size > pool->arenasize) {
|
||||
ap = *PTR_TO_HEADER(pool, p);
|
||||
a = *ap;
|
||||
} else {
|
||||
q = (jsuword)p + size;
|
||||
q = JS_ARENA_ALIGN(pool, q);
|
||||
ap = &pool->first.next;
|
||||
while ((a = *ap) != NULL) {
|
||||
JS_ASSERT(a->base <= a->avail && a->avail <= a->limit);
|
||||
|
||||
if (a->avail == q) {
|
||||
/*
|
||||
* If a is consumed by the allocation at p, we can free it to
|
||||
* the malloc heap.
|
||||
*/
|
||||
if (a->base == (jsuword)p)
|
||||
break;
|
||||
|
||||
/*
|
||||
* We can't free a, but we can "retract" its avail cursor --
|
||||
* whether there are others after it in pool.
|
||||
*/
|
||||
a->avail = (jsuword)p;
|
||||
return;
|
||||
}
|
||||
ap = &a->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, a is doomed, so ensure that pool->current doesn't point
|
||||
* at it. We must preserve LIFO order of mark/release cursors, so we use
|
||||
* the oversized-allocation arena's back pointer (or if not oversized, we
|
||||
* use the result of searching the entire pool) to compute the address of
|
||||
* the arena that precedes a.
|
||||
*/
|
||||
if (pool->current == a)
|
||||
pool->current = (JSArena *) ((char *)ap - offsetof(JSArena, next));
|
||||
|
||||
/*
|
||||
* This is a non-LIFO deallocation, so take care to fix up a->next's back
|
||||
* pointer in its header, if a->next is oversized.
|
||||
*/
|
||||
*ap = b = a->next;
|
||||
if (b && b->avail - b->base > pool->arenasize) {
|
||||
JS_ASSERT(GET_HEADER(pool, b) == &a->next);
|
||||
SET_HEADER(pool, b, ap);
|
||||
}
|
||||
if (pool->quotap)
|
||||
*pool->quotap += a->limit - (jsuword) a;
|
||||
JS_CLEAR_ARENA(a);
|
||||
JS_COUNT_ARENA(pool,--);
|
||||
free(a);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_FreeArenaPool(JSArenaPool *pool)
|
||||
{
|
||||
|
|
|
@ -281,13 +281,6 @@ JS_ArenaGrow(JSArenaPool *pool, void *p, size_t size, size_t incr);
|
|||
extern JS_PUBLIC_API(void)
|
||||
JS_ArenaRelease(JSArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
* Function to be used directly when an allocation has likely grown to consume
|
||||
* an entire JSArena, in which case the arena is returned to the malloc heap.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ArenaFreeAllocation(JSArenaPool *pool, void *p, size_t size);
|
||||
|
||||
#ifdef JS_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
Загрузка…
Ссылка в новой задаче