Public Types | Public Member Functions | Static Public Member Functions

nanojit::CodeAlloc Class Reference

Code memory allocator. More...

#include <CodeAlloc.h>

Collaboration diagram for nanojit::CodeAlloc:

List of all members.

Public Types

enum  CodePointerKind { kUnknown, kFree, kUsed }

Public Member Functions

 CodeAlloc ()
 ~CodeAlloc ()
void reset ()
 return all the memory allocated through this allocator to the gcheap.
void alloc (NIns *&start, NIns *&end)
 allocate some memory for code, return pointers to the region.
void free (NIns *start, NIns *end)
 free a block of memory previously returned by alloc()
void freeAll (CodeList *&code)
 free several blocks
void addRemainder (CodeList *&code, NIns *start, NIns *end, NIns *holeStart, NIns *holeEnd)
 add the ranges [start, holeStart) and [holeEnd, end) to code, and free [holeStart, holeEnd) if the hole is >= minsize
size_t size ()
 return the total number of bytes held by this CodeAlloc.
void logStats ()
 print out stats about heap usage
CodePointerKind classifyPtr (NIns *p)
 determine whether the given address is not code, or is allocated or free
void sweep ()
 return any completely empty pages

Static Public Member Functions

static void flushICache (CodeList *&blocks)
 flush the icache for all code in the list, before executing
static void flushICache (void *start, size_t len)
 flush the icache for a specific extent
static void add (CodeList *&code, NIns *start, NIns *end)
 add a block previously returned by alloc(), to code
static void moveAll (CodeList *&to, CodeList *&from)
 move all the code in list "from" to list "to", and leave from empty.
static bool contains (const CodeList *code, NIns *p)
 return true if any block in list "code" contains the code pointer p
static size_t size (const CodeList *code)
 return the number of bytes in all the code blocks in "code", including block overhead

Detailed Description

Code memory allocator.

Long lived manager for many code blocks, manages interaction with an underlying code memory allocator, setting page permissions, api's for allocating and freeing individual blocks of code memory (for methods, stubs, or compiled traces), and also static functions for managing lists of allocated code.


Member Enumeration Documentation

Enumerator:
kUnknown 
kFree 
kUsed 

Constructor & Destructor Documentation

nanojit::CodeAlloc::CodeAlloc (  ) 
nanojit::CodeAlloc::~CodeAlloc (  ) 

Member Function Documentation

static void nanojit::CodeAlloc::add ( CodeList *&  code,
NIns start,
NIns end 
) [static]

add a block previously returned by alloc(), to code

void nanojit::CodeAlloc::addRemainder ( CodeList *&  code,
NIns start,
NIns end,
NIns holeStart,
NIns holeEnd 
)

add the ranges [start, holeStart) and [holeEnd, end) to code, and free [holeStart, holeEnd) if the hole is >= minsize

void nanojit::CodeAlloc::alloc ( NIns *&  start,
NIns *&  end 
)

allocate some memory for code, return pointers to the region.

CodePointerKind nanojit::CodeAlloc::classifyPtr ( NIns p  ) 

determine whether the given address is not code, or is allocated or free

static bool nanojit::CodeAlloc::contains ( const CodeList code,
NIns p 
) [static]

return true if any block in list "code" contains the code pointer p

static void nanojit::CodeAlloc::flushICache ( CodeList *&  blocks  )  [static]

flush the icache for all code in the list, before executing

static void nanojit::CodeAlloc::flushICache ( void *  start,
size_t  len 
) [static]

flush the icache for a specific extent

void nanojit::CodeAlloc::free ( NIns start,
NIns end 
)

free a block of memory previously returned by alloc()

void nanojit::CodeAlloc::freeAll ( CodeList *&  code  ) 

free several blocks

void nanojit::CodeAlloc::logStats (  ) 

print out stats about heap usage

static void nanojit::CodeAlloc::moveAll ( CodeList *&  to,
CodeList *&  from 
) [static]

move all the code in list "from" to list "to", and leave from empty.

void nanojit::CodeAlloc::reset (  ) 

return all the memory allocated through this allocator to the gcheap.

static size_t nanojit::CodeAlloc::size ( const CodeList code  )  [static]

return the number of bytes in all the code blocks in "code", including block overhead

size_t nanojit::CodeAlloc::size (  ) 

return the total number of bytes held by this CodeAlloc.

void nanojit::CodeAlloc::sweep (  ) 

return any completely empty pages


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