--- old/src/share/vm/utilities/copy.cpp Wed Jun 9 10:46:11 2010 +++ new/src/share/vm/utilities/copy.cpp Wed Jun 9 10:46:11 2010 @@ -28,6 +28,7 @@ // Copy bytes; larger units are filled atomically if everything is aligned. void Copy::conjoint_memory_atomic(void* from, void* to, size_t size) { + if (size == 0) return; address src = (address) from; address dst = (address) to; uintptr_t bits = (uintptr_t) src | (uintptr_t) dst | (uintptr_t) size; @@ -55,6 +56,7 @@ // Fill bytes; larger units are filled atomically if everything is aligned. void Copy::fill_to_memory_atomic(void* to, size_t size, jubyte value) { + if (size == 0) return; address dst = (address) to; uintptr_t bits = (uintptr_t) to | (uintptr_t) size; if (bits % sizeof(jlong) == 0) { --- old/src/share/vm/utilities/copy.hpp Wed Jun 9 10:46:11 2010 +++ new/src/share/vm/utilities/copy.hpp Wed Jun 9 10:46:11 2010 @@ -79,6 +79,7 @@ // Word-aligned words, conjoint, not atomic on each word static void conjoint_words(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogHeapWordSize); + if (count == 0) return; pd_conjoint_words(from, to, count); } @@ -86,6 +87,7 @@ static void disjoint_words(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogHeapWordSize); assert_disjoint(from, to, count); + if (count == 0) return; pd_disjoint_words(from, to, count); } @@ -93,6 +95,7 @@ static void disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogHeapWordSize); assert_disjoint(from, to, count); + if (count == 0) return; pd_disjoint_words_atomic(from, to, count); } @@ -99,7 +102,7 @@ // Object-aligned words, conjoint, not atomic on each word static void aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { assert_params_aligned(from, to); - assert_non_zero(count); + if (count == 0) return; pd_aligned_conjoint_words(from, to, count); } @@ -107,7 +110,7 @@ static void aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { assert_params_aligned(from, to); assert_disjoint(from, to, count); - assert_non_zero(count); + if (count == 0) return; pd_aligned_disjoint_words(from, to, count); } @@ -115,13 +118,13 @@ // bytes, conjoint, not atomic on each byte (not that it matters) static void conjoint_bytes(void* from, void* to, size_t count) { - assert_non_zero(count); + if (count == 0) return; pd_conjoint_bytes(from, to, count); } // bytes, conjoint, atomic on each byte (not that it matters) static void conjoint_bytes_atomic(void* from, void* to, size_t count) { - assert_non_zero(count); + if (count == 0) return; pd_conjoint_bytes(from, to, count); } @@ -128,7 +131,7 @@ // jshorts, conjoint, atomic on each jshort static void conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { assert_params_ok(from, to, LogBytesPerShort); - assert_non_zero(count); + if (count == 0) return; pd_conjoint_jshorts_atomic(from, to, count); } @@ -135,7 +138,7 @@ // jints, conjoint, atomic on each jint static void conjoint_jints_atomic(jint* from, jint* to, size_t count) { assert_params_ok(from, to, LogBytesPerInt); - assert_non_zero(count); + if (count == 0) return; pd_conjoint_jints_atomic(from, to, count); } @@ -142,7 +145,7 @@ // jlongs, conjoint, atomic on each jlong static void conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { assert_params_ok(from, to, LogBytesPerLong); - assert_non_zero(count); + if (count == 0) return; pd_conjoint_jlongs_atomic(from, to, count); } @@ -149,7 +152,7 @@ // oops, conjoint, atomic on each oop static void conjoint_oops_atomic(oop* from, oop* to, size_t count) { assert_params_ok(from, to, LogBytesPerHeapOop); - assert_non_zero(count); + if (count == 0) return; pd_conjoint_oops_atomic(from, to, count); } @@ -157,7 +160,7 @@ static void conjoint_oops_atomic(narrowOop* from, narrowOop* to, size_t count) { assert(sizeof(narrowOop) == sizeof(jint), "this cast is wrong"); assert_params_ok(from, to, LogBytesPerInt); - assert_non_zero(count); + if (count == 0) return; pd_conjoint_jints_atomic((jint*)from, (jint*)to, count); } @@ -169,7 +172,7 @@ // bytes, conjoint array, atomic on each byte (not that it matters) static void arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) { - assert_non_zero(count); + if (count == 0) return; pd_arrayof_conjoint_bytes(from, to, count); } @@ -176,7 +179,7 @@ // jshorts, conjoint array, atomic on each jshort static void arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogBytesPerShort); - assert_non_zero(count); + if (count == 0) return; pd_arrayof_conjoint_jshorts(from, to, count); } @@ -183,7 +186,7 @@ // jints, conjoint array, atomic on each jint static void arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogBytesPerInt); - assert_non_zero(count); + if (count == 0) return; pd_arrayof_conjoint_jints(from, to, count); } @@ -190,7 +193,7 @@ // jlongs, conjoint array, atomic on each jlong static void arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogBytesPerLong); - assert_non_zero(count); + if (count == 0) return; pd_arrayof_conjoint_jlongs(from, to, count); } @@ -197,7 +200,7 @@ // oops, conjoint array, atomic on each oop static void arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) { assert_params_ok(from, to, LogBytesPerHeapOop); - assert_non_zero(count); + if (count == 0) return; pd_arrayof_conjoint_oops(from, to, count); } @@ -207,6 +210,7 @@ inline static void conjoint_words_to_lower(HeapWord* from, HeapWord* to, size_t byte_count) { // byte_count is in bytes to check its alignment assert_params_ok(from, to, LogHeapWordSize); + if (byte_count == 0) return; assert_byte_count_ok(byte_count, HeapWordSize); size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize; @@ -221,6 +225,7 @@ inline static void conjoint_words_to_higher(HeapWord* from, HeapWord* to, size_t byte_count) { // byte_count is in bytes to check its alignment assert_params_ok(from, to, LogHeapWordSize); + if (byte_count == 0) return; assert_byte_count_ok(byte_count, HeapWordSize); size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize; @@ -239,16 +244,19 @@ // set_words static void fill_to_words(HeapWord* to, size_t count, juint value = 0) { assert_params_ok(to, LogHeapWordSize); + if (count == 0) return; pd_fill_to_words(to, count, value); } static void fill_to_aligned_words(HeapWord* to, size_t count, juint value = 0) { assert_params_aligned(to); + if (count == 0) return; pd_fill_to_aligned_words(to, count, value); } // Fill bytes static void fill_to_bytes(void* to, size_t count, jubyte value = 0) { + if (count == 0) return; pd_fill_to_bytes(to, count, value); } @@ -263,11 +271,13 @@ // Zero word-aligned words, not atomic on each word static void zero_to_words(HeapWord* to, size_t count) { assert_params_ok(to, LogHeapWordSize); + if (count == 0) return; pd_zero_to_words(to, count); } // Zero bytes static void zero_to_bytes(void* to, size_t count) { + if (count == 0) return; pd_zero_to_bytes(to, count); } @@ -318,14 +328,6 @@ basic_fatal("not long aligned"); #endif } - - static void assert_non_zero(size_t count) { -#ifdef ASSERT - if (count == 0) { - basic_fatal("count must be non-zero"); - } -#endif - } static void assert_byte_count_ok(size_t byte_count, size_t unit_size) { #ifdef ASSERT