Modifier and Type | Field and Description |
---|---|
private static int |
BYTES_IN_COPY
Number of bytes used when copying larger chunks of memory.
|
static int |
MAP_ANONYMOUS |
static int |
MAP_FIXED |
static int |
MAP_PRIVATE |
private static int |
NATIVE_THRESHOLD
How many bytes is considered large enough to justify the transition to
C code to use memcpy?
|
private static int |
pagesize |
private static int |
pagesizeLog |
static int |
PROT_EXEC |
static int |
PROT_NONE |
static int |
PROT_READ |
static int |
PROT_WRITE |
private static int |
UNKNOWN |
private static boolean |
USE_NATIVE
Allow the use of C based memcpy
|
Constructor and Description |
---|
Memory() |
Modifier and Type | Method and Description |
---|---|
static Address |
alignDown(Address address,
int alignment) |
static int |
alignDown(int address,
int alignment) |
static void |
aligned16Copy(Address dstPtr,
Address srcPtr,
int copyBytes)
Low level copy of
copyBytes bytes from src[srcPos] to dst[dstPos] . |
static void |
aligned32Copy(Address dst,
Address src,
int copyBytes)
Copy copyBytes from src to dst.
|
static void |
aligned64Copy(Address dstPtr,
Address srcPtr,
int copyBytes)
Low level copy of
copyBytes bytes from src[srcPos] to dst[dstPos] . |
static void |
aligned8Copy(Address dstPtr,
Address srcPtr,
int copyBytes)
Low level copy of
copyBytes bytes from src[srcPos] to dst[dstPos] . |
static void |
alignedWordCopy(Address dst,
Address src,
int numBytes)
Copy numbytes from src to dst.
|
static Address |
alignUp(Address address,
int alignment) |
static int |
alignUp(int address,
int alignment) |
static void |
arraycopy16Bit(Object src,
int srcPos,
Object dst,
int dstPos,
int len)
Low level copy of len elements from src[srcPos] to dst[dstPos].
|
static void |
arraycopy32Bit(Object src,
int srcIdx,
Object dst,
int dstIdx,
int len)
Low level copy of
len elements from src[srcPos] to dst[dstPos] . |
static void |
arraycopy64Bit(Object src,
int srcIdx,
Object dst,
int dstIdx,
int len)
Low level copy of
len elements from src[srcPos] to dst[dstPos] . |
static void |
arraycopy8Bit(Object src,
int srcPos,
Object dst,
int dstPos,
int len)
Low level copy of len elements from src[srcPos] to dst[dstPos].
|
private static void |
copy1Bytes(Address dstPtr,
Address srcPtr) |
private static void |
copy2Bytes(Address dstPtr,
Address srcPtr) |
private static void |
copy4Bytes(Address dstPtr,
Address srcPtr) |
private static void |
copy8Bytes(Address dstPtr,
Address srcPtr) |
static void |
dumpMemory(Address start,
int beforeBytes,
int afterBytes) |
static Address |
dzmmap(Address address,
Extent size)
Do mmap demand zero fixed address memory mapping call
|
(package private) static int |
getNativeThreshold()
For use in test cases only.
|
static int |
getPagesize() |
static int |
getPagesizeLog() |
static byte |
getPagesizeLogAsByte() |
private static void |
internalAlignedWordCopy(Address dst,
Address src,
int numBytes)
Copy
numbytes from src to dst . |
static boolean |
isPageAligned(Address addr) |
static boolean |
isPageMultiple(Extent val) |
static boolean |
isPageMultiple(int val) |
static boolean |
isPageMultiple(Offset val) |
static void |
memcopy(Address dst,
Address src,
Extent cnt)
Copies a region of memory.
|
static void |
memcopy(Address dst,
Address src,
int cnt)
Wrapper method for
memcopy(Address, Address, Extent) . |
static Address |
mmap(Address address,
Extent size,
int prot,
int flags)
Do generic mmap non-file memory mapping call
|
static boolean |
mprotect(Address address,
Extent size,
int prot)
Do mprotect system call
|
static void |
setPageSize(Extent pageSizeFromBootRecord)
Sets the page size.
|
static void |
sync(Address address,
int size)
Synchronize a region of memory: force data in dcache to be written out to main
memory so that it will be seen by icache when instructions are fetched back.
|
static void |
zero(boolean useNT,
Address start,
Extent len)
Zero a region of memory.
|
private static final int UNKNOWN
private static final int NATIVE_THRESHOLD
private static final boolean USE_NATIVE
private static final int BYTES_IN_COPY
public static final int PROT_NONE
public static final int PROT_READ
public static final int PROT_WRITE
public static final int PROT_EXEC
public static final int MAP_PRIVATE
public static final int MAP_FIXED
public static final int MAP_ANONYMOUS
private static int pagesize
private static int pagesizeLog
public Memory()
private static void copy8Bytes(Address dstPtr, Address srcPtr)
private static void copy4Bytes(Address dstPtr, Address srcPtr)
private static void copy2Bytes(Address dstPtr, Address srcPtr)
private static void copy1Bytes(Address dstPtr, Address srcPtr)
public static void arraycopy8Bit(Object src, int srcPos, Object dst, int dstPos, int len)
src != dst || (scrPos >= dstPos + 4)
and src and dst are 8Bit arrays.src
- the source arraysrcPos
- index in the source array to begin copydst
- the destination arraydstPos
- index in the destination array to being copylen
- number of array elements to copypublic static void aligned8Copy(Address dstPtr, Address srcPtr, int copyBytes)
copyBytes
bytes from src[srcPos]
to dst[dstPos]
.
Assumption src != dst || (srcPos >= dstPos)
and element size is 4 bytes.dstPtr
- The destination start addresssrcPtr
- The source start addresscopyBytes
- The number of bytes to be copiedpublic static void arraycopy16Bit(Object src, int srcPos, Object dst, int dstPos, int len)
Assumption; src != dst || (srcPos >= dstPos + 2)
.
src
- the source arraysrcPos
- index in the source array to begin copydst
- the destination arraydstPos
- index in the destination array to being copylen
- number of array elements to copypublic static void aligned16Copy(Address dstPtr, Address srcPtr, int copyBytes)
copyBytes
bytes from src[srcPos]
to dst[dstPos]
.
Assumption: src != dst || (srcPos >= dstPos)
and element size is 2 bytes.
dstPtr
- The destination start addresssrcPtr
- The source start addresscopyBytes
- The number of bytes to be copiedpublic static void arraycopy32Bit(Object src, int srcIdx, Object dst, int dstIdx, int len)
len
elements from src[srcPos]
to dst[dstPos]
.
Assumption: src != dst || (srcPos >= dstPos)
and element size is 4 bytes.
src
- the source arraysrcIdx
- index in the source array to begin copydst
- the destination arraydstIdx
- index in the destination array to being copylen
- number of array elements to copypublic static void arraycopy64Bit(Object src, int srcIdx, Object dst, int dstIdx, int len)
len
elements from src[srcPos]
to dst[dstPos]
.
Assumption: src != dst || (srcPos >= dstPos)
and element size is 8 bytes.
src
- the source arraysrcIdx
- index in the source array to begin copydst
- the destination arraydstIdx
- index in the destination array to being copylen
- number of array elements to copypublic static void aligned64Copy(Address dstPtr, Address srcPtr, int copyBytes)
copyBytes
bytes from src[srcPos]
to dst[dstPos]
.
Assumption src != dst || (srcPos >= dstPos)
and element size is 8 bytes.dstPtr
- The destination start addresssrcPtr
- The source start addresscopyBytes
- The number of bytes to be copiedpublic static void aligned32Copy(Address dst, Address src, int copyBytes)
src >= dst + 4
.
Also, src and dst are 4 byte aligned and numBytes is a multiple of 4.dst
- the destination addrsrc
- the source addrcopyBytes
- the number of bytes top copypublic static void alignedWordCopy(Address dst, Address src, int numBytes)
src >= dst + BYTES_IN_ADDRESS
.
Also, src and dst are word aligned and numBytes is a multiple of BYTES_IN_ADDRESS.dst
- the destination addrsrc
- the source addrnumBytes
- the number of bytes top copyprivate static void internalAlignedWordCopy(Address dst, Address src, int numBytes)
numbytes
from src
to dst
.
Assumption either the ranges are non overlapping, or src >= dst + BYTES_IN_ADDRESS
.dst
- The destination addrsrc
- The source addrnumBytes
- The number of bytes to copypublic static void memcopy(Address dst, Address src, Extent cnt)
dst
- Destination addresssrc
- Source addresscnt
- Number of bytes to copypublic static void memcopy(Address dst, Address src, int cnt)
memcopy(Address, Address, Extent)
.dst
- Destination addresssrc
- Source addresscnt
- Number of bytes to copypublic static void zero(boolean useNT, Address start, Extent len)
useNT
- use non-temporal instructions (if available)start
- of address range (inclusive)len
- extent to zero.public static void sync(Address address, int size)
address
- Start of address rangesize
- Size of address range (bytes)public static boolean isPageMultiple(int val)
public static boolean isPageMultiple(Extent val)
public static boolean isPageMultiple(Offset val)
public static boolean isPageAligned(Address addr)
public static Address mmap(Address address, Extent size, int prot, int flags)
address
- Start of address range (Address)size
- Size of address rangeprot
- Protection (int)flags
- (int)public static Address dzmmap(Address address, Extent size)
address
- Start of address rangesize
- Size of address rangepublic static boolean mprotect(Address address, Extent size, int prot)
address
- Start of address range (Address)size
- Size of address rangeprot
- Protection (int)public static void setPageSize(Extent pageSizeFromBootRecord)
Note: this method may only be called once, at boot time. Multithreading is not yet enabled at this point, so no synchronization is necessary.
pageSizeFromBootRecord
- the page sizepublic static int getPagesize()
public static int getPagesizeLog()
public static byte getPagesizeLogAsByte()
public static void dumpMemory(Address start, int beforeBytes, int afterBytes)
public static int alignUp(int address, int alignment)
public static int alignDown(int address, int alignment)
static int getNativeThreshold()