hotspot/src/cpu/sparc/vm/bytes_sparc.hpp
author jmasa
Tue, 24 Nov 2015 15:56:40 -0800
changeset 35043 30543d2a0a20
parent 7397 5b173b4ca846
child 46504 38048d4d20e7
permissions -rw-r--r--
8133023: ParallelGCThreads is not calculated correctly Reviewed-by: kbarrett, tschatzl, sangheki, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef CPU_SPARC_VM_BYTES_SPARC_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define CPU_SPARC_VM_BYTES_SPARC_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class Bytes: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  // Sparc needs to check for alignment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  // can I count on address always being a pointer to an unsigned char? Yes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  static inline bool is_Java_byte_ordering_different() { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // Thus, a swap between native and Java ordering is always a no-op:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  static inline u2   swap_u2(u2 x)  { return x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  static inline u4   swap_u4(u4 x)  { return x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  static inline u8   swap_u8(u8 x)  { return x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  static inline u2   get_native_u2(address p){
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    return (intptr_t(p) & 1) == 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
             ?   *(u2*)p
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
             :   ( u2(p[0]) << 8 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
               | ( u2(p[1])      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  static inline u4   get_native_u4(address p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    switch (intptr_t(p) & 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
     case 0:  return *(u4*)p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
     case 2:  return (  u4( ((u2*)p)[0] ) << 16  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                   | (  u4( ((u2*)p)[1] )                  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    default:  return ( u4(p[0]) << 24 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                   | ( u4(p[1]) << 16 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
                   | ( u4(p[2]) <<  8 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
                   |   u4(p[3]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  static inline u8   get_native_u8(address p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    switch (intptr_t(p) & 7) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      case 0:  return *(u8*)p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      case 4:  return (  u8( ((u4*)p)[0] ) << 32  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
                    | (  u8( ((u4*)p)[1] )        );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      case 2:  return (  u8( ((u2*)p)[0] ) << 48  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
                    | (  u8( ((u2*)p)[1] ) << 32  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                    | (  u8( ((u2*)p)[2] ) << 16  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
                    | (  u8( ((u2*)p)[3] )        );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
     default:  return ( u8(p[0]) << 56 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                    | ( u8(p[1]) << 48 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
                    | ( u8(p[2]) << 40 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
                    | ( u8(p[3]) << 32 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
                    | ( u8(p[4]) << 24 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                    | ( u8(p[5]) << 16 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                    | ( u8(p[6]) <<  8 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                    |   u8(p[7]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  static inline void put_native_u2(address p, u2 x)   {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    if ( (intptr_t(p) & 1) == 0 )  *(u2*)p = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      p[0] = x >> 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      p[1] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static inline void put_native_u4(address p, u4 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    switch ( intptr_t(p) & 3 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    case 0:  *(u4*)p = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
              break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    case 2:  ((u2*)p)[0] = x >> 16;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
             ((u2*)p)[1] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    default: ((u1*)p)[0] = x >> 24;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
             ((u1*)p)[1] = x >> 16;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
             ((u1*)p)[2] = x >>  8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
             ((u1*)p)[3] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  static inline void put_native_u8(address p, u8 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    switch ( intptr_t(p) & 7 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    case 0:  *(u8*)p = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    case 4:  ((u4*)p)[0] = x >> 32;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
             ((u4*)p)[1] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    case 2:  ((u2*)p)[0] = x >> 48;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
             ((u2*)p)[1] = x >> 32;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
             ((u2*)p)[2] = x >> 16;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
             ((u2*)p)[3] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    default: ((u1*)p)[0] = x >> 56;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
             ((u1*)p)[1] = x >> 48;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
             ((u1*)p)[2] = x >> 40;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
             ((u1*)p)[3] = x >> 32;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
             ((u1*)p)[4] = x >> 24;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
             ((u1*)p)[5] = x >> 16;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
             ((u1*)p)[6] = x >>  8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
             ((u1*)p)[7] = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  static inline u2   get_Java_u2(address p) { return get_native_u2(p); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  static inline u4   get_Java_u4(address p) { return get_native_u4(p); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  static inline u8   get_Java_u8(address p) { return get_native_u8(p); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
//Reconciliation History
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// 1.7 98/02/24 10:18:41 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// 1.10 98/04/08 18:47:57 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// 1.13 98/07/15 17:10:03 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// 1.14 98/08/13 10:38:23 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// 1.15 98/10/05 16:30:21 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// 1.17 99/06/22 16:37:35 bytes_i486.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
//End
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   163
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   164
#endif // CPU_SPARC_VM_BYTES_SPARC_HPP