17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
26 #define CPU_SPARC_VM_BYTES_SPARC_HPP
27
28 #include "memory/allocation.hpp"
29
30 class Bytes: AllStatic {
31 public:
32 // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
33 // Sparc needs to check for alignment.
34
35 // can I count on address always being a pointer to an unsigned char? Yes
36
37 // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
38 // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
39 static inline bool is_Java_byte_ordering_different() { return false; }
40
41 // Thus, a swap between native and Java ordering is always a no-op:
42 static inline u2 swap_u2(u2 x) { return x; }
43 static inline u4 swap_u4(u4 x) { return x; }
44 static inline u8 swap_u8(u8 x) { return x; }
45
46 static inline u2 get_native_u2(address p){
47 return (intptr_t(p) & 1) == 0
48 ? *(u2*)p
49 : ( u2(p[0]) << 8 )
50 | ( u2(p[1]) );
51 }
52
53 static inline u4 get_native_u4(address p) {
54 switch (intptr_t(p) & 3) {
55 case 0: return *(u4*)p;
56
57 case 2: return ( u4( ((u2*)p)[0] ) << 16 )
58 | ( u4( ((u2*)p)[1] ) );
59
60 default: return ( u4(p[0]) << 24 )
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
26 #define CPU_SPARC_VM_BYTES_SPARC_HPP
27
28 #include "memory/allocation.hpp"
29
30 class Bytes: AllStatic {
31 public:
32 // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
33 // Sparc needs to check for alignment.
34
35 // can I count on address always being a pointer to an unsigned char? Yes
36
37 // Thus, a swap between native and Java ordering is always a no-op:
38 static inline u2 swap_u2(u2 x) { return x; }
39 static inline u4 swap_u4(u4 x) { return x; }
40 static inline u8 swap_u8(u8 x) { return x; }
41
42 static inline u2 get_native_u2(address p){
43 return (intptr_t(p) & 1) == 0
44 ? *(u2*)p
45 : ( u2(p[0]) << 8 )
46 | ( u2(p[1]) );
47 }
48
49 static inline u4 get_native_u4(address p) {
50 switch (intptr_t(p) & 3) {
51 case 0: return *(u4*)p;
52
53 case 2: return ( u4( ((u2*)p)[0] ) << 16 )
54 | ( u4( ((u2*)p)[1] ) );
55
56 default: return ( u4(p[0]) << 24 )
|