decompiler
1.0.0
|
A memory bank that implements reads and writes using a hash table. More...
#include <memstate.hh>
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... | |
AddrSpace * | getSpace (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 | |
MemoryBank * | underlie |
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... | |
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.
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.
spc | is the address space associated with the memory bank |
ws | is the number of bytes in the preferred wordsize (must be power of 2) |
ps | is the number of bytes in a page (must be a power of 2) |
hashsize | is the maximum number of entries in the hashtable |
ul | is the underlying memory bank being overlayed |
References alignshift, collideskip, and underlie.
|
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
addr | is the aligned address of the word to retrieve |
Implements MemoryBank.
References address, alignshift, collideskip, MemoryBank::find(), underlie, and value.
|
protectedvirtual |
Overridden aligned word insert.
Write the value into the hashtable, using addr as a key.
addr | is the aligned address of the word being written |
val | is the value of the word to write |
Implements MemoryBank.
References address, alignshift, collideskip, and value.