Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/bytes_sparc.hpp
32285 views
/*1* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef CPU_SPARC_VM_BYTES_SPARC_HPP25#define CPU_SPARC_VM_BYTES_SPARC_HPP2627#include "memory/allocation.hpp"2829class Bytes: AllStatic {30public:31// Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering32// Sparc needs to check for alignment.3334// can I count on address always being a pointer to an unsigned char? Yes3536// Returns true, if the byte ordering used by Java is different from the nativ byte ordering37// of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.38static inline bool is_Java_byte_ordering_different() { return false; }3940// Thus, a swap between native and Java ordering is always a no-op:41static inline u2 swap_u2(u2 x) { return x; }42static inline u4 swap_u4(u4 x) { return x; }43static inline u8 swap_u8(u8 x) { return x; }4445static inline u2 get_native_u2(address p){46return (intptr_t(p) & 1) == 047? *(u2*)p48: ( u2(p[0]) << 8 )49| ( u2(p[1]) );50}5152static inline u4 get_native_u4(address p) {53switch (intptr_t(p) & 3) {54case 0: return *(u4*)p;5556case 2: return ( u4( ((u2*)p)[0] ) << 16 )57| ( u4( ((u2*)p)[1] ) );5859default: return ( u4(p[0]) << 24 )60| ( u4(p[1]) << 16 )61| ( u4(p[2]) << 8 )62| u4(p[3]);63}64}6566static inline u8 get_native_u8(address p) {67switch (intptr_t(p) & 7) {68case 0: return *(u8*)p;6970case 4: return ( u8( ((u4*)p)[0] ) << 32 )71| ( u8( ((u4*)p)[1] ) );7273case 2: return ( u8( ((u2*)p)[0] ) << 48 )74| ( u8( ((u2*)p)[1] ) << 32 )75| ( u8( ((u2*)p)[2] ) << 16 )76| ( u8( ((u2*)p)[3] ) );7778default: return ( u8(p[0]) << 56 )79| ( u8(p[1]) << 48 )80| ( u8(p[2]) << 40 )81| ( u8(p[3]) << 32 )82| ( u8(p[4]) << 24 )83| ( u8(p[5]) << 16 )84| ( u8(p[6]) << 8 )85| u8(p[7]);86}87}88899091static inline void put_native_u2(address p, u2 x) {92if ( (intptr_t(p) & 1) == 0 ) *(u2*)p = x;93else {94p[0] = x >> 8;95p[1] = x;96}97}9899static inline void put_native_u4(address p, u4 x) {100switch ( intptr_t(p) & 3 ) {101case 0: *(u4*)p = x;102break;103104case 2: ((u2*)p)[0] = x >> 16;105((u2*)p)[1] = x;106break;107108default: ((u1*)p)[0] = x >> 24;109((u1*)p)[1] = x >> 16;110((u1*)p)[2] = x >> 8;111((u1*)p)[3] = x;112break;113}114}115116static inline void put_native_u8(address p, u8 x) {117switch ( intptr_t(p) & 7 ) {118case 0: *(u8*)p = x;119break;120121case 4: ((u4*)p)[0] = x >> 32;122((u4*)p)[1] = x;123break;124125case 2: ((u2*)p)[0] = x >> 48;126((u2*)p)[1] = x >> 32;127((u2*)p)[2] = x >> 16;128((u2*)p)[3] = x;129break;130131default: ((u1*)p)[0] = x >> 56;132((u1*)p)[1] = x >> 48;133((u1*)p)[2] = x >> 40;134((u1*)p)[3] = x >> 32;135((u1*)p)[4] = x >> 24;136((u1*)p)[5] = x >> 16;137((u1*)p)[6] = x >> 8;138((u1*)p)[7] = x;139}140}141142143// Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)144// (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)145static inline u2 get_Java_u2(address p) { return get_native_u2(p); }146static inline u4 get_Java_u4(address p) { return get_native_u4(p); }147static inline u8 get_Java_u8(address p) { return get_native_u8(p); }148149static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, x); }150static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, x); }151static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, x); }152};153154//Reconciliation History155// 1.7 98/02/24 10:18:41 bytes_i486.hpp156// 1.10 98/04/08 18:47:57 bytes_i486.hpp157// 1.13 98/07/15 17:10:03 bytes_i486.hpp158// 1.14 98/08/13 10:38:23 bytes_i486.hpp159// 1.15 98/10/05 16:30:21 bytes_i486.hpp160// 1.17 99/06/22 16:37:35 bytes_i486.hpp161//End162163#endif // CPU_SPARC_VM_BYTES_SPARC_HPP164165166