0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
1879N/A#define CPU_SPARC_VM_BYTES_SPARC_HPP
1879N/A
1879N/A#include "memory/allocation.hpp"
1879N/A
0N/Aclass Bytes: AllStatic {
0N/A public:
0N/A // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
0N/A // Sparc needs to check for alignment.
0N/A
0N/A // can I count on address always being a pointer to an unsigned char? Yes
0N/A
0N/A // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
0N/A // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
0N/A static inline bool is_Java_byte_ordering_different() { return false; }
0N/A
0N/A // Thus, a swap between native and Java ordering is always a no-op:
0N/A static inline u2 swap_u2(u2 x) { return x; }
0N/A static inline u4 swap_u4(u4 x) { return x; }
0N/A static inline u8 swap_u8(u8 x) { return x; }
0N/A
0N/A static inline u2 get_native_u2(address p){
0N/A return (intptr_t(p) & 1) == 0
0N/A ? *(u2*)p
0N/A : ( u2(p[0]) << 8 )
0N/A | ( u2(p[1]) );
0N/A }
0N/A
0N/A static inline u4 get_native_u4(address p) {
0N/A switch (intptr_t(p) & 3) {
0N/A case 0: return *(u4*)p;
0N/A
0N/A case 2: return ( u4( ((u2*)p)[0] ) << 16 )
0N/A | ( u4( ((u2*)p)[1] ) );
0N/A
0N/A default: return ( u4(p[0]) << 24 )
0N/A | ( u4(p[1]) << 16 )
0N/A | ( u4(p[2]) << 8 )
0N/A | u4(p[3]);
0N/A }
0N/A }
0N/A
0N/A static inline u8 get_native_u8(address p) {
0N/A switch (intptr_t(p) & 7) {
0N/A case 0: return *(u8*)p;
0N/A
0N/A case 4: return ( u8( ((u4*)p)[0] ) << 32 )
0N/A | ( u8( ((u4*)p)[1] ) );
0N/A
0N/A case 2: return ( u8( ((u2*)p)[0] ) << 48 )
0N/A | ( u8( ((u2*)p)[1] ) << 32 )
0N/A | ( u8( ((u2*)p)[2] ) << 16 )
0N/A | ( u8( ((u2*)p)[3] ) );
0N/A
0N/A default: return ( u8(p[0]) << 56 )
0N/A | ( u8(p[1]) << 48 )
0N/A | ( u8(p[2]) << 40 )
0N/A | ( u8(p[3]) << 32 )
0N/A | ( u8(p[4]) << 24 )
0N/A | ( u8(p[5]) << 16 )
0N/A | ( u8(p[6]) << 8 )
0N/A | u8(p[7]);
0N/A }
0N/A }
0N/A
0N/A
0N/A
0N/A static inline void put_native_u2(address p, u2 x) {
0N/A if ( (intptr_t(p) & 1) == 0 ) *(u2*)p = x;
0N/A else {
0N/A p[0] = x >> 8;
0N/A p[1] = x;
0N/A }
0N/A }
0N/A
0N/A static inline void put_native_u4(address p, u4 x) {
0N/A switch ( intptr_t(p) & 3 ) {
0N/A case 0: *(u4*)p = x;
0N/A break;
0N/A
0N/A case 2: ((u2*)p)[0] = x >> 16;
0N/A ((u2*)p)[1] = x;
0N/A break;
0N/A
0N/A default: ((u1*)p)[0] = x >> 24;
0N/A ((u1*)p)[1] = x >> 16;
0N/A ((u1*)p)[2] = x >> 8;
0N/A ((u1*)p)[3] = x;
0N/A break;
0N/A }
0N/A }
0N/A
0N/A static inline void put_native_u8(address p, u8 x) {
0N/A switch ( intptr_t(p) & 7 ) {
0N/A case 0: *(u8*)p = x;
0N/A break;
0N/A
0N/A case 4: ((u4*)p)[0] = x >> 32;
0N/A ((u4*)p)[1] = x;
0N/A break;
0N/A
0N/A case 2: ((u2*)p)[0] = x >> 48;
0N/A ((u2*)p)[1] = x >> 32;
0N/A ((u2*)p)[2] = x >> 16;
0N/A ((u2*)p)[3] = x;
0N/A break;
0N/A
0N/A default: ((u1*)p)[0] = x >> 56;
0N/A ((u1*)p)[1] = x >> 48;
0N/A ((u1*)p)[2] = x >> 40;
0N/A ((u1*)p)[3] = x >> 32;
0N/A ((u1*)p)[4] = x >> 24;
0N/A ((u1*)p)[5] = x >> 16;
0N/A ((u1*)p)[6] = x >> 8;
0N/A ((u1*)p)[7] = x;
0N/A }
0N/A }
0N/A
0N/A
0N/A // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
0N/A // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
0N/A static inline u2 get_Java_u2(address p) { return get_native_u2(p); }
0N/A static inline u4 get_Java_u4(address p) { return get_native_u4(p); }
0N/A static inline u8 get_Java_u8(address p) { return get_native_u8(p); }
0N/A
0N/A static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, x); }
0N/A static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, x); }
0N/A static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, x); }
0N/A};
0N/A
0N/A//Reconciliation History
0N/A// 1.7 98/02/24 10:18:41 bytes_i486.hpp
0N/A// 1.10 98/04/08 18:47:57 bytes_i486.hpp
0N/A// 1.13 98/07/15 17:10:03 bytes_i486.hpp
0N/A// 1.14 98/08/13 10:38:23 bytes_i486.hpp
0N/A// 1.15 98/10/05 16:30:21 bytes_i486.hpp
0N/A// 1.17 99/06/22 16:37:35 bytes_i486.hpp
0N/A//End
1879N/A
1879N/A#endif // CPU_SPARC_VM_BYTES_SPARC_HPP