hotspot/src/cpu/ppc/vm/bytes_ppc.hpp
author goetz
Thu, 21 Jan 2016 12:37:47 +0100
changeset 35594 cc13089c6327
parent 23532 7e8719ce96ea
child 40010 e32d5e545789
permissions -rw-r--r--
8147937: Adapt SAP copyrights to new company name. Reviewed-by: simonis, stuefe
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
/*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
35594
cc13089c6327 8147937: Adapt SAP copyrights to new company name.
goetz
parents: 23532
diff changeset
     3
 * Copyright (c) 2012, 2013 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
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#ifndef CPU_PPC_VM_BYTES_PPC_HPP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#define CPU_PPC_VM_BYTES_PPC_HPP
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
  // Returns true, if the byte ordering used by Java is different from the native byte ordering
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    41
  // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    42
  static inline bool is_Java_byte_ordering_different() { return true; }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    43
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    44
  // Forward declarations of the compiler-dependent implementation
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    45
  static inline u2 swap_u2(u2 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    46
  static inline u4 swap_u4(u4 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    47
  static inline u8 swap_u8(u8 x);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    48
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    49
  static inline u2   get_native_u2(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    50
    return (intptr_t(p) & 1) == 0
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    51
             ?   *(u2*)p
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    52
             :   ( u2(p[1]) << 8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    53
               | ( u2(p[0])      );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    54
  }
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
  static inline u4   get_native_u4(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    57
    switch (intptr_t(p) & 3) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    58
     case 0:  return *(u4*)p;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    59
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    60
     case 2:  return (  u4( ((u2*)p)[1] ) << 16  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    61
                   | (  u4( ((u2*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    62
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    63
    default:  return ( u4(p[3]) << 24 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    64
                   | ( u4(p[2]) << 16 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    65
                   | ( u4(p[1]) <<  8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    66
                   |   u4(p[0]);
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    67
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    68
  }
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
  static inline u8   get_native_u8(address p) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    71
    switch (intptr_t(p) & 7) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    72
      case 0:  return *(u8*)p;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    73
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    74
      case 4:  return (  u8( ((u4*)p)[1] ) << 32  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    75
                    | (  u8( ((u4*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    76
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    77
      case 2:  return (  u8( ((u2*)p)[3] ) << 48  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    78
                    | (  u8( ((u2*)p)[2] ) << 32  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    79
                    | (  u8( ((u2*)p)[1] ) << 16  )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    80
                    | (  u8( ((u2*)p)[0] )        );
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    81
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    82
     default:  return ( u8(p[7]) << 56 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    83
                    | ( u8(p[6]) << 48 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    84
                    | ( u8(p[5]) << 40 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    85
                    | ( u8(p[4]) << 32 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    86
                    | ( u8(p[3]) << 24 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    87
                    | ( u8(p[2]) << 16 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    88
                    | ( u8(p[1]) <<  8 )
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    89
                    |   u8(p[0]);
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
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    92
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    93
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    94
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    95
  static inline void put_native_u2(address p, u2 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    96
    if ( (intptr_t(p) & 1) == 0 )  *(u2*)p = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    97
    else {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    98
      p[1] = x >> 8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
    99
      p[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   100
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   101
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   102
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   103
  static inline void put_native_u4(address p, u4 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   104
    switch ( intptr_t(p) & 3 ) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   105
    case 0:  *(u4*)p = 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
    case 2:  ((u2*)p)[1] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   109
             ((u2*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   110
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   111
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   112
    default: ((u1*)p)[3] = x >> 24;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   113
             ((u1*)p)[2] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   114
             ((u1*)p)[1] = x >>  8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   115
             ((u1*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   116
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   117
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   118
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   119
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   120
  static inline void put_native_u8(address p, u8 x) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   121
    switch ( intptr_t(p) & 7 ) {
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   122
    case 0:  *(u8*)p = 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 4:  ((u4*)p)[1] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   126
             ((u4*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   127
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   128
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   129
    case 2:  ((u2*)p)[3] = x >> 48;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   130
             ((u2*)p)[2] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   131
             ((u2*)p)[1] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   132
             ((u2*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   133
             break;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   134
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   135
    default: ((u1*)p)[7] = x >> 56;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   136
             ((u1*)p)[6] = x >> 48;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   137
             ((u1*)p)[5] = x >> 40;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   138
             ((u1*)p)[4] = x >> 32;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   139
             ((u1*)p)[3] = x >> 24;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   140
             ((u1*)p)[2] = x >> 16;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   141
             ((u1*)p)[1] = x >>  8;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   142
             ((u1*)p)[0] = x;
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   143
    }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   144
  }
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   145
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   146
  // 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
   147
  // (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
   148
  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
   149
  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
   150
  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
   151
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   152
  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
   153
  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
   154
  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
   155
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   156
#else // !defined(VM_LITTLE_ENDIAN)
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   157
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
  // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   159
  // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
  static inline bool is_Java_byte_ordering_different() { return false; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
  // 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
   163
  static inline u2   swap_u2(u2 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
  static inline u4   swap_u4(u4 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
  static inline u8   swap_u8(u8 x)  { return x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
  static inline u2   get_native_u2(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   168
    return (intptr_t(p) & 1) == 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   169
             ?   *(u2*)p
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   170
             :   ( u2(p[0]) << 8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
               | ( 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
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   174
  static inline u4   get_native_u4(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
    switch (intptr_t(p) & 3) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
     case 0:  return *(u4*)p;
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
     case 2:  return (  u4( ((u2*)p)[0] ) << 16  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   179
                   | (  u4( ((u2*)p)[1] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   180
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   181
    default:  return ( u4(p[0]) << 24 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   182
                   | ( u4(p[1]) << 16 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   183
                   | ( u4(p[2]) <<  8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   184
                   |   u4(p[3]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   185
    }
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
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   188
  static inline u8   get_native_u8(address p) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   189
    switch (intptr_t(p) & 7) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   190
      case 0:  return *(u8*)p;
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
      case 4:  return (  u8( ((u4*)p)[0] ) << 32  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   193
                    | (  u8( ((u4*)p)[1] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   194
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   195
      case 2:  return (  u8( ((u2*)p)[0] ) << 48  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   196
                    | (  u8( ((u2*)p)[1] ) << 32  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   197
                    | (  u8( ((u2*)p)[2] ) << 16  )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   198
                    | (  u8( ((u2*)p)[3] )        );
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   199
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   200
     default:  return ( u8(p[0]) << 56 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   201
                    | ( u8(p[1]) << 48 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   202
                    | ( u8(p[2]) << 40 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   203
                    | ( u8(p[3]) << 32 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   204
                    | ( u8(p[4]) << 24 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   205
                    | ( u8(p[5]) << 16 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   206
                    | ( u8(p[6]) <<  8 )
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   207
                    |   u8(p[7]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   208
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
  }
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_u2(address p, u2 x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   214
    if ( (intptr_t(p) & 1) == 0 ) { *(u2*)p = x; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   215
    else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   216
      p[0] = x >> 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   217
      p[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   218
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   220
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
  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
   222
    switch ( intptr_t(p) & 3 ) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
    case 0:  *(u4*)p = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
              break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
    case 2:  ((u2*)p)[0] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
             ((u2*)p)[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   228
             break;
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
    default: ((u1*)p)[0] = x >> 24;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
             ((u1*)p)[1] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   232
             ((u1*)p)[2] = x >>  8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   233
             ((u1*)p)[3] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   234
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   235
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   238
  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
   239
    switch ( intptr_t(p) & 7 ) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
    case 0:  *(u8*)p = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
    case 4:  ((u4*)p)[0] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   244
             ((u4*)p)[1] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   245
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   246
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   247
    case 2:  ((u2*)p)[0] = x >> 48;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   248
             ((u2*)p)[1] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
             ((u2*)p)[2] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   250
             ((u2*)p)[3] = x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   251
             break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   252
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   253
    default: ((u1*)p)[0] = x >> 56;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   254
             ((u1*)p)[1] = x >> 48;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   255
             ((u1*)p)[2] = x >> 40;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   256
             ((u1*)p)[3] = x >> 32;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   257
             ((u1*)p)[4] = x >> 24;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   258
             ((u1*)p)[5] = x >> 16;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   259
             ((u1*)p)[6] = x >>  8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   260
             ((u1*)p)[7] = x;
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
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   263
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   264
  // 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
   265
  // (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
   266
  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
   267
  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
   268
  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
   269
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   270
  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
   271
  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
   272
  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
   273
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   274
#endif // VM_LITTLE_ENDIAN
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   275
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   276
23532
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   277
#if defined(TARGET_OS_ARCH_linux_ppc)
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   278
#include "bytes_linux_ppc.inline.hpp"
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   279
#endif
7e8719ce96ea 8036767: PPC64: Support for little endian execution model
kvn
parents: 22861
diff changeset
   280
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   281
#endif // CPU_PPC_VM_BYTES_PPC_HPP