src/cpu/sparc/vm/bytes_sparc.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 class Bytes: AllStatic {
  26  public:
  27   // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
  28   // Sparc needs to check for alignment.
  29 
  30   // can I count on address always being a pointer to an unsigned char? Yes
  31 
  32   // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
  33   // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
  34   static inline bool is_Java_byte_ordering_different() { return false; }
  35 
  36   // Thus, a swap between native and Java ordering is always a no-op:
  37   static inline u2   swap_u2(u2 x)  { return x; }
  38   static inline u4   swap_u4(u4 x)  { return x; }
  39   static inline u8   swap_u8(u8 x)  { return x; }
  40 
  41   static inline u2   get_native_u2(address p){
  42     return (intptr_t(p) & 1) == 0
  43              ?   *(u2*)p
  44              :   ( u2(p[0]) << 8 )


 138 
 139   // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
 140   // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
 141   static inline u2   get_Java_u2(address p) { return get_native_u2(p); }
 142   static inline u4   get_Java_u4(address p) { return get_native_u4(p); }
 143   static inline u8   get_Java_u8(address p) { return get_native_u8(p); }
 144 
 145   static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, x); }
 146   static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, x); }
 147   static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, x); }
 148 };
 149 
 150 //Reconciliation History
 151 // 1.7 98/02/24 10:18:41 bytes_i486.hpp
 152 // 1.10 98/04/08 18:47:57 bytes_i486.hpp
 153 // 1.13 98/07/15 17:10:03 bytes_i486.hpp
 154 // 1.14 98/08/13 10:38:23 bytes_i486.hpp
 155 // 1.15 98/10/05 16:30:21 bytes_i486.hpp
 156 // 1.17 99/06/22 16:37:35 bytes_i486.hpp
 157 //End


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 )


 143 
 144   // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
 145   // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
 146   static inline u2   get_Java_u2(address p) { return get_native_u2(p); }
 147   static inline u4   get_Java_u4(address p) { return get_native_u4(p); }
 148   static inline u8   get_Java_u8(address p) { return get_native_u8(p); }
 149 
 150   static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, x); }
 151   static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, x); }
 152   static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, x); }
 153 };
 154 
 155 //Reconciliation History
 156 // 1.7 98/02/24 10:18:41 bytes_i486.hpp
 157 // 1.10 98/04/08 18:47:57 bytes_i486.hpp
 158 // 1.13 98/07/15 17:10:03 bytes_i486.hpp
 159 // 1.14 98/08/13 10:38:23 bytes_i486.hpp
 160 // 1.15 98/10/05 16:30:21 bytes_i486.hpp
 161 // 1.17 99/06/22 16:37:35 bytes_i486.hpp
 162 //End
 163 
 164 #endif // CPU_SPARC_VM_BYTES_SPARC_HPP