|
SunSPOT API V4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.squawk.Unsafe
public final class Unsafe
A collection of methods for performing peek and poke operations on memory addresses.
The Unsafe class is primarily concerned with accessing memory ouside of the Java heap, but improper use of the Unsafe class can corrupt the Java heap (hence the name).
Only "trusted" Isolates may use the methods of this class. Calls to Any memory accessor methods by an untrusted Isolate will throw a SecurityException.
Isolate
Method Summary | |
---|---|
static Address |
getAddress(Address base,
int offset)
Gets a pointer from memory as an Address. |
static int |
getByte(Address base,
int offset)
Gets a signed 8 bit value from memory. |
static void |
getBytes(Address src,
int boffset,
byte[] bytes,
int low,
int number)
Copy from memory to byte array. |
static int |
getChar(Address base,
int offset)
Gets an unsigned 16 bit value from memory. |
static int |
getInt(Address base,
int offset)
Gets a signed 32 bit value from memory. |
static void |
getInts(Address src,
int boffset,
int[] ints,
int low,
int number)
Copy from memory to int array. |
static long |
getLong(Address base,
int offset)
Gets a 64 bit value from memory using a 64 bit word offset. |
static long |
getLongAtWord(Address base,
int offset)
Gets a 64 bit value from memory using a 32 bit word offset. |
static void |
getLongs(Address src,
int boffset,
long[] longs,
int low,
int number)
Copy from memory to long array. |
static int |
getShort(Address base,
int offset)
Gets a signed 16 bit value from memory. |
static void |
getShorts(Address src,
int boffset,
short[] shorts,
int low,
int number)
Copy from memory to short array. |
static int |
getUByte(Address base,
int offset)
Gets an unsigned 8 bit value from memory. |
static int |
getUnalignedInt(Address base,
int boffset)
Gets the int at the given byte offset in the memory, starting from base. |
static long |
getUnalignedLong(Address base,
int boffset)
Gets the long at the given byte offset in the memory, starting from base. |
static int |
getUnalignedShort(Address base,
int boffset)
Gets the short at the given byte offset in the memory, starting from base. |
static UWord |
getUWord(Address base,
int offset)
Gets an unsigned 32 or 64 bit value from memory. |
static void |
setAddress(Address base,
int offset,
Address value)
Sets a pointer value in memory without updating the write barrier. |
static void |
setByte(Address base,
int offset,
int value)
Sets an 8 bit value in memory. |
static void |
setBytes(Address dst,
int boffset,
byte[] bytes,
int low,
int number)
Copy from byte array to memory. |
static void |
setChar(Address base,
int offset,
int value)
Sets an unsigned 16 bit value in memory. |
static void |
setInt(Address base,
int offset,
int value)
Sets a 32 bit value in memory. |
static void |
setInts(Address dst,
int boffset,
int[] ints,
int low,
int number)
Copy from int array to memory. |
static void |
setLong(Address base,
int offset,
long value)
Sets a 64 bit value in memory. |
static void |
setLongAtWord(Address base,
int offset,
long value)
Sets a 64 bit value in memory at a 32 bit word offset. |
static void |
setLongs(Address dst,
int boffset,
long[] longs,
int low,
int number)
Copy from long array to memory. |
static void |
setShort(Address base,
int offset,
int value)
Sets a signed 16 bit value in memory. |
static void |
setShorts(Address dst,
int boffset,
short[] shorts,
int low,
int number)
Copy from short array to memory. |
static void |
setUnalignedInt(Address base,
int boffset,
int value)
Gets the int at the given byte offset in the memory, starting from base. |
static void |
setUnalignedLong(Address base,
int boffset,
long value)
Gets the long at the given byte offset in the memory, starting from base. |
static void |
setUnalignedShort(Address base,
int boffset,
int value)
Sets the short at the given byte offset in the memory, starting from base. |
static void |
setUWord(Address base,
int offset,
UWord value)
Sets a UWord value in memory. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Address getAddress(Address base, int offset)
base
- the base addressoffset
- the offset (in UWords) from base
from which to load
public static int getByte(Address base, int offset)
base
- the base addressoffset
- the offset (in bytes) from base
from which to load
public static void getBytes(Address src, int boffset, byte[] bytes, int low, int number)
number
bytes from the memory location specified by the address dst
and byte offset boffset
to
the byte array bytes
starting at position low
.
src
- the base memory addressboffset
- the byte offset to add to the base memory addressbytes
- the destination byte arraylow
- the offset in the destination arraynumber
- the number of bytes to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the dst arraypublic static int getChar(Address base, int offset)
base
- the base addressoffset
- the offset (in 16 bit words) from base
from which to load
public static int getInt(Address base, int offset)
base
- the base addressoffset
- the offset (in 32 bit words) from base
from which to load
public static void getInts(Address src, int boffset, int[] ints, int low, int number)
number
ints from the memory location specified by the address dst
and byte offset boffset
to
the int array ints
starting at position low
.
src
- the base memory addressboffset
- the byte offset to add to the base memory addressints
- the destination int arraylow
- the offset in the destination arraynumber
- the number of ints to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the dst arraypublic static long getLong(Address base, int offset)
base
- the base addressoffset
- the offset (in 64 bit words) from base
from which to load
public static long getLongAtWord(Address base, int offset)
base
- the base addressoffset
- the offset (in 32 bit words) from base
from which to load
public static void getLongs(Address src, int boffset, long[] longs, int low, int number)
number
longs from the memory location specified by the address dst
and byte offset boffset
to
the long array longs
starting at position low
.
src
- the base memory addressboffset
- the byte offset to add to the base memory addresslongs
- the destination long arraylow
- the offset in the destination arraynumber
- the number of ints to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the dst arraypublic static int getShort(Address base, int offset)
base
- the base addressoffset
- the offset (in 16 bit words) from base
from which to load
public static void getShorts(Address src, int boffset, short[] shorts, int low, int number)
number
shorts from the memory location specified by the address dst
and byte offset boffset
to
the short array shorts
starting at position low
.
src
- the base memory addressboffset
- the byte offset to add to the base memory addressshorts
- the destination short arraylow
- the offset in the destination arraynumber
- the number of shorts to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the dst arraypublic static int getUByte(Address base, int offset)
base
- the base addressoffset
- the offset (in bytes) from base
from which to load
public static UWord getUWord(Address base, int offset)
base
- the base addressoffset
- the offset (in UWords) from base
from which to load
public static int getUnalignedInt(Address base, int boffset)
int
at the given byte offset in the memory, starting from base.
If the integer is aligned on a "natural"
boundary it is always loaded from memory
in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and
the number and order of the load operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the int to be loaded
public static long getUnalignedLong(Address base, int boffset)
long
at the given byte offset in the memory, starting from base.
If the long is aligned on a "natural"
boundary it is always loaded from memory
in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and
the number and order of the load operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the long to be loaded
public static int getUnalignedShort(Address base, int boffset)
short
at the given byte offset in the memory, starting from base.
If the short is aligned on a "natural"
boundary it is always loaded from memory
in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and
the number and order of the load operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the short to be loaded
public static void setAddress(Address base, int offset, Address value)
hosted
environment then the corresponding bit in the
oop map (if any) is also set.
base
- the base addressoffset
- the offset (in UWords) from base
at which to writevalue
- the value to writepublic static void setByte(Address base, int offset, int value)
base
- the base addressoffset
- the offset (in bytes) from base
at which to writevalue
- the value to writepublic static void setBytes(Address dst, int boffset, byte[] bytes, int low, int number)
number
bytes from byte array bytes
starting at position low
.to the memory location specified
by the address dst
and byte offset boffset
.
dst
- the base memory addressboffset
- the byte offset to add to the base memory addressbytes
- the src byte arraylow
- the offset in the src arraynumber
- the number of bytes to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the src arraypublic static void setChar(Address base, int offset, int value)
base
- the base addressoffset
- the offset (in 16 bit words) from base
at which to writevalue
- the value to writepublic static void setInt(Address base, int offset, int value)
base
- the base addressoffset
- the offset (in 32 bit words) from base
at which to writevalue
- the value to writepublic static void setInts(Address dst, int boffset, int[] ints, int low, int number)
number
int from int array ints
starting at position low
.to the memory location specified
by the address dst
and byte offset boffset
.
dst
- the base memory addressboffset
- the byte offset to add to the base memory addressints
- the src int arraylow
- the offset in the src arraynumber
- the number of bytes to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the src arraypublic static void setLong(Address base, int offset, long value)
base
- the base addressoffset
- the offset (in 64 bit words) from base
at which to writevalue
- the value to writepublic static void setLongAtWord(Address base, int offset, long value)
base
- the base addressoffset
- the offset (in 32 bit words) from base
at which to writevalue
- the value to writepublic static void setLongs(Address dst, int boffset, long[] longs, int low, int number)
number
longs from long array longs
starting at position low
.to the memory location specified
by the address dst
and byte offset boffset
.
dst
- the base memory addressboffset
- the byte offset to add to the base memory addresslongs
- the src long arraylow
- the offset in the src arraynumber
- the number of bytes to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the src arraypublic static void setShort(Address base, int offset, int value)
base
- the base addressoffset
- the offset (in 16 bit words) from base
at which to writevalue
- the value to writepublic static void setShorts(Address dst, int boffset, short[] shorts, int low, int number)
number
shorts from short array shorts
starting at position low
.to the memory location specified
by the address dst
and byte offset boffset
.
dst
- the base memory addressboffset
- the byte offset to add to the base memory addressshorts
- the src short arraylow
- the offset in the src arraynumber
- the number of bytes to copy
ArrayIndexOutOfBoundsException
- if the range specified by low and number does not fit within the src arraypublic static void setUWord(Address base, int offset, UWord value)
base
- the base addressoffset
- the offset (in UWords) from base
at which to writevalue
- the value to writepublic static void setUnalignedInt(Address base, int boffset, int value)
int
at the given byte offset in the memory, starting from base.
If the integer is aligned on a "natural"
boundary it is always stored to memory
in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and
the number and order of the store operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the location to be storedvalue
- public static void setUnalignedLong(Address base, int boffset, long value)
long
at the given byte offset in the memory, starting from base.
If the long is aligned on a "natural"
boundary it is always stored to memory
in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and
the number and order of the store operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the location to be storedvalue
- public static void setUnalignedShort(Address base, int boffset, int value)
short
at the given byte offset in the memory, starting from base.
If the short is aligned on a "natural"
boundary it is always stored to memory
in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and
the number and order of the store operations is unspecified.
base
- address of to region of memoryboffset
- The offset in bytes from base to the location to be storedvalue
-
|
SunSPOT API V4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |