// Assembly code for platforms that need it.
extern "C" { 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_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 (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);
}
class Copy : AllStatic { public: // Block copy methods have four attributes. We don't define all possibilities. // alignment: aligned to BytesPerLong // arrayof: arraycopy operation with both operands aligned on the same // boundary as the first element of an array of the copy unit. // This is currently a HeapWord boundary on all platforms, except // for long and double arrays, which are aligned on an 8-byte // boundary on all platforms. // arraycopy operations are implicitly atomic on each array element. // overlap: disjoint or conjoint. // copy unit: bytes or words (i.e., HeapWords) or oops (i.e., pointers). // atomicity: atomic or non-atomic on the copy unit. // // Names are constructed thusly: // // [ 'aligned_' | 'arrayof_' ] // ('conjoint_' | 'disjoint_') // ('words' | 'bytes' | 'jshorts' | 'jints' | 'jlongs' | 'oops') // [ '_atomic' ] // // Except in the arrayof case, whatever the alignment is, we assume we can copy // whole alignment units. E.g., if BytesPerLong is 2x word alignment, an odd // count may copy an extra word. In the arrayof case, we are allowed to copy // only the number of copy units specified. // // All callees check count for 0. //
// HeapWords
// Word-aligned words, conjoint, not atomic on each word staticvoid conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, HeapWordSize);
pd_conjoint_words(from, to, count);
}
// Word-aligned words, disjoint, not atomic on each word staticvoid disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, HeapWordSize);
assert_disjoint(from, to, count);
pd_disjoint_words(from, to, count);
}
// Word-aligned words, disjoint, atomic on each word staticvoid disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, HeapWordSize);
assert_disjoint(from, to, count);
pd_disjoint_words_atomic(from, to, count);
}
// Object-aligned words, conjoint, not atomic on each word staticvoid 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 staticvoid 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);
}
// bytes, jshorts, jints, jlongs, oops
// bytes, conjoint, not atomic on each byte (not that it matters) staticvoid conjoint_jbytes(constvoid* from, void* to, size_t count) {
pd_conjoint_bytes(from, to, count);
}
// bytes, conjoint, atomic on each byte (not that it matters) staticvoid conjoint_jbytes_atomic(constvoid* from, void* to, size_t count) {
pd_conjoint_bytes(from, to, count);
}
// jshorts, conjoint, atomic on each jshort staticvoid conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
assert_params_ok(from, to, BytesPerShort);
pd_conjoint_jshorts_atomic(from, to, count);
}
// jints, conjoint, atomic on each jint staticvoid conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
assert_params_ok(from, to, BytesPerInt);
pd_conjoint_jints_atomic(from, to, count);
}
// jlongs, conjoint, atomic on each jlong staticvoid conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
assert_params_ok(from, to, BytesPerLong);
pd_conjoint_jlongs_atomic(from, to, count);
}
// oops, conjoint, atomic on each oop staticvoid conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
assert_params_ok(from, to, BytesPerHeapOop);
pd_conjoint_oops_atomic(from, to, count);
}
// overloaded for UseCompressedOops staticvoid 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, BytesPerInt);
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. staticvoid conjoint_memory_atomic(constvoid* from, void* to, size_t size);
// bytes, conjoint array, atomic on each byte (not that it matters) staticvoid 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 staticvoid arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, BytesPerShort);
pd_arrayof_conjoint_jshorts(from, to, count);
}
// jints, conjoint array, atomic on each jint staticvoid arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, BytesPerInt);
pd_arrayof_conjoint_jints(from, to, count);
}
// jlongs, conjoint array, atomic on each jlong staticvoid arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, BytesPerLong);
pd_arrayof_conjoint_jlongs(from, to, count);
}
// oops, conjoint array, atomic on each oop staticvoid arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
assert_params_ok(from, to, BytesPerHeapOop);
pd_arrayof_conjoint_oops(from, to, count);
}
// Known overlap methods
// Copy word-aligned words from higher to lower addresses, not atomic on each word
inline staticvoid 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, HeapWordSize);
assert_byte_count_ok(byte_count, HeapWordSize);
size_t count = align_up(byte_count, HeapWordSize) >> LogHeapWordSize;
assert(to <= from || from + count <= to, "do not overwrite source data");
while (count-- > 0) {
*to++ = *from++;
}
}
// Copy word-aligned words from lower to higher addresses, not atomic on each word
inline staticvoid 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, HeapWordSize);
assert_byte_count_ok(byte_count, HeapWordSize);
size_t count = align_up(byte_count, HeapWordSize) >> LogHeapWordSize;
assert(from <= to || to + count <= from, "do not overwrite source data");
from += count - 1;
to += count - 1; while (count-- > 0) {
*to-- = *from--;
}
}
// Fill word-aligned words, not atomic on each word // set_words staticvoid fill_to_words(HeapWord* to, size_t count, juint value = 0) {
assert_params_ok(to, HeapWordSize);
pd_fill_to_words(to, count, value);
}
staticvoid fill_to_aligned_words(HeapWord* to, size_t count, juint value = 0) {
assert_params_aligned(to);
pd_fill_to_aligned_words(to, count, value);
}
// Fill bytes staticvoid fill_to_bytes(void* to, size_t count, jubyte value = 0) {
pd_fill_to_bytes(to, count, value);
}
// Fill a span of memory. If the span is an integral number of aligned // longs, words, or ints, store to those units atomically. // The largest atomic transfer unit is 8 bytes, or the largest power // of two which divides both to and size, whichever is smaller. staticvoid fill_to_memory_atomic(void* to, size_t size, jubyte value = 0);
// Zero-fill methods
// Zero word-aligned words, not atomic on each word staticvoid zero_to_words(HeapWord* to, size_t count) {
assert_params_ok(to, HeapWordSize);
pd_zero_to_words(to, count);
}
// Zero bytes staticvoid zero_to_bytes(void* to, size_t count) {
pd_zero_to_bytes(to, count);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.