src/share/vm/utilities/copy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/utilities

src/share/vm/utilities/copy.hpp

Print this page
rev 10065 : imported patch unsafecopyswap
rev 10066 : imported patch unsafecopyswap2
   1 /*
   2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 209     while (count-- > 0) {
 210       *to++ = *from++;
 211     }
 212   }
 213 
 214   // Copy word-aligned words from lower to higher addresses, not atomic on each word
 215   inline static void conjoint_words_to_higher(HeapWord* from, HeapWord* to, size_t byte_count) {
 216     // byte_count is in bytes to check its alignment
 217     assert_params_ok(from, to, LogHeapWordSize);
 218     assert_byte_count_ok(byte_count, HeapWordSize);
 219 
 220     size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize;
 221     assert(from <= to || to + count <= from, "do not overwrite source data");
 222 
 223     from += count - 1;
 224     to   += count - 1;
 225     while (count-- > 0) {
 226       *to-- = *from--;
 227     }
 228   }










 229 
 230   // Fill methods
 231 
 232   // Fill word-aligned words, not atomic on each word
 233   // set_words
 234   static void fill_to_words(HeapWord* to, size_t count, juint value = 0) {
 235     assert_params_ok(to, LogHeapWordSize);
 236     pd_fill_to_words(to, count, value);
 237   }
 238 
 239   static void fill_to_aligned_words(HeapWord* to, size_t count, juint value = 0) {
 240     assert_params_aligned(to);
 241     pd_fill_to_aligned_words(to, count, value);
 242   }
 243 
 244   // Fill bytes
 245   static void fill_to_bytes(void* to, size_t count, jubyte value = 0) {
 246     pd_fill_to_bytes(to, count, value);
 247   }
 248 


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 209     while (count-- > 0) {
 210       *to++ = *from++;
 211     }
 212   }
 213 
 214   // Copy word-aligned words from lower to higher addresses, not atomic on each word
 215   inline static void conjoint_words_to_higher(HeapWord* from, HeapWord* to, size_t byte_count) {
 216     // byte_count is in bytes to check its alignment
 217     assert_params_ok(from, to, LogHeapWordSize);
 218     assert_byte_count_ok(byte_count, HeapWordSize);
 219 
 220     size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize;
 221     assert(from <= to || to + count <= from, "do not overwrite source data");
 222 
 223     from += count - 1;
 224     to   += count - 1;
 225     while (count-- > 0) {
 226       *to-- = *from--;
 227     }
 228   }
 229 
 230   /**
 231    * Copy and *unconditionally* byte swap elements
 232    *
 233    * @param src address of source
 234    * @param dst address of destination
 235    * @param byte_count number of bytes to copy
 236    * @param elem_size size of the elements to copy-swap
 237    */
 238   static void conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size);
 239 
 240   // Fill methods
 241 
 242   // Fill word-aligned words, not atomic on each word
 243   // set_words
 244   static void fill_to_words(HeapWord* to, size_t count, juint value = 0) {
 245     assert_params_ok(to, LogHeapWordSize);
 246     pd_fill_to_words(to, count, value);
 247   }
 248 
 249   static void fill_to_aligned_words(HeapWord* to, size_t count, juint value = 0) {
 250     assert_params_aligned(to);
 251     pd_fill_to_aligned_words(to, count, value);
 252   }
 253 
 254   // Fill bytes
 255   static void fill_to_bytes(void* to, size_t count, jubyte value = 0) {
 256     pd_fill_to_bytes(to, count, value);
 257   }
 258 


src/share/vm/utilities/copy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File