Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes

nanojit::Allocator Class Reference

Allocator is a bump-pointer allocator with an SPI for getting more memory from embedder-implemented allocator, such as malloc()/free(). More...

#include <Allocator.h>

Collaboration diagram for nanojit::Allocator:

List of all members.

Classes

class  Chunk

Public Member Functions

 Allocator ()
 ~Allocator ()
void reset ()
void * alloc (size_t nbytes)
 alloc memory, never return null.
void * fallibleAlloc (size_t nbytes)
 alloc memory, maybe return null.

Static Public Attributes

static const size_t MIN_CHUNK_SZB = 2000

Protected Member Functions

void * allocSlow (size_t nbytes, bool fallible=false)
bool fill (size_t minbytes, bool fallible)
void * allocChunk (size_t nbytes, bool fallible)
 allocate another block from a host provided allocator
void freeChunk (void *)
 free back to the same allocator
void postReset ()
 hook for post-reset action.

Protected Attributes

Chunkcurrent_chunk
char * current_top
char * current_limit

Detailed Description

Allocator is a bump-pointer allocator with an SPI for getting more memory from embedder-implemented allocator, such as malloc()/free().

alloc() never returns NULL. The implementation of allocChunk() is expected to perform a longjmp or exception when an allocation can't proceed. fallibleAlloc() (and fallibleAllocChunk()) may return NULL. They should be used for large allocations whose failure can be handled without too much difficulty.


Constructor & Destructor Documentation

nanojit::Allocator::Allocator (  ) 
nanojit::Allocator::~Allocator (  ) 

Member Function Documentation

void* nanojit::Allocator::alloc ( size_t  nbytes  )  [inline]

alloc memory, never return null.

void* nanojit::Allocator::allocChunk ( size_t  nbytes,
bool  fallible 
) [protected]

allocate another block from a host provided allocator

void* nanojit::Allocator::allocSlow ( size_t  nbytes,
bool  fallible = false 
) [protected]
void* nanojit::Allocator::fallibleAlloc ( size_t  nbytes  )  [inline]

alloc memory, maybe return null.

bool nanojit::Allocator::fill ( size_t  minbytes,
bool  fallible 
) [protected]
void nanojit::Allocator::freeChunk ( void *   )  [protected]

free back to the same allocator

void nanojit::Allocator::postReset (  )  [protected]

hook for post-reset action.

void nanojit::Allocator::reset (  ) 

Member Data Documentation

const size_t nanojit::Allocator::MIN_CHUNK_SZB = 2000 [static]

The documentation for this class was generated from the following file: