SunSPOT API V3.0


com.sun.squawk
Class Address

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

public final class Address
extends Object

The Address class is used to abstract machine addresses. It is used instead of 'int' or 'Object' for coding clarity and machine-portability (it can map to 32 bit and 64 bit integral types).

Variables of type Address will never be updated if they correspond with an object that may be moved by the garbage collector. As such, they should never appear in code that may have a collection occur in between the definition and use of the variable. In general, variables of type address should not be used outside of the garbage collector.

This class is known specially by the translator as a Modifier#SQUAWKPRIMITIVE and programming with it requires adhering to the restrictions implied by this attribute.

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.

This mechanism was largely inspired by the VM_Address class in the Jikes RVM.

Author:
Doug Simon

Method Summary
 Address add(int offset)
          Adds a 32 bit offset to this address and return the resulting address.
 Address addOffset(Offset offset)
          Adds a 32 or 64 bit offset to this address and return the resulting address.
 Address and(UWord word)
          Logically AND a word with this address.
 Offset diff(Address address2)
          Calculates the offset between this address an another address.
 boolean eq(Address address2)
          Determines if this address is equal to a given address.
static Address fromObject(Object object)
          Casts an object reference to an address.
static Address fromPrimitive(int value)
          Casts a word expressed as the appropriate Java primitive type for the platform (i.e. int or long) into a value of type Address.
 boolean hi(Address address2)
          Determines if this address is higher than a given address.
 boolean hieq(Address address2)
          Determines if this address is higher than or equal to a given address.
 boolean isMax()
          Determines if this address is equals to max.
 boolean isZero()
          Determines if this address is null.
 boolean lo(Address address2)
          Determines if this address is lower than a given address.
 boolean loeq(Address address2)
          Determines if this address is lower than or equal to a given address.
static Address max()
          Gets the largest possible machine address.
 boolean ne(Address address2)
          Determines if this address is not equal to a given address.
 Address or(UWord word)
          Logically OR a word with this address.
 Address roundDown(int alignment)
          Rounds this address down based on a given alignment.
 Address roundDownToWord()
          Rounds this address down to a machine word boundary.
 Address roundUp(int alignment)
          Rounds this address up based on a given alignment.
 Address roundUpToWord()
          Rounds this address up to a machine word boundary.
 Address sub(int offset)
          Subtracts a 32 bit offset to this address and return the resulting address.
 Address subOffset(Offset offset)
          Subtracts a 32 or 64 bit offset to this address and return the resulting address.
 Object toObject()
          Casts this address to an object reference.
 UWord toUWord()
          Casts this address to a UWord.
static Address zero()
          Gets the canonical Address representation of null.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public Address add(int offset)
Adds a 32 bit offset to this address and return the resulting address.

Parameters:
offset - the offset to add
Returns:
the result of adding offset to this address

addOffset

public Address addOffset(Offset offset)
Adds a 32 or 64 bit offset to this address and return the resulting address.

Parameters:
offset - the offset to add
Returns:
the result of adding offset to this address

and

public Address and(UWord word)
Logically AND a word with this address.

Parameters:
word - the word to AND this address with
Returns:
the result of the AND operation

diff

public Offset diff(Address address2)
Calculates the offset between this address an another address.

Parameters:
address2 - the address to compare this address with
Returns:
the offset that must be applied to this address to get address2

eq

public boolean eq(Address address2)
Determines if this address is equal to a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is equal to address2

fromObject

public static Address fromObject(Object object)
Casts an object reference to an address.

Parameters:
object - the object reference to cast
Returns:
the object reference as an address

fromPrimitive

public static Address fromPrimitive(int value)
Casts a word expressed as the appropriate Java primitive type for the platform (i.e. int or long) into a value of type Address.

Parameters:
value - an address expressed as an int or long
Returns:
the canonical Address instance for value

hi

public boolean hi(Address address2)
Determines if this address is higher than a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is higher than address2

hieq

public boolean hieq(Address address2)
Determines if this address is higher than or equal to a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is higher than or equal to address2

isMax

public boolean isMax()
Determines if this address is equals to max.

Returns:
true if this address is equals to max

isZero

public boolean isZero()
Determines if this address is null.

Returns:
true if this address is null

lo

public boolean lo(Address address2)
Determines if this address is lower than a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is lower than or equals to address2

loeq

public boolean loeq(Address address2)
Determines if this address is lower than or equal to a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is lower than or equal to address2

max

public static Address max()
Gets the largest possible machine address.

Returns:
the largest possible machine address

ne

public boolean ne(Address address2)
Determines if this address is not equal to a given address.

Parameters:
address2 - the address to compare this address against
Returns:
true if this address is not equal to address2

or

public Address or(UWord word)
Logically OR a word with this address.

Parameters:
word - the word to OR this address with
Returns:
the result of the OR operation

roundDown

public Address roundDown(int alignment)
Rounds this address down based on a given alignment.

Parameters:
alignment - this address is rounded down to be a multiple of this value
Returns:
the new address

roundDownToWord

public Address roundDownToWord()
Rounds this address down to a machine word boundary.

Returns:
the new address

roundUp

public Address roundUp(int alignment)
Rounds this address up based on a given alignment.

Parameters:
alignment - this address is rounded up to be a multiple of this value
Returns:
the new address

roundUpToWord

public Address roundUpToWord()
Rounds this address up to a machine word boundary.

Returns:
the new address

sub

public Address sub(int offset)
Subtracts a 32 bit offset to this address and return the resulting address.

Parameters:
offset - the offset to subract
Returns:
the result of subtracting offset to this address

subOffset

public Address subOffset(Offset offset)
Subtracts a 32 or 64 bit offset to this address and return the resulting address.

Parameters:
offset - the offset to subract
Returns:
the result of subtracting offset to this address

toObject

public Object toObject()
Casts this address to an object reference.

Returns:
this address as an object reference

toUWord

public UWord toUWord()
Casts this address to a UWord.

Returns:
this address as a UWord

zero

public static Address zero()
Gets the canonical Address representation of null.

Returns:
the canonical Address representation of null

SunSPOT API V3.0


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