Sun SPOT API
Green Release  


com.sun.squawk
Class Unsafe

java.lang.Object
  extended by com.sun.squawk.Unsafe

public final class Unsafe
extends Object

A collection of methods for performing peek and poke operations on memory addresses.

Author:
Nik Shaylor, Doug Simon

Method Summary
static Address getAddress(Object base, int offset)
          Gets a pointer from memory as an Address.
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)
          Gets a signed 8 bit value from memory.
static int getChar(Object base, int offset)
          Gets an unsigned 16 bit value from memory.
static int getInt(Object base, int offset)
          Gets a signed 32 bit value from memory.
static long getLong(Object base, int offset)
          Gets a 64 bit value from memory using a 64 bit word offset.
static long getLongAtWord(Object base, int offset)
          Gets a 64 bit value from memory using a 32 bit word offset.
static Object getObject(Object base, int offset)
          Gets a pointer from memory as an Object.
static int getShort(Object base, int offset)
          Gets a signed 16 bit value from memory.
static UWord getUWord(Object base, int offset)
          Gets an unsigned 32 or 64 bit value from memory.
static void setAddress(Object base, int offset, Object value)
          Sets a pointer value in memory without updating the write barrier.
static void setByte(Object base, int offset, int value)
          Sets an 8 bit value in memory.
static void setChar(Object base, int offset, int value)
          Sets an unsigned 16 bit value in memory.
static void setInt(Object base, int offset, int value)
          Sets a 32 bit value in memory.
static void setLong(Object base, int offset, long value)
          Sets a 64 bit value in memory.
static void setLongAtWord(Object base, int offset, long value)
          Sets a 64 bit value in memory at a 32 bit word offset.
static void setObject(Object base, int offset, Object value)
          Sets a pointer value in memory and updates the write barrier.
static void setShort(Object base, int offset, int value)
          Sets a signed 16 bit value in memory.
static void setUWord(Object base, int offset, UWord value)
          Sets a UWord value in memory.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setByte

public static void setByte(Object base,
                           int offset,
                           int value)
Sets an 8 bit value in memory.

Parameters:
base - the base address
offset - the offset (in bytes) from base at which to write
value - the value to write

setShort

public static void setShort(Object base,
                            int offset,
                            int value)
Sets a signed 16 bit value in memory.

Parameters:
base - the base address
offset - the offset (in 16 bit words) from base at which to write
value - the value to write

setChar

public static void setChar(Object base,
                           int offset,
                           int value)
Sets an unsigned 16 bit value in memory.

Parameters:
base - the base address
offset - the offset (in 16 bit words) from base at which to write
value - the value to write

setInt

public static void setInt(Object base,
                          int offset,
                          int value)
Sets a 32 bit value in memory.

Parameters:
base - the base address
offset - the offset (in 32 bit words) from base at which to write
value - the value to write

setUWord

public static void setUWord(Object base,
                            int offset,
                            UWord value)
Sets a UWord value in memory.

Parameters:
base - the base address
offset - the offset (in UWords) from base at which to write
value - the value to write

setLong

public static void setLong(Object base,
                           int offset,
                           long value)
Sets a 64 bit value in memory.

Parameters:
base - the base address
offset - the offset (in 64 bit words) from base at which to write
value - the value to write

setLongAtWord

public static void setLongAtWord(Object base,
                                 int offset,
                                 long value)
Sets a 64 bit value in memory at a 32 bit word offset.

Parameters:
base - the base address
offset - the offset (in 32 bit words) from base at which to write
value - the value to write

setAddress

public static void setAddress(Object base,
                              int offset,
                              Object value)
Sets a pointer value in memory without updating the write barrier. If this method is being called in a hosted environment then the corresponding bit in the oop map (if any) is also set.

Parameters:
base - the base address
offset - the offset (in UWords) from base at which to write
value - the value to write

setObject

public static void setObject(Object base,
                             int offset,
                             Object value)
Sets a pointer value in memory and updates the write barrier.

Parameters:
base - the base address
offset - the offset (in UWords) from base at which to write
value - the value to write

getByte

public static int getByte(Object base,
                          int offset)
Gets a signed 8 bit value from memory.

Parameters:
base - the base address
offset - the offset (in bytes) from base from which to load
Returns:
the value

getShort

public static int getShort(Object base,
                           int offset)
Gets a signed 16 bit value from memory.

Parameters:
base - the base address
offset - the offset (in 16 bit words) from base from which to load
Returns:
the value

getChar

public static int getChar(Object base,
                          int offset)
Gets an unsigned 16 bit value from memory.

Parameters:
base - the base address
offset - the offset (in 16 bit words) from base from which to load
Returns:
the value

getInt

public static int getInt(Object base,
                         int offset)
Gets a signed 32 bit value from memory.

Parameters:
base - the base address
offset - the offset (in 32 bit words) from base from which to load
Returns:
the value

getUWord

public static UWord getUWord(Object base,
                             int offset)
Gets an unsigned 32 or 64 bit value from memory.

Parameters:
base - the base address
offset - the offset (in UWords) from base from which to load
Returns:
the value

getLong

public static long getLong(Object base,
                           int offset)
Gets a 64 bit value from memory using a 64 bit word offset.

Parameters:
base - the base address
offset - the offset (in 64 bit words) from base from which to load
Returns:
the value

getLongAtWord

public static long getLongAtWord(Object base,
                                 int offset)
Gets a 64 bit value from memory using a 32 bit word offset.

Parameters:
base - the base address
offset - the offset (in 32 bit words) from base from which to load
Returns:
the value

getObject

public static Object getObject(Object base,
                               int offset)
Gets a pointer from memory as an Object.

Parameters:
base - the base address
offset - the offset (in UWords) from base from which to load
Returns:
the value

getAddress

public static Address getAddress(Object base,
                                 int offset)
Gets a pointer from memory as an Address.

Parameters:
base - the base address
offset - the offset (in UWords) from base from which to load
Returns:
the value

getAsUWord

public static UWord getAsUWord(Object base,
                               int offset)
Gets a UWord value from memory ignoring any recorded type of the value at the designated location. This operation is equivalent to getUWord(Object, int) when runtime type checking is disabled.

Parameters:
base - the base address
offset - the offset (in words) from base from which to load
Returns:
the value

getAsByte

public 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. This operation is equivalent to getByte(Object, int) when runtime type checking is disabled.

Parameters:
base - the base address
offset - the offset (in 8 bit words) from base from which to load
Returns:
the value

getAsShort

public 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. This operation is equivalent to getShort(Object, int) when runtime type checking is disabled.

Parameters:
base - the base address
offset - the offset (in 16 bit words) from base from which to load
Returns:
the value

getAsInt

public 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. This operation is equivalent to getInt(Object, int) when runtime type checking is disabled.

Parameters:
base - the base address
offset - the offset (in 32 bit words) from base from which to load
Returns:
the value

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.