Skip to end of metadata
Go to start of metadata

If a type is boxed then it means that values of that type are represented by a pointer to a heap object. An unboxed type is represented by the value itself such as int, double, float, byte etc. Values of unboxed types appear only in the virtual machine's stack, registers, or as fields/elements of class/array instances.

The Jikes RVM also defines a number of other unboxed types. Due to a limitation of the way the compiler generates code the Jikes RVM must define an unboxed array type for each unboxed type. The unboxed types are;

  • org.vmmagic.unboxed.Address
  • org.vmmagic.unboxed.Extent
  • org.vmmagic.unboxed.ObjectReference
  • org.vmmagic.unboxed.Offset
  • org.vmmagic.unboxed.Word
  • org.jikesrvm.ArchitectureSpecific.Code

Unboxed types may inherit from Object but they are not objects. As such there are some restrictions on the use of unboxed types:

  • A unboxed type instance must not be passed where an Object is expected. This will type-check, but it is not what you want. A corollary is to avoid overloading a method where the two overloaded versions of the method can only be distinguished by operating on an Object versus an unboxed type.
  • An unboxed type must not be synchronized on.
  • They have no virtual methods.
  • They do not support lock operations, generating hashcodes or any other method inherited from Object.
  • All methods must be compiler intrinsics.
  • Avoid making an array of an unboxed type. Instead represent it by the array version of unboxed type. i.e. org.vmmagic.unboxed.Address[] should be replaced with org.vmmagic.unboxed.AddressArray but org.vmmagic.unboxed.AddressArray[] is fine.
  • No labels