hotspot/src/share/vm/utilities/copy.cpp
changeset 46619 a3919f5e8d2b
parent 46504 38048d4d20e7
child 46625 edefffab74e2
equal deleted inserted replaced
46618:d503911aa948 46619:a3919f5e8d2b
    69   static void conjoint_swap_if_needed(const void* src, void* dst, size_t byte_count, size_t elem_size) {
    69   static void conjoint_swap_if_needed(const void* src, void* dst, size_t byte_count, size_t elem_size) {
    70     assert(src != NULL, "address must not be NULL");
    70     assert(src != NULL, "address must not be NULL");
    71     assert(dst != NULL, "address must not be NULL");
    71     assert(dst != NULL, "address must not be NULL");
    72     assert(elem_size == 2 || elem_size == 4 || elem_size == 8,
    72     assert(elem_size == 2 || elem_size == 4 || elem_size == 8,
    73            "incorrect element size: " SIZE_FORMAT, elem_size);
    73            "incorrect element size: " SIZE_FORMAT, elem_size);
    74     assert(is_size_aligned(byte_count, elem_size),
    74     assert(is_aligned(byte_count, elem_size),
    75            "byte_count " SIZE_FORMAT " must be multiple of element size " SIZE_FORMAT, byte_count, elem_size);
    75            "byte_count " SIZE_FORMAT " must be multiple of element size " SIZE_FORMAT, byte_count, elem_size);
    76 
    76 
    77     address src_end = (address)src + byte_count;
    77     address src_end = (address)src + byte_count;
    78 
    78 
    79     if (dst <= src || dst >= src_end) {
    79     if (dst <= src || dst >= src_end) {
   187    * @param dst address of destination
   187    * @param dst address of destination
   188    * @param byte_count number of bytes to copy
   188    * @param byte_count number of bytes to copy
   189    */
   189    */
   190   template <typename T, CopyDirection direction, bool swap>
   190   template <typename T, CopyDirection direction, bool swap>
   191   static void do_conjoint_swap(const void* src, void* dst, size_t byte_count) {
   191   static void do_conjoint_swap(const void* src, void* dst, size_t byte_count) {
   192     if (is_ptr_aligned(src, sizeof(T))) {
   192     if (is_aligned(src, sizeof(T))) {
   193       if (is_ptr_aligned(dst, sizeof(T))) {
   193       if (is_aligned(dst, sizeof(T))) {
   194         do_conjoint_swap<T,direction,swap,true,true>(src, dst, byte_count);
   194         do_conjoint_swap<T,direction,swap,true,true>(src, dst, byte_count);
   195       } else {
   195       } else {
   196         do_conjoint_swap<T,direction,swap,true,false>(src, dst, byte_count);
   196         do_conjoint_swap<T,direction,swap,true,false>(src, dst, byte_count);
   197       }
   197       }
   198     } else {
   198     } else {
   199       if (is_ptr_aligned(dst, sizeof(T))) {
   199       if (is_aligned(dst, sizeof(T))) {
   200         do_conjoint_swap<T,direction,swap,false,true>(src, dst, byte_count);
   200         do_conjoint_swap<T,direction,swap,false,true>(src, dst, byte_count);
   201       } else {
   201       } else {
   202         do_conjoint_swap<T,direction,swap,false,false>(src, dst, byte_count);
   202         do_conjoint_swap<T,direction,swap,false,false>(src, dst, byte_count);
   203       }
   203       }
   204     }
   204     }