|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.runtime.Memory
public class Memory
Low level memory management functions.
Note that this class is "uninterruptible" - calling its methods will never cause the current thread to yield the CPU to another thread (one that might cause a GC, for example).
Field Summary | |
---|---|
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 boolean |
USE_NATIVE
Allow the use of C based memcpy |
Constructor Summary | |
---|---|
Memory()
|
Method Summary | |
---|---|
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 |
static int |
getPagesize()
Do getpagesize call |
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)
Copy a region of memory. |
static void |
memcopy(Address dst,
Address src,
int cnt)
|
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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public Memory()
Method Detail |
---|
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)
Assumption: source and destination regions do not overlap
dst
- Destination addresssrc
- Source addresscnt
- Number of bytes to copypublic static void memcopy(Address dst, Address src, int cnt)
public 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 range
public static boolean mprotect(Address address, Extent size, int prot)
address
- Start of address range (Address)size
- Size of address rangeprot
- Protection (int)
public static int getPagesize()
public static void dumpMemory(Address start, int beforeBytes, int afterBytes)
public static Address alignUp(Address address, int alignment)
public static Address alignDown(Address address, int alignment)
public static int alignUp(int address, int alignment)
public static int alignDown(int address, int alignment)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |