|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.squawk.NativeUnsafe
public final class NativeUnsafe
A collection of methods for performing peek and poke operations on memory addresses.
Only the public methods of this class which do not override any of the
methods in java.lang.Object will be available in a non-hosted
environment. The translator replaces any calls to these methods to native
method calls.
Field Summary | |
---|---|
static int |
NATIVE_TASK_ARGS_OFFSET
|
static int |
NATIVE_TASK_EVENTID_OFFSET
|
static int |
NATIVE_TASK_LOW_RESULT_OFFSET
|
static int |
NATIVE_TASK_NT_ERRNO_RESULT_OFFSET
|
static int |
NATIVE_TASK_RESULT_OFFSET
|
Method Summary | |
---|---|
static int |
call0(Address fptr)
Call a function pointer with no arguments |
static int |
call1(Address fptr,
int i1)
Call a function pointer with one arguments |
static int |
call10(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7,
int i8,
int i9,
int i19)
Call a function pointer with 10 arguments |
static int |
call2(Address fptr,
int i1,
int i2)
Call a function pointer with two arguments |
static int |
call3(Address fptr,
int i1,
int i2,
int i3)
Call a function pointer with three arguments |
static int |
call4(Address fptr,
int i1,
int i2,
int i3,
int i4)
Call a function pointer with four arguments |
static int |
call5(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5)
Call a function pointer with five arguments |
static int |
call6(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6)
Call a function pointer with six arguments |
static int |
call7(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7)
Call a function pointer with seven arguments |
static int |
call8(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7,
int i8)
Call a function pointer with eight arguments |
static int |
call9(Address fptr,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7,
int i8,
int i9)
Call a function pointer with nine arguments |
static int |
cancelTaskExecutor(Address taskExecutor)
|
static char |
charAt(String str,
int index)
Gets character from a string. |
static void |
clearObject(Object base,
int offset)
Clears a pointer value in memory. |
static void |
copyMemory(byte[] buffer,
int memoryOffset,
int bufferOffset,
int length)
Copies a range of memory into a buffer. |
static void |
copyTypes(Address src,
Address dst,
int length)
Block copies the types recorded for a range of memory to another range of memory. |
static Address |
createTaskExecutor(Address name,
int priority,
int stacksize)
|
static int |
deleteNativeTask(Address ntask)
|
static int |
deleteTaskExecutor(Address taskExecutor)
|
static void |
free(Address ptr)
|
static Address |
getAddress(Object base,
int offset)
|
static int |
getAsByte(Object base,
int offset)
Gets a signed 8 bit value from memory ignoring any recorded type of the value at the designated location. |
static int |
getAsInt(Object base,
int offset)
Gets a signed 32 bit value from memory ignoring any recorded type of the value at the designated location. |
static int |
getAsShort(Object base,
int offset)
Gets a signed 16 bit value from memory ignoring any recorded type of the value at the designated location. |
static UWord |
getAsUWord(Object base,
int offset)
Gets a UWord value from memory ignoring any recorded type of the value at the designated location. |
static int |
getByte(Object base,
int offset)
|
static int |
getChar(Object base,
int offset)
|
static int |
getInt(Object base,
int offset)
|
static long |
getLong(Object base,
int offset)
|
static long |
getLongAtWord(Object base,
int offset)
|
static int |
getNativeTaskErrno(Address ntask)
|
static int |
getNativeTaskEventID(Address ntask)
|
static int |
getNativeTaskResult(Address ntask)
|
static Object |
getObject(Object base,
int offset)
|
static int |
getShort(Object base,
int offset)
|
static byte |
getType(Address ea)
Gets the type of a value at a given address. |
static int |
getUByte(Object base,
int offset)
|
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(Object base,
int offset)
|
static void |
hostedInit()
Do this little dance to avoid initializing static variables only used in a hosted environment. |
static void |
initialize(byte[] buffer,
BitSet oopMap,
boolean append)
Initialize or appends to the contents of memory. |
static Address |
malloc(UWord size)
Allocate a block of memory outside of the Java heap. |
static Address |
runBlockingFunctionOn(Address taskExecutor,
Address fptr,
int arg1,
int arg2,
int arg3,
int arg4,
int arg5,
int arg6,
int arg7,
int arg8,
int arg9,
int arg10)
|
static void |
setAddress(Object base,
int offset,
Object value)
|
static void |
setArrayTypes(Address ea,
byte componentType,
int componentSize,
int length)
Sets the type of each value in an array. |
static void |
setByte(Object base,
int offset,
int value)
|
static void |
setChar(Object base,
int offset,
int value)
|
static void |
setInt(Object base,
int offset,
int value)
|
static void |
setLong(Object base,
int offset,
long value)
|
static void |
setLongAtWord(Object base,
int offset,
long value)
|
static void |
setMemorySize(int newSize)
Sets the size of used/initialized memory. |
static void |
setObject(Object base,
int offset,
Object value)
|
static void |
setShort(Object base,
int offset,
int value)
|
static void |
setType(Address ea,
byte type,
int size)
Sets the type of a value at a given address. |
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(Object base,
int offset,
UWord value)
|
static void |
swap(Address address,
int dataSize)
Swaps the endianess of a value. |
static void |
swap2(Address address)
Swaps the endianess of a 2 byte value. |
static void |
swap4(Address address)
Swaps the endianess of a 4 byte value. |
static void |
swap8(Address address)
Swaps the endianess of a 8 byte value. |
static int |
waitForBlockingFunction(Address ntask)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NATIVE_TASK_EVENTID_OFFSET
public static final int NATIVE_TASK_RESULT_OFFSET
public static final int NATIVE_TASK_LOW_RESULT_OFFSET
public static final int NATIVE_TASK_NT_ERRNO_RESULT_OFFSET
public static final int NATIVE_TASK_ARGS_OFFSET
Method Detail |
---|
public static void setByte(Object base, int offset, int value) throws NativePragma
NativePragma
Unsafe.setByte(com.sun.squawk.Address, int, int)
public static void setShort(Object base, int offset, int value) throws NativePragma
NativePragma
Unsafe.setShort(com.sun.squawk.Address, int, int)
public static void setChar(Object base, int offset, int value) throws NativePragma
NativePragma
Unsafe.setChar(com.sun.squawk.Address, int, int)
public static void setInt(Object base, int offset, int value) throws NativePragma
NativePragma
Unsafe.setInt(com.sun.squawk.Address, int, int)
public static void setUWord(Object base, int offset, UWord value) throws NativePragma
NativePragma
Unsafe.setUWord(com.sun.squawk.Address, int, com.sun.squawk.UWord)
public static void setLong(Object base, int offset, long value) throws NativePragma
NativePragma
Unsafe.setLong(com.sun.squawk.Address, int, long)
public static void setLongAtWord(Object base, int offset, long value) throws NativePragma
NativePragma
Unsafe.setLongAtWord(com.sun.squawk.Address, int, long)
public static void setAddress(Object base, int offset, Object value) throws NativePragma
NativePragma
Unsafe.setAddress(com.sun.squawk.Address, int, com.sun.squawk.Address)
public static void setObject(Object base, int offset, Object value) throws NativePragma
NativePragma
Unsafe#setObject
public static void setType(Address ea, byte type, int size) throws NativePragma
VM.usingTypeMap()
returns false.
ea
- the address of the valuetype
- the type of the valuesize
- the size (in bytes) of the value
NativePragma
public static void setArrayTypes(Address ea, byte componentType, int componentSize, int length) throws NativePragma
VM.usingTypeMap()
returns false.
ea
- the address of an arraycomponentType
- the component type of the arraycomponentSize
- the size (in bytes) of componentType
length
- the length of the array
NativePragma
public static byte getType(Address ea) throws NativePragma
VM.usingTypeMap()
returns false.
ea
- the address to query
ea
NativePragma
public static void copyTypes(Address src, Address dst, int length) throws NativePragma
src
- the start address of the source rangedst
- the start address of the destination rangelength
- the length (in bytes) of the range
NativePragma
public static int getByte(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getByte(com.sun.squawk.Address, int)
public static int getUByte(Object base, int offset)
Unsafe.getUByte(com.sun.squawk.Address, int)
public static int getShort(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getShort(com.sun.squawk.Address, int)
public static int getChar(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getChar(com.sun.squawk.Address, int)
public static int getInt(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getInt(com.sun.squawk.Address, int)
public static UWord getUWord(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getUWord(com.sun.squawk.Address, int)
public static long getLong(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getLong(com.sun.squawk.Address, int)
public static long getLongAtWord(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getLongAtWord(com.sun.squawk.Address, int)
public static Object getObject(Object base, int offset) throws NativePragma
NativePragma
Unsafe#getObject
public static Address getAddress(Object base, int offset) throws NativePragma
NativePragma
Unsafe.getAddress(com.sun.squawk.Address, int)
public static UWord getAsUWord(Object base, int offset) throws NativePragma
getUWord(Object, int)
when runtime type checking
is disabled.
base
- the base addressoffset
- the offset (in words) from base
from which to load
NativePragma
public static int getAsByte(Object base, int offset) throws NativePragma
getByte(Object, int)
when runtime type checking
is disabled.
base
- the base addressoffset
- the offset (in 8 bit words) from base
from which to load
NativePragma
public static int getAsShort(Object base, int offset) throws NativePragma
getShort(Object, int)
when runtime type checking
is disabled.
base
- the base addressoffset
- the offset (in 16 bit words) from base
from which to load
NativePragma
public static int getAsInt(Object base, int offset) throws NativePragma
getInt(Object, int)
when runtime type checking
is disabled.
base
- the base addressoffset
- the offset (in 32 bit words) from base
from which to load
NativePragma
public static char charAt(String str, int index) throws NativePragma
str
- the stringindex
- the index to the character
NativePragma
public static int call0(Address fptr) throws NativePragma
NativePragma
public static int call1(Address fptr, int i1) throws NativePragma
NativePragma
public static int call2(Address fptr, int i1, int i2) throws NativePragma
NativePragma
public static int call3(Address fptr, int i1, int i2, int i3) throws NativePragma
NativePragma
public static int call4(Address fptr, int i1, int i2, int i3, int i4) throws NativePragma
NativePragma
public static int call5(Address fptr, int i1, int i2, int i3, int i4, int i5) throws NativePragma
NativePragma
public static int call6(Address fptr, int i1, int i2, int i3, int i4, int i5, int i6) throws NativePragma
NativePragma
public static int call7(Address fptr, int i1, int i2, int i3, int i4, int i5, int i6, int i7) throws NativePragma
NativePragma
public static int call8(Address fptr, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8) throws NativePragma
NativePragma
public static int call9(Address fptr, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) throws NativePragma
NativePragma
public static int call10(Address fptr, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i19) throws NativePragma
NativePragma
public static int getNativeTaskEventID(Address ntask)
public static int getNativeTaskResult(Address ntask)
public static int getNativeTaskErrno(Address ntask)
public static Address createTaskExecutor(Address name, int priority, int stacksize) throws NativePragma
NativePragma
public static int cancelTaskExecutor(Address taskExecutor) throws NativePragma
NativePragma
public static int deleteTaskExecutor(Address taskExecutor) throws NativePragma
NativePragma
public static Address runBlockingFunctionOn(Address taskExecutor, Address fptr, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10) throws NativePragma
NativePragma
public static int deleteNativeTask(Address ntask) throws NativePragma
NativePragma
public static int waitForBlockingFunction(Address ntask)
public static Address malloc(UWord size) throws NativePragma
Memory may be be very restricted on some platforms. Callers shouldn't rely on this memory unless they have a good understanding of the memory resvered for malloc on a particular platform.
size
-
NativePragma
public static void free(Address ptr) throws NativePragma
NativePragma
public static int getUnalignedShort(Address base, int boffset) throws NativePragma
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
NativePragma
public static int getUnalignedInt(Address base, int boffset) throws NativePragma
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
NativePragma
public static long getUnalignedLong(Address base, int boffset) throws NativePragma
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
NativePragma
public static void setUnalignedShort(Address base, int boffset, int value) throws NativePragma
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
-
NativePragma
public static void setUnalignedInt(Address base, int boffset, int value) throws NativePragma
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
-
NativePragma
public static void setUnalignedLong(Address base, int boffset, long value) throws NativePragma
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
-
NativePragma
public static void swap(Address address, int dataSize) throws NativePragma
address
- the address of the valuedataSize
- the size (in bytes) of the value
NativePragma
public static void swap2(Address address) throws NativePragma
address
- the address of the value
NativePragma
public static void swap4(Address address) throws NativePragma
address
- the address of the value
NativePragma
public static void swap8(Address address) throws NativePragma
address
- the address of the value
NativePragma
public static void clearObject(Object base, int offset) throws HostedPragma
base
- the base addressoffset
- the offset (in UWords) from base
of the pointer to clear
HostedPragma
public static void hostedInit() throws HostedPragma
HostedPragma
public static void initialize(byte[] buffer, BitSet oopMap, boolean append) throws HostedPragma
buffer
- a buffer containing a serialized object memory relative to 0oopMap
- an oop map specifying where the pointers in the serialized object memory areappend
- specifies if the memory is being appended to
HostedPragma
public static void setMemorySize(int newSize) throws HostedPragma
newSize
and greater are zeroed.
newSize
- the new size of memory
HostedPragma
public static void copyMemory(byte[] buffer, int memoryOffset, int bufferOffset, int length) throws HostedPragma
buffer
- the buffer to copy intomemoryOffset
- the offset in memory at which to start copying frombufferOffset
- the offset in buffer
at which to start copying tolength
- the number of bytes to copy
HostedPragma
|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |