src/hotspot/cpu/ppc/bytes_ppc.hpp
author naoto
Tue, 09 Jul 2019 08:05:38 -0700
changeset 55627 9c1885fb2a42
parent 53244 9807daeb47c4
permissions -rw-r--r--
8227127: Era designator not displayed correctly using the COMPAT provider Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 35594
diff changeset
     3
 * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#ifndef CPU_PPC_BYTES_PPC_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    27
#define CPU_PPC_BYTES_PPC_HPP
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "memory/allocation.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    31
class Bytes: AllStatic {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
  // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
  // PowerPC needs to check for alignment.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    36
  // Can I count on address always being a pointer to an unsigned char? Yes.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
23532
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    38
#if defined(VM_LITTLE_ENDIAN)
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    39
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    40
  // Forward declarations of the compiler-dependent implementation
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    41
  static inline u2 swap_u2(u2 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    42
  static inline u4 swap_u4(u4 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    43
  static inline u8 swap_u8(u8 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    44
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    45
  static inline u2   get_native_u2(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    46
    return (intptr_t(p) & 1) == 0
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    47
             ?   *(u2*)p
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    48
             :   ( u2(p[1]) << 8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    49
               | ( u2(p[0])      );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    50
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    51
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    52
  static inline u4   get_native_u4(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    53
    switch (intptr_t(p) & 3) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    54
     case 0:  return *(u4*)p;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    55
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    56
     case 2:  return (  u4( ((u2*)p)[1] ) << 16  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    57
                   | (  u4( ((u2*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    58
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    59
    default:  return ( u4(p[3]) << 24 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    60
                   | ( u4(p[2]) << 16 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    61
                   | ( u4(p[1]) <<  8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    62
                   |   u4(p[0]);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    63
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    64
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    65
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    66
  static inline u8   get_native_u8(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    67
    switch (intptr_t(p) & 7) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    68
      case 0:  return *(u8*)p;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    69
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    70
      case 4:  return (  u8( ((u4*)p)[1] ) << 32  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    71
                    | (  u8( ((u4*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    72
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    73
      case 2:  return (  u8( ((u2*)p)[3] ) << 48  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    74
                    | (  u8( ((u2*)p)[2] ) << 32  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    75
                    | (  u8( ((u2*)p)[1] ) << 16  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    76
                    | (  u8( ((u2*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    77
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    78
     default:  return ( u8(p[7]) << 56 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    79
                    | ( u8(p[6]) << 48 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    80
                    | ( u8(p[5]) << 40 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    81
                    | ( u8(p[4]) << 32 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    82
                    | ( u8(p[3]) << 24 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    83
                    | ( u8(p[2]) << 16 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    84
                    | ( u8(p[1]) <<  8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    85
                    |   u8(p[0]);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    86
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    87
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    88
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    89
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    90
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    91
  static inline void put_native_u2(address p, u2 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    92
    if ( (intptr_t(p) & 1) == 0 )  *(u2*)p = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    93
    else {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    94
      p[1] = x >> 8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    95
      p[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    96
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    97
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    98
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    99
  static inline void put_native_u4(address p, u4 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   100
    switch ( intptr_t(p) & 3 ) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   101
    case 0:  *(u4*)p = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   102
              break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   103
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   104
    case 2:  ((u2*)p)[1] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   105
             ((u2*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   106
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   107
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   108
    default: ((u1*)p)[3] = x >> 24;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   109
             ((u1*)p)[2] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   110
             ((u1*)p)[1] = x >>  8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   111
             ((u1*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   112
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   113
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   114
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   115
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   116
  static inline void put_native_u8(address p, u8 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   117
    switch ( intptr_t(p) & 7 ) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   118
    case 0:  *(u8*)p = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   119
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   120
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   121
    case 4:  ((u4*)p)[1] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   122
             ((u4*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   123
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   124
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   125
    case 2:  ((u2*)p)[3] = x >> 48;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   126
             ((u2*)p)[2] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   127
             ((u2*)p)[1] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   128
             ((u2*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   129
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   130
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   131
    default: ((u1*)p)[7] = x >> 56;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   132
             ((u1*)p)[6] = x >> 48;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   133
             ((u1*)p)[5] = x >> 40;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   134
             ((u1*)p)[4] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   135
             ((u1*)p)[3] = x >> 24;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   136
             ((u1*)p)[2] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   137
             ((u1*)p)[1] = x >>  8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   138
             ((u1*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   139
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   140
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   141
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   142
  // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   143
  // (no byte-order reversal is needed since Power CPUs are big-endian oriented).
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   144
  static inline u2   get_Java_u2(address p) { return swap_u2(get_native_u2(p)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   145
  static inline u4   get_Java_u4(address p) { return swap_u4(get_native_u4(p)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   146
  static inline u8   get_Java_u8(address p) { return swap_u8(get_native_u8(p)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   147
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   148
  static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, swap_u2(x)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   149
  static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, swap_u4(x)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   150
  static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, swap_u8(x)); }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   151
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   152
#else // !defined(VM_LITTLE_ENDIAN)
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   153
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
  // Thus, a swap between native and Java ordering is always a no-op:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
  static inline u2   swap_u2(u2 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
  static inline u4   swap_u4(u4 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
  static inline u8   swap_u8(u8 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   159
  static inline u2   get_native_u2(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
    return (intptr_t(p) & 1) == 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
             ?   *(u2*)p
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
             :   ( u2(p[0]) << 8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   163
               | ( u2(p[1])      );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
  static inline u4   get_native_u4(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
    switch (intptr_t(p) & 3) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   168
     case 0:  return *(u4*)p;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   169
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   170
     case 2:  return (  u4( ((u2*)p)[0] ) << 16  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
                   | (  u4( ((u2*)p)[1] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   172
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   173
    default:  return ( u4(p[0]) << 24 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   174
                   | ( u4(p[1]) << 16 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
                   | ( u4(p[2]) <<  8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
                   |   u4(p[3]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   177
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   178
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   179
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   180
  static inline u8   get_native_u8(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   181
    switch (intptr_t(p) & 7) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   182
      case 0:  return *(u8*)p;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   183
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   184
      case 4:  return (  u8( ((u4*)p)[0] ) << 32  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   185
                    | (  u8( ((u4*)p)[1] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   186
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   187
      case 2:  return (  u8( ((u2*)p)[0] ) << 48  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   188
                    | (  u8( ((u2*)p)[1] ) << 32  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   189
                    | (  u8( ((u2*)p)[2] ) << 16  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   190
                    | (  u8( ((u2*)p)[3] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   191
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   192
     default:  return ( u8(p[0]) << 56 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   193
                    | ( u8(p[1]) << 48 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   194
                    | ( u8(p[2]) << 40 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   195
                    | ( u8(p[3]) << 32 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   196
                    | ( u8(p[4]) << 24 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   197
                    | ( u8(p[5]) << 16 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   198
                    | ( u8(p[6]) <<  8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   199
                    |   u8(p[7]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   200
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   201
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   202
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   203
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   204
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   205
  static inline void put_native_u2(address p, u2 x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   206
    if ( (intptr_t(p) & 1) == 0 ) { *(u2*)p = x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   207
    else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   208
      p[0] = x >> 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
      p[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   210
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   211
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   212
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   213
  static inline void put_native_u4(address p, u4 x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   214
    switch ( intptr_t(p) & 3 ) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   215
    case 0:  *(u4*)p = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   216
              break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   217
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   218
    case 2:  ((u2*)p)[0] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
             ((u2*)p)[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   220
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   222
    default: ((u1*)p)[0] = x >> 24;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
             ((u1*)p)[1] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
             ((u1*)p)[2] = x >>  8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
             ((u1*)p)[3] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   228
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   229
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   230
  static inline void put_native_u8(address p, u8 x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
    switch ( intptr_t(p) & 7 ) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   232
    case 0:  *(u8*)p = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   233
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   234
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   235
    case 4:  ((u4*)p)[0] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
             ((u4*)p)[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   238
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   239
    case 2:  ((u2*)p)[0] = x >> 48;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
             ((u2*)p)[1] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
             ((u2*)p)[2] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
             ((u2*)p)[3] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   244
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   245
    default: ((u1*)p)[0] = x >> 56;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   246
             ((u1*)p)[1] = x >> 48;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   247
             ((u1*)p)[2] = x >> 40;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   248
             ((u1*)p)[3] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
             ((u1*)p)[4] = x >> 24;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   250
             ((u1*)p)[5] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   251
             ((u1*)p)[6] = x >>  8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   252
             ((u1*)p)[7] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   253
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   254
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   255
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   256
  // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   257
  // (no byte-order reversal is needed since Power CPUs are big-endian oriented).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   258
  static inline u2   get_Java_u2(address p) { return get_native_u2(p); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   259
  static inline u4   get_Java_u4(address p) { return get_native_u4(p); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   260
  static inline u8   get_Java_u8(address p) { return get_native_u8(p); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   261
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   262
  static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, x); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   263
  static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, x); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   264
  static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, x); }
23532
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   265
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   266
#endif // VM_LITTLE_ENDIAN
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   267
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   268
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 35594
diff changeset
   269
#include OS_CPU_HEADER_INLINE(bytes)
23532
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   270
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   271
#endif // CPU_PPC_BYTES_PPC_HPP