< prev index next >

src/java.base/share/classes/java/nio/Bits.java

Print this page




 758      *
 759      * @param   src
 760      *          source array
 761      * @param   srcBaseOffset
 762      *          offset of first element of storage in source array
 763      * @param   srcPos
 764      *          offset within source array of the first element to read
 765      * @param   dstAddr
 766      *          destination address
 767      * @param   length
 768      *          number of bytes to copy
 769      */
 770     static void copyFromArray(Object src, long srcBaseOffset, long srcPos,
 771                               long dstAddr, long length)
 772     {
 773         long offset = srcBaseOffset + srcPos;
 774         while (length > 0) {
 775             long size = (length > UNSAFE_COPY_THRESHOLD) ? UNSAFE_COPY_THRESHOLD : length;
 776             unsafe.copyMemory(src, offset, null, dstAddr, size);
 777             length -= size;
 778             offset += size;
 779             dstAddr += size;
 780         }
 781     }
 782 
 783     /**
 784      * Copy from source address into given destination array.
 785      *
 786      * @param   srcAddr
 787      *          source address
 788      * @param   dst
 789      *          destination array
 790      * @param   dstBaseOffset
 791      *          offset of first element of storage in destination array
 792      * @param   dstPos
 793      *          offset within destination array of the first element to write
 794      * @param   length
 795      *          number of bytes to copy
 796      */
 797     static void copyToArray(long srcAddr, Object dst, long dstBaseOffset, long dstPos,
 798                             long length)
 799     {
 800         long offset = dstBaseOffset + dstPos;
 801         while (length > 0) {
 802             long size = (length > UNSAFE_COPY_THRESHOLD) ? UNSAFE_COPY_THRESHOLD : length;
 803             unsafe.copyMemory(null, srcAddr, dst, offset, size);
 804             length -= size;
 805             srcAddr += size;
 806             offset += size;
 807         }
 808     }
 809 
 810     static void copyFromCharArray(Object src, long srcPos, long dstAddr,
 811                                   long length)
 812     {
 813         copyFromShortArray(src, srcPos, dstAddr, length);
 814     }
 815 
 816     static void copyToCharArray(long srcAddr, Object dst, long dstPos,
 817                                 long length)
 818     {
 819         copyToShortArray(srcAddr, dst, dstPos, length);
 820     }
 821 
 822     static native void copyFromShortArray(Object src, long srcPos, long dstAddr,
 823                                           long length);
 824     static native void copyToShortArray(long srcAddr, Object dst, long dstPos,
 825                                         long length);
 826 


 758      *
 759      * @param   src
 760      *          source array
 761      * @param   srcBaseOffset
 762      *          offset of first element of storage in source array
 763      * @param   srcPos
 764      *          offset within source array of the first element to read
 765      * @param   dstAddr
 766      *          destination address
 767      * @param   length
 768      *          number of bytes to copy
 769      */
 770     static void copyFromArray(Object src, long srcBaseOffset, long srcPos,
 771                               long dstAddr, long length)
 772     {
 773         long offset = srcBaseOffset + srcPos;
 774         while (length > 0) {
 775             long size = (length > UNSAFE_COPY_THRESHOLD) ? UNSAFE_COPY_THRESHOLD : length;
 776             unsafe.copyMemory(src, offset, null, dstAddr, size);
 777             length -= size;
 778             offset += (size << 1);
 779             dstAddr += size;
 780         }
 781     }
 782 
 783     /**
 784      * Copy from source address into given destination array.
 785      *
 786      * @param   srcAddr
 787      *          source address
 788      * @param   dst
 789      *          destination array
 790      * @param   dstBaseOffset
 791      *          offset of first element of storage in destination array
 792      * @param   dstPos
 793      *          offset within destination array of the first element to write
 794      * @param   length
 795      *          number of bytes to copy
 796      */
 797     static void copyToArray(long srcAddr, Object dst, long dstBaseOffset, long dstPos,
 798                             long length)
 799     {
 800         long offset = dstBaseOffset + dstPos;
 801         while (length > 0) {
 802             long size = (length > UNSAFE_COPY_THRESHOLD) ? UNSAFE_COPY_THRESHOLD : length;
 803             unsafe.copyMemory(null, srcAddr, dst, offset, size);
 804             length -= size;
 805             srcAddr += size;
 806             offset += (size << 1);
 807         }
 808     }
 809 
 810     static void copyFromCharArray(Object src, long srcPos, long dstAddr,
 811                                   long length)
 812     {
 813         copyFromShortArray(src, srcPos, dstAddr, length);
 814     }
 815 
 816     static void copyToCharArray(long srcAddr, Object dst, long dstPos,
 817                                 long length)
 818     {
 819         copyToShortArray(srcAddr, dst, dstPos, length);
 820     }
 821 
 822     static native void copyFromShortArray(Object src, long srcPos, long dstAddr,
 823                                           long length);
 824     static native void copyToShortArray(long srcAddr, Object dst, long dstPos,
 825                                         long length);
 826 
< prev index next >