Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
jsarena.h File Reference
#include <stdlib.h>
#include "jstypes.h"
#include "jscompat.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JSArena
struct  JSArenaPool

Defines

#define JS_ARENA_ALIGN(pool, n)   (((jsuword)(n) + (pool)->mask) & ~(pool)->mask)
#define JS_ARENA_ALLOCATE(p, pool, nb)   JS_ARENA_ALLOCATE_CAST(p, void *, pool, nb)
#define JS_ARENA_ALLOCATE_TYPE(p, type, pool)   JS_ARENA_ALLOCATE_COMMON(p, type *, pool, sizeof(type), 0)
#define JS_ARENA_ALLOCATE_CAST(p, type, pool, nb)   JS_ARENA_ALLOCATE_COMMON(p, type, pool, nb, _nb > _a->limit)
#define JS_ARENA_ALLOCATE_COMMON(p, type, pool, nb, guard)
#define JS_ARENA_GROW(p, pool, size, incr)   JS_ARENA_GROW_CAST(p, void *, pool, size, incr)
#define JS_ARENA_GROW_CAST(p, type, pool, size, incr)
#define JS_ARENA_MARK(pool)   ((void *) (pool)->current->avail)
#define JS_UPTRDIFF(p, q)   ((jsuword)(p) - (jsuword)(q))
#define JS_CLEAR_UNUSED(a)   /* nothing */
#define JS_CLEAR_ARENA(a)   /* nothing */
#define JS_ARENA_RELEASE(pool, mark)
#define JS_COUNT_ARENA(pool, op)
#define JS_ARENA_DESTROY(pool, a, pnext)
#define JS_ArenaCountAllocation(ap, nb)   /* nothing */
#define JS_ArenaCountInplaceGrowth(ap, size, incr)   /* nothing */
#define JS_ArenaCountGrowth(ap, size, incr)   /* nothing */
#define JS_ArenaCountRelease(ap, mark)   /* nothing */
#define JS_ArenaCountRetract(ap, mark)   /* nothing */

Typedefs

typedef
typedefJS_BEGIN_EXTERN_C
struct 
JSArena
typedef struct JSArenaPool

Functions

 JS_PUBLIC_API (void) JS_InitArenaPool(JSArenaPool *pool
 JS_PUBLIC_API (void *) JS_ArenaAllocate(JSArenaPool *pool

Variables

const char * name
const char size_t size
const char size_t size_t align
size_t nb
voidp
void size_t size_t incr
char * mark

Class Documentation

struct JSArena

Definition at line 58 of file jsarena.h.

Collaboration diagram for JSArena:
Class Members
jsuword avail
jsuword base
jsuword limit
JSArena * next
struct JSArenaPool

Definition at line 86 of file jsarena.h.

Collaboration diagram for JSArenaPool:
Class Members
size_t arenasize
JSArena * current
JSArena first
jsuword mask

Define Documentation

#define JS_ARENA_ALIGN (   pool,
  n 
)    (((jsuword)(n) + (pool)->mask) & ~(pool)->mask)

Definition at line 108 of file jsarena.h.

Definition at line 111 of file jsarena.h.

#define JS_ARENA_ALLOCATE_CAST (   p,
  type,
  pool,
  nb 
)    JS_ARENA_ALLOCATE_COMMON(p, type, pool, nb, _nb > _a->limit)

Definition at line 117 of file jsarena.h.

#define JS_ARENA_ALLOCATE_COMMON (   p,
  type,
  pool,
  nb,
  guard 
)
Value:
JS_BEGIN_MACRO                                                            \
        JSArena *_a = (pool)->current;                                        \
        size_t _nb = JS_ARENA_ALIGN(pool, nb);                                \
        jsuword _p = _a->avail;                                               \
        if ((guard) || _p > _a->limit - _nb)                                  \
            _p = (jsuword)JS_ArenaAllocate(pool, _nb);                        \
        else                                                                  \
            _a->avail = _p + _nb;                                             \
        p = (type) _p;                                                        \
        JS_ArenaCountAllocation(pool, nb);                                    \
    JS_END_MACRO

Definition at line 130 of file jsarena.h.

#define JS_ARENA_ALLOCATE_TYPE (   p,
  type,
  pool 
)    JS_ARENA_ALLOCATE_COMMON(p, type *, pool, sizeof(type), 0)

Definition at line 114 of file jsarena.h.

