1 /* |
1 /* |
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 #ifndef CPU_SPARC_VM_COPY_SPARC_HPP |
25 #ifndef CPU_SPARC_VM_COPY_SPARC_HPP |
26 #define CPU_SPARC_VM_COPY_SPARC_HPP |
26 #define CPU_SPARC_VM_COPY_SPARC_HPP |
27 |
27 |
28 // Inline functions for memory copy and fill. |
28 // Inline functions for memory copy and fill. |
29 |
29 |
30 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { |
30 static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) { |
31 (void)memmove(to, from, count * HeapWordSize); |
31 (void)memmove(to, from, count * HeapWordSize); |
32 } |
32 } |
33 |
33 |
34 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { |
34 static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) { |
35 switch (count) { |
35 switch (count) { |
36 case 8: to[7] = from[7]; |
36 case 8: to[7] = from[7]; |
37 case 7: to[6] = from[6]; |
37 case 7: to[6] = from[6]; |
38 case 6: to[5] = from[5]; |
38 case 6: to[5] = from[5]; |
39 case 5: to[4] = from[4]; |
39 case 5: to[4] = from[4]; |
45 default: (void)memcpy(to, from, count * HeapWordSize); |
45 default: (void)memcpy(to, from, count * HeapWordSize); |
46 break; |
46 break; |
47 } |
47 } |
48 } |
48 } |
49 |
49 |
50 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) { |
50 static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) { |
51 switch (count) { |
51 switch (count) { |
52 case 8: to[7] = from[7]; |
52 case 8: to[7] = from[7]; |
53 case 7: to[6] = from[6]; |
53 case 7: to[6] = from[6]; |
54 case 6: to[5] = from[5]; |
54 case 6: to[5] = from[5]; |
55 case 5: to[4] = from[4]; |
55 case 5: to[4] = from[4]; |
63 } |
63 } |
64 break; |
64 break; |
65 } |
65 } |
66 } |
66 } |
67 |
67 |
68 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { |
68 static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) { |
69 (void)memmove(to, from, count * HeapWordSize); |
69 (void)memmove(to, from, count * HeapWordSize); |
70 } |
70 } |
71 |
71 |
72 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { |
72 static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) { |
73 pd_disjoint_words(from, to, count); |
73 pd_disjoint_words(from, to, count); |
74 } |
74 } |
75 |
75 |
76 static void pd_conjoint_bytes(void* from, void* to, size_t count) { |
76 static void pd_conjoint_bytes(const void* from, void* to, size_t count) { |
77 (void)memmove(to, from, count); |
77 (void)memmove(to, from, count); |
78 } |
78 } |
79 |
79 |
80 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { |
80 static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) { |
81 (void)memmove(to, from, count); |
81 (void)memmove(to, from, count); |
82 } |
82 } |
83 |
83 |
84 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { |
84 static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) { |
85 if (from > to) { |
85 if (from > to) { |
86 while (count-- > 0) { |
86 while (count-- > 0) { |
87 // Copy forwards |
87 // Copy forwards |
88 *to++ = *from++; |
88 *to++ = *from++; |
89 } |
89 } |
111 *to-- = *from--; |
111 *to-- = *from--; |
112 } |
112 } |
113 } |
113 } |
114 } |
114 } |
115 |
115 |
116 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { |
116 static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) { |
117 assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); |
117 assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); |
118 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count); |
118 pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count); |
119 } |
119 } |
120 |
120 |
121 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) { |
121 static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) { |
122 // Do better than this: inline memmove body NEEDS CLEANUP |
122 // Do better than this: inline memmove body NEEDS CLEANUP |
123 if (from > to) { |
123 if (from > to) { |
124 while (count-- > 0) { |
124 while (count-- > 0) { |
125 // Copy forwards |
125 // Copy forwards |
126 *to++ = *from++; |
126 *to++ = *from++; |
133 *to-- = *from--; |
133 *to-- = *from--; |
134 } |
134 } |
135 } |
135 } |
136 } |
136 } |
137 |
137 |
138 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) { |
138 static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) { |
139 pd_conjoint_bytes_atomic(from, to, count); |
139 pd_conjoint_bytes_atomic(from, to, count); |
140 } |
140 } |
141 |
141 |
142 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) { |
142 static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) { |
143 pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count); |
143 pd_conjoint_jshorts_atomic((const jshort*)from, (jshort*)to, count); |
144 } |
144 } |
145 |
145 |
146 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) { |
146 static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) { |
147 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count); |
147 pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count); |
148 } |
148 } |
149 |
149 |
150 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) { |
150 static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) { |
151 pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); |
151 pd_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count); |
152 } |
152 } |
153 |
153 |
154 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) { |
154 static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) { |
155 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count); |
155 pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count); |
156 } |
156 } |
157 |
157 |
158 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { |
158 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { |
159 guarantee(mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0, |
159 guarantee(mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0, |
160 "unaligned fill words"); |
160 "unaligned fill words"); |