src/hotspot/share/utilities/copy.hpp
changeset 48951 950c35ea6237
parent 47216 71c04702a3d5
child 49011 a0e246b7403a
--- a/src/hotspot/share/utilities/copy.hpp	Fri Feb 09 13:09:55 2018 +0100
+++ b/src/hotspot/share/utilities/copy.hpp	Fri Feb 09 08:23:42 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,28 +31,28 @@
 
 // Assembly code for platforms that need it.
 extern "C" {
-  void _Copy_conjoint_words(HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_disjoint_words(HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_conjoint_words(const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_disjoint_words(const HeapWord* from, HeapWord* to, size_t count);
 
-  void _Copy_conjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_conjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count);
 
-  void _Copy_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count);
 
-  void _Copy_conjoint_bytes(void* from, void* to, size_t count);
+  void _Copy_conjoint_bytes(const void* from, void* to, size_t count);
 
-  void _Copy_conjoint_bytes_atomic  (void*   from, void*   to, size_t count);
-  void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count);
-  void _Copy_conjoint_jints_atomic  (jint*   from, jint*   to, size_t count);
-  void _Copy_conjoint_jlongs_atomic (jlong*  from, jlong*  to, size_t count);
-  void _Copy_conjoint_oops_atomic   (oop*    from, oop*    to, size_t count);
+  void _Copy_conjoint_bytes_atomic  (const void*   from, void*   to, size_t count);
+  void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count);
+  void _Copy_conjoint_jints_atomic  (const jint*   from, jint*   to, size_t count);
+  void _Copy_conjoint_jlongs_atomic (const jlong*  from, jlong*  to, size_t count);
+  void _Copy_conjoint_oops_atomic   (const oop*    from, oop*    to, size_t count);
 
-  void _Copy_arrayof_conjoint_bytes  (HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_arrayof_conjoint_jints  (HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_arrayof_conjoint_jlongs (HeapWord* from, HeapWord* to, size_t count);
-  void _Copy_arrayof_conjoint_oops   (HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_arrayof_conjoint_bytes  (const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_arrayof_conjoint_jints  (const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_arrayof_conjoint_jlongs (const HeapWord* from, HeapWord* to, size_t count);
+  void _Copy_arrayof_conjoint_oops   (const HeapWord* from, HeapWord* to, size_t count);
 }
 
 class Copy : AllStatic {
@@ -87,33 +87,33 @@
   // HeapWords
 
   // Word-aligned words,    conjoint, not atomic on each word
-  static void conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  static void conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogHeapWordSize);
     pd_conjoint_words(from, to, count);
   }
 
   // Word-aligned words,    disjoint, not atomic on each word
-  static void disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  static void disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogHeapWordSize);
     assert_disjoint(from, to, count);
     pd_disjoint_words(from, to, count);
   }
 
   // Word-aligned words,    disjoint, atomic on each word
-  static void disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
+  static void disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogHeapWordSize);
     assert_disjoint(from, to, count);
     pd_disjoint_words_atomic(from, to, count);
   }
 
   // Object-aligned words,  conjoint, not atomic on each word
-  static void aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  static void aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_aligned(from, to);
     pd_aligned_conjoint_words(from, to, count);
   }
 
   // Object-aligned words,  disjoint, not atomic on each word
-  static void aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  static void aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_aligned(from, to);
     assert_disjoint(from, to, count);
     pd_aligned_disjoint_words(from, to, count);
@@ -122,77 +122,77 @@
   // bytes, jshorts, jints, jlongs, oops
 
   // bytes,                 conjoint, not atomic on each byte (not that it matters)
-  static void conjoint_jbytes(void* from, void* to, size_t count) {
+  static void conjoint_jbytes(const void* from, void* to, size_t count) {
     pd_conjoint_bytes(from, to, count);
   }
 
   // bytes,                 conjoint, atomic on each byte (not that it matters)
-  static void conjoint_jbytes_atomic(void* from, void* to, size_t count) {
+  static void conjoint_jbytes_atomic(const void* from, void* to, size_t count) {
     pd_conjoint_bytes(from, to, count);
   }
 
   // jshorts,               conjoint, atomic on each jshort
-  static void conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
+  static void conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerShort);
     pd_conjoint_jshorts_atomic(from, to, count);
   }
 
   // jints,                 conjoint, atomic on each jint
-  static void conjoint_jints_atomic(jint* from, jint* to, size_t count) {
+  static void conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerInt);
     pd_conjoint_jints_atomic(from, to, count);
   }
 
   // jlongs,                conjoint, atomic on each jlong
-  static void conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
+  static void conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerLong);
     pd_conjoint_jlongs_atomic(from, to, count);
   }
 
   // oops,                  conjoint, atomic on each oop