#define JS_ARENA_DESTROY (   pool,
  a,
  pnext 
)
Value:
JS_BEGIN_MACRO                                                            \
        JS_COUNT_ARENA(pool,--);                                              \
        if ((pool)->current == (a)) (pool)->current = &(pool)->first;         \
        *(pnext) = (a)->next;                                                 \
        JS_CLEAR_ARENA(a);                                                    \
        free(a);                                                              \
        (a) = NULL;                                                           \
    JS_END_MACRO

Definition at line 203 of file jsarena.h.

#define JS_ARENA_GROW (   p,
  pool,
  size,
  incr 
)    JS_ARENA_GROW_CAST(p, void *, pool, size, incr)

Definition at line 143 of file jsarena.h.

#define JS_ARENA_GROW_CAST (   p,
  type,
  pool,
  size,
  incr 
)
Value:
JS_BEGIN_MACRO                                                            \
        JSArena *_a = (pool)->current;                                        \
        if (_a->avail == (jsuword)(p) + JS_ARENA_ALIGN(pool, size)) {         \
            size_t _nb = (size) + (incr);                                     \
            _nb = JS_ARENA_ALIGN(pool, _nb);                                  \
            if (_a->limit >= _nb && (jsuword)(p) <= _a->limit - _nb) {        \
                _a->avail = (jsuword)(p) + _nb;                               \
                JS_ArenaCountInplaceGrowth(pool, size, incr);                 \
            } else if ((jsuword)(p) == _a->base) {                            \
                p = (type) JS_ArenaRealloc(pool, p, size, incr);              \
            } else {                                                          \
                p = (type) JS_ArenaGrow(pool, p, size, incr);                 \
            }                                                                 \
        } else {                                                              \
            p = (type) JS_ArenaGrow(pool, p, size, incr);                     \
        }                                                                     \
        JS_ArenaCountGrowth(pool, size, incr);                                \
    JS_END_MACRO

Definition at line 146 of file jsarena.h.

#define JS_ARENA_MARK (   pool)    ((void *) (pool)->current->avail)

Definition at line 166 of file jsarena.h.

Value:
JS_BEGIN_MACRO                                                            \
        char *_m = (char *)(mark);                                            \
        JSArena *_a = (pool)->current;                                        \
        if (_a != &(pool)->first &&                                           \
            JS_UPTRDIFF(_m, _a->base) <= JS_UPTRDIFF(_a->avail, _a->base)) {  \
            _a->avail = (jsuword)JS_ARENA_ALIGN(pool, _m);                    \
            JS_ASSERT(_a->avail <= _a->limit);                                \
            JS_CLEAR_UNUSED(_a);                                              \
            JS_ArenaCountRetract(pool, _m);                                   \
        } else {                                                              \
            JS_ArenaRelease(pool, _m);                                        \
        }                                                                     \
        JS_ArenaCountRelease(pool, _m);                                       \
    JS_END_MACRO

Definition at line 181 of file jsarena.h.

#define JS_ArenaCountAllocation (   ap,
  nb 
)    /* nothing */

Definition at line 293 of file jsarena.h.

#define JS_ArenaCountGrowth (   ap,
  size,
  incr 
)    /* nothing */

Definition at line 295 of file jsarena.h.

#define JS_ArenaCountInplaceGrowth (   ap,
  size,
  incr 
)    /* nothing */

Definition at line 294 of file jsarena.h.

#define JS_ArenaCountRelease (   ap,
  mark 
)    /* nothing */

Definition at line 296 of file jsarena.h.

#define JS_ArenaCountRetract (   ap,
  mark 
)    /* nothing */

Definition at line 297 of file jsarena.h.

#define JS_CLEAR_ARENA (   a)    /* nothing */

Definition at line 178 of file jsarena.h.

#define JS_CLEAR_UNUSED (   a)    /* nothing */

Definition at line 177 of file jsarena.h.

#define JS_COUNT_ARENA (   pool,
  op 
)

Definition at line 200 of file jsarena.h.

#define JS_UPTRDIFF (   p,
 
)    ((jsuword)(p) - (jsuword)(q))

Definition at line 167 of file jsarena.h.


Typedef Documentation

typedef typedefJS_BEGIN_EXTERN_C struct JSArena

Definition at line 55 of file jsarena.h.

typedef struct JSArenaPool

Definition at line 56 of file jsarena.h.


Function Documentation


Variable Documentation

const char size_t size_t align

Definition at line 218 of file jsarena.h.

void size_t size_t incr

Definition at line 254 of file jsarena.h.

char* mark

Definition at line 260 of file jsarena.h.

const char* name

Definition at line 218 of file jsarena.h.

size_t nb

Definition at line 251 of file jsarena.h.

void* p

Definition at line 254 of file jsarena.h.

void size_t size

Definition at line 218 of file jsarena.h.