Package libcore.io

Class Memory


  • public final class Memory
    extends Object
    Unsafe access to memory.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void memmove​(Object dstObject, int dstOffset, Object srcObject, int srcOffset, long byteCount)
      Copies 'byteCount' bytes from the source to the destination.
      static byte peekByte​(long address)  
      static void peekByteArray​(long address, byte[] dst, int dstOffset, int byteCount)  
      static void peekCharArray​(long address, char[] dst, int dstOffset, int charCount, boolean swap)  
      static void peekDoubleArray​(long address, double[] dst, int dstOffset, int doubleCount, boolean swap)  
      static void peekFloatArray​(long address, float[] dst, int dstOffset, int floatCount, boolean swap)  
      static int peekInt​(byte[] src, int offset, ByteOrder order)  
      static int peekInt​(long address, boolean swap)  
      static void peekIntArray​(long address, int[] dst, int dstOffset, int intCount, boolean swap)  
      static long peekLong​(byte[] src, int offset, ByteOrder order)  
      static long peekLong​(long address, boolean swap)  
      static void peekLongArray​(long address, long[] dst, int dstOffset, int longCount, boolean swap)  
      static short peekShort​(byte[] src, int offset, ByteOrder order)  
      static short peekShort​(long address, boolean swap)  
      static void peekShortArray​(long address, short[] dst, int dstOffset, int shortCount, boolean swap)  
      static void pokeByte​(long address, byte value)  
      static void pokeByteArray​(long address, byte[] src, int offset, int count)  
      static void pokeCharArray​(long address, char[] src, int offset, int count, boolean swap)  
      static void pokeDoubleArray​(long address, double[] src, int offset, int count, boolean swap)  
      static void pokeFloatArray​(long address, float[] src, int offset, int count, boolean swap)  
      static void pokeInt​(byte[] dst, int offset, int value, ByteOrder order)  
      static void pokeInt​(long address, int value, boolean swap)  
      static void pokeIntArray​(long address, int[] src, int offset, int count, boolean swap)  
      static void pokeLong​(byte[] dst, int offset, long value, ByteOrder order)  
      static void pokeLong​(long address, long value, boolean swap)  
      static void pokeLongArray​(long address, long[] src, int offset, int count, boolean swap)  
      static void pokeShort​(byte[] dst, int offset, short value, ByteOrder order)  
      static void pokeShort​(long address, short value, boolean swap)  
      static void pokeShortArray​(long address, short[] src, int offset, int count, boolean swap)  
      static void unsafeBulkGet​(Object dst, int dstOffset, int byteCount, byte[] src, int srcOffset, int sizeofElements, boolean swap)
      Used to optimize nio heap buffer bulk get operations.
      static void unsafeBulkPut​(byte[] dst, int dstOffset, int byteCount, Object src, int srcOffset, int sizeofElements, boolean swap)
      Used to optimize nio heap buffer bulk put operations.
    • Method Detail

      • unsafeBulkGet

        public static void unsafeBulkGet​(Object dst,
                                         int dstOffset,
                                         int byteCount,
                                         byte[] src,
                                         int srcOffset,
                                         int sizeofElements,
                                         boolean swap)
        Used to optimize nio heap buffer bulk get operations. 'dst' must be a primitive array. 'dstOffset' is measured in units of 'sizeofElements' bytes.
      • unsafeBulkPut

        public static void unsafeBulkPut​(byte[] dst,
                                         int dstOffset,
                                         int byteCount,
                                         Object src,
                                         int srcOffset,
                                         int sizeofElements,
                                         boolean swap)
        Used to optimize nio heap buffer bulk put operations. 'src' must be a primitive array. 'srcOffset' is measured in units of 'sizeofElements' bytes.
      • peekInt

        public static int peekInt​(byte[] src,
                                  int offset,
                                  ByteOrder order)
      • peekLong

        public static long peekLong​(byte[] src,
                                    int offset,
                                    ByteOrder order)
      • peekShort

        public static short peekShort​(byte[] src,
                                      int offset,
                                      ByteOrder order)
      • pokeInt

        public static void pokeInt​(byte[] dst,
                                   int offset,
                                   int value,
                                   ByteOrder order)
      • pokeLong

        public static void pokeLong​(byte[] dst,
                                    int offset,
                                    long value,
                                    ByteOrder order)
      • pokeShort

        public static void pokeShort​(byte[] dst,
                                     int offset,
                                     short value,
                                     ByteOrder order)
      • memmove

        public static void memmove​(Object dstObject,
                                   int dstOffset,
                                   Object srcObject,
                                   int srcOffset,
                                   long byteCount)
        Copies 'byteCount' bytes from the source to the destination. The objects are either instances of DirectByteBuffer or byte[]. The offsets in the byte[] case must include the Buffer.arrayOffset if the array came from a Buffer.array call. We could make this private and provide the four type-safe variants, but then ByteBuffer.put(ByteBuffer) would need to work out which to call based on whether the source and destination buffers are direct or not.
      • peekByte

        public static byte peekByte​(long address)
      • peekInt

        public static int peekInt​(long address,
                                  boolean swap)
      • peekLong

        public static long peekLong​(long address,
                                    boolean swap)
      • peekShort

        public static short peekShort​(long address,
                                      boolean swap)
      • peekByteArray

        public static void peekByteArray​(long address,
                                         byte[] dst,
                                         int dstOffset,
                                         int byteCount)
      • peekCharArray

        public static void peekCharArray​(long address,
                                         char[] dst,
                                         int dstOffset,
                                         int charCount,
                                         boolean swap)
      • peekDoubleArray

        public static void peekDoubleArray​(long address,
                                           double[] dst,
                                           int dstOffset,
                                           int doubleCount,
                                           boolean swap)
      • peekFloatArray

        public static void peekFloatArray​(long address,
                                          float[] dst,
                                          int dstOffset,
                                          int floatCount,
                                          boolean swap)
      • peekIntArray

        public static void peekIntArray​(long address,
                                        int[] dst,
                                        int dstOffset,
                                        int intCount,
                                        boolean swap)
      • peekLongArray

        public static void peekLongArray​(long address,
                                         long[] dst,
                                         int dstOffset,
                                         int longCount,
                                         boolean swap)
      • peekShortArray

        public static void peekShortArray​(long address,
                                          short[] dst,
                                          int dstOffset,
                                          int shortCount,
                                          boolean swap)
      • pokeByte

        public static void pokeByte​(long address,
                                    byte value)
      • pokeInt

        public static void pokeInt​(long address,
                                   int value,
                                   boolean swap)
      • pokeLong

        public static void pokeLong​(long address,
                                    long value,
                                    boolean swap)
      • pokeShort

        public static void pokeShort​(long address,
                                     short value,
                                     boolean swap)
      • pokeByteArray

        public static void pokeByteArray​(long address,
                                         byte[] src,
                                         int offset,
                                         int count)
      • pokeCharArray

        public static void pokeCharArray​(long address,
                                         char[] src,
                                         int offset,
                                         int count,
                                         boolean swap)
      • pokeDoubleArray

        public static void pokeDoubleArray​(long address,
                                           double[] src,
                                           int offset,
                                           int count,
                                           boolean swap)
      • pokeFloatArray

        public static void pokeFloatArray​(long address,
                                          float[] src,
                                          int offset,
                                          int count,
                                          boolean swap)
      • pokeIntArray

        public static void pokeIntArray​(long address,
                                        int[] src,
                                        int offset,
                                        int count,
                                        boolean swap)
      • pokeLongArray

        public static void pokeLongArray​(long address,
                                         long[] src,
                                         int offset,
                                         int count,
                                         boolean swap)
      • pokeShortArray

        public static void pokeShortArray​(long address,
                                          short[] src,
                                          int offset,
                                          int count,
                                          boolean swap)