-  static void conjoint_oops_atomic(oop* from, oop* to, size_t count) {
+  static void conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerHeapOop);
     pd_conjoint_oops_atomic(from, to, count);
   }
 
   // overloaded for UseCompressedOops
-  static void conjoint_oops_atomic(narrowOop* from, narrowOop* to, size_t count) {
+  static void conjoint_oops_atomic(const narrowOop* from, narrowOop* to, size_t count) {
     assert(sizeof(narrowOop) == sizeof(jint), "this cast is wrong");
     assert_params_ok(from, to, LogBytesPerInt);
-    pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
+    pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count);
   }
 
   // Copy a span of memory.  If the span is an integral number of aligned
   // longs, words, or ints, copy those units atomically.
   // The largest atomic transfer unit is 8 bytes, or the largest power
   // of two which divides all of from, to, and size, whichever is smaller.
-  static void conjoint_memory_atomic(void* from, void* to, size_t size);
+  static void conjoint_memory_atomic(const void* from, void* to, size_t size);
 
   // bytes,                 conjoint array, atomic on each byte (not that it matters)
-  static void arrayof_conjoint_jbytes(HeapWord* from, HeapWord* to, size_t count) {
+  static void arrayof_conjoint_jbytes(const HeapWord* from, HeapWord* to, size_t count) {
     pd_arrayof_conjoint_bytes(from, to, count);
   }
 
   // jshorts,               conjoint array, atomic on each jshort
-  static void arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
+  static void arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerShort);
     pd_arrayof_conjoint_jshorts(from, to, count);
   }
 
   // jints,                 conjoint array, atomic on each jint
-  static void arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
+  static void arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerInt);
     pd_arrayof_conjoint_jints(from, to, count);
   }
 
   // jlongs,                conjoint array, atomic on each jlong
-  static void arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
+  static void arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerLong);
     pd_arrayof_conjoint_jlongs(from, to, count);
   }
 
   // oops,                  conjoint array, atomic on each oop
-  static void arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
+  static void arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
     assert_params_ok(from, to, LogBytesPerHeapOop);
     pd_arrayof_conjoint_oops(from, to, count);
   }
@@ -200,7 +200,7 @@
   // Known overlap methods
 
   // Copy word-aligned words from higher to lower addresses, not atomic on each word
-  inline static void conjoint_words_to_lower(HeapWord* from, HeapWord* to, size_t byte_count) {
+  inline static void conjoint_words_to_lower(const HeapWord* from, HeapWord* to, size_t byte_count) {
     // byte_count is in bytes to check its alignment
     assert_params_ok(from, to, LogHeapWordSize);
     assert_byte_count_ok(byte_count, HeapWordSize);
@@ -214,7 +214,7 @@
   }
 
   // Copy word-aligned words from lower to higher addresses, not atomic on each word
-  inline static void conjoint_words_to_higher(HeapWord* from, HeapWord* to, size_t byte_count) {
+  inline static void conjoint_words_to_higher(const HeapWord* from, HeapWord* to, size_t byte_count) {
     // byte_count is in bytes to check its alignment
     assert_params_ok(from, to, LogHeapWordSize);
     assert_byte_count_ok(byte_count, HeapWordSize);
@@ -305,7 +305,7 @@
   }
 
  private:
-  static bool params_disjoint(HeapWord* from, HeapWord* to, size_t count) {
+  static bool params_disjoint(const HeapWord* from, HeapWord* to, size_t count) {
     if (from < to) {
       return pointer_delta(to, from) >= count;
     }
@@ -314,14 +314,14 @@
 
   // These methods raise a fatal if they detect a problem.
 
-  static void assert_disjoint(HeapWord* from, HeapWord* to, size_t count) {
+  static void assert_disjoint(const HeapWord* from, HeapWord* to, size_t count) {
 #ifdef ASSERT
     if (!params_disjoint(from, to, count))
       basic_fatal("source and dest overlap");
 #endif
   }
 
-  static void assert_params_ok(void* from, void* to, intptr_t log_align) {
+  static void assert_params_ok(const void* from, void* to, intptr_t log_align) {
 #ifdef ASSERT
     if (mask_bits((uintptr_t)from, right_n_bits(log_align)) != 0)
       basic_fatal("not aligned");
@@ -336,7 +336,7 @@
       basic_fatal("not word aligned");
 #endif
   }
-  static void assert_params_aligned(HeapWord* from, HeapWord* to) {
+  static void assert_params_aligned(const HeapWord* from, HeapWord* to) {
 #ifdef ASSERT
     if (mask_bits((uintptr_t)from, BytesPerLong-1) != 0)
       basic_fatal("not long aligned");