Last active
December 19, 2015 13:59
-
-
Save lichenbo/5965735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void pd_conjoint_bytes(void* from, void* to, size_t count) { | |
| #ifdef AMD64 | |
| (void)memmove(to, from, count); | |
| #else | |
| // Includes a zero-count check. | |
| intx temp; | |
| __asm__ volatile(" testl %6,%6 ;" | |
| ... Assembly here ... | |
| ); | |
| #endif // AMD64 | |
| } | |
| static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { | |
| pd_conjoint_bytes(from, to, count); | |
| } | |
| static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { | |
| _Copy_conjoint_jshorts_atomic(from, to, count); | |
| } | |
| static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) { | |
| #ifdef AMD64 | |
| _Copy_conjoint_jints_atomic(from, to, count); | |
| #else | |
| assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size"); | |
| // pd_conjoint_words is word-atomic in this implementation. | |
| pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count); | |
| #endif // AMD64 | |
| } | |
| static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { | |
| #ifdef AMD64 | |
| _Copy_conjoint_jlongs_atomic(from, to, count); | |
| #else | |
| // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't. | |
| if (from > to) { | |
| while (count-- > 0) { | |
| __asm__ volatile("fildll (%0); fistpll (%1)" | |
| : | |
| : "r" (from), "r" (to) | |
| : "memory" ); | |
| ++from; | |
| ++to; | |
| } | |
| } else { | |
| while (count-- > 0) { | |
| __asm__ volatile("fildll (%0,%2,8); fistpll (%1,%2,8)" | |
| : | |
| : "r" (from), "r" (to), "r" (count) | |
| : "memory" ); | |
| } | |
| } | |
| #endif // AMD64 | |
| } | |
| static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) { | |
| #ifdef AMD64 | |
| assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); | |
| _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); | |
| #else | |
| assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size"); | |
| // pd_conjoint_words is word-atomic in this implementation. | |
| pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count); | |
| #endif // AMD64 | |
| } | |
| static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) { | |
| _Copy_arrayof_conjoint_bytes(from, to, count); | |
| } | |
| static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) { | |
| _Copy_arrayof_conjoint_jshorts(from, to, count); | |
| } | |
| static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) { | |
| #ifdef AMD64 | |
| _Copy_arrayof_conjoint_jints(from, to, count); | |
| #else | |
| pd_conjoint_jints_atomic((jint*)from, (jint*)to, count); | |
| #endif // AMD64 | |
| } | |
| static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) { | |
| #ifdef AMD64 | |
| _Copy_arrayof_conjoint_jlongs(from, to, count); | |
| #else | |
| pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); | |
| #endif // AMD64 | |
| } | |
| static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) { | |
| #ifdef AMD64 | |
| assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); | |
| _Copy_arrayof_conjoint_jlongs(from, to, count); | |
| #else | |
| pd_conjoint_oops_atomic((oop*)from, (oop*)to, count); | |
| #endif // AMD64 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment