decompiler  1.0.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
MemoryHashOverlay Class Reference

A memory bank that implements reads and writes using a hash table. More...

#include <memstate.hh>

Inheritance diagram for MemoryHashOverlay:
MemoryBank

Public Member Functions

 MemoryHashOverlay (AddrSpace *spc, int4 ws, int4 ps, int4 hashsize, MemoryBank *ul)
 Constructor for hash overlay. More...
 
- Public Member Functions inherited from MemoryBank
 MemoryBank (AddrSpace *spc, int4 ws, int4 ps)
 Generic constructor for a memory bank. More...
 
int4 getWordSize (void) const
 Get the number of bytes in a word for this memory bank. More...
 
int4 getPageSize (void) const
 Get the number of bytes in a page for this memory bank. More...
 
AddrSpacegetSpace (void) const
 Get the address space associated with this memory bank. More...
 
void setValue (uintb offset, int4 size, uintb val)
 Set the value of a (small) range of bytes. More...
 
uintb getValue (uintb offset, int4 size) const
 Retrieve the value encoded in a (small) range of bytes. More...
 
void setChunk (uintb offset, int4 size, const uint1 *val)
 Set values of an arbitrary sequence of bytes. More...
 
void getChunk (uintb offset, int4 size, uint1 *res) const
 Retrieve an arbitrary sequence of bytes. More...
 

Protected Member Functions

virtual void insert (uintb addr, uintb val)
 Overridden aligned word insert. More...
 
virtual uintb find (uintb addr) const
 Overridden aligned word find. More...
 
- Protected Member Functions inherited from MemoryBank
virtual void getPage (uintb addr, uint1 *res, int4 skip, int4 size) const
 Retrieve data from a memory page. More...
 
virtual void setPage (uintb addr, const uint1 *val, int4 skip, int4 size)
 Write data into a memory page. More...
 

Private Attributes

MemoryBankunderlie
 Underlying memory bank.
 
int4 alignshift
 How many LSBs are thrown away from address when doing hash table lookup.
 
uintb collideskip
 How many slots to skip after a hashtable collision.
 
vector< uintb > address
 The hashtable addresses.
 
vector< uintb > value
 The hashtable values.
 

Additional Inherited Members

- Static Public Member Functions inherited from MemoryBank
static uintb constructValue (const uint1 *ptr, int4 size, bool bigendian)
 Decode bytes to value. More...
 
static void deconstructValue (uint1 *ptr, uintb val, int4 size, bool bigendian)
 Encode value to bytes. More...
 

Detailed Description

A memory bank that implements reads and writes using a hash table.

The initial state of the bank is taken from an underlying memory bank or is all zero, if this bank is initialized with a null pointer. This implementation will not be very efficient for accessing entire pages.

Constructor & Destructor Documentation

MemoryHashOverlay::MemoryHashOverlay ( AddrSpace spc,
int4  ws,
int4  ps,
int4  hashsize,
MemoryBank ul 
)

Constructor for hash overlay.

A MemoryBank implemented as a hash table needs everything associated with a generic memory bank, but the constructor also needs to know the size of the hashtable and the underlying memorybank to forward reads and writes to.

Parameters
spcis the address space associated with the memory bank
wsis the number of bytes in the preferred wordsize (must be power of 2)
psis the number of bytes in a page (must be a power of 2)
hashsizeis the maximum number of entries in the hashtable
ulis the underlying memory bank being overlayed

References alignshift, collideskip, and underlie.

Member Function Documentation

uintb MemoryHashOverlay::find ( uintb  addr) const
protectedvirtual

Overridden aligned word find.

First search for an entry in the hashtable using addr as a key. If there is no entry, forward the query to the underlying memory bank, or return 0 if there is no underlying bank

Parameters
addris the aligned address of the word to retrieve
Returns
the retrieved value

Implements MemoryBank.

References MemoryBank::find(), and MemoryPageOverlay::underlie.

void MemoryHashOverlay::insert ( uintb  addr,
uintb  val 
)
protectedvirtual

Overridden aligned word insert.

Write the value into the hashtable, using addr as a key.

Parameters
addris the aligned address of the word being written
valis the value of the word to write

Implements MemoryBank.


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