hotspot/src/cpu/x86/vm/bytes_x86.hpp
author goetz
Wed, 18 Sep 2013 14:34:56 -0700
changeset 22834 3e2df6a4a28c
parent 10565 dc90c239f4ec
child 40010 e32d5e545789
permissions -rw-r--r--
8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints. Summary: Some platforms, as ppc and s390x/zArch require that 32-bit ints are passed as 64-bit values to C functions. This change adds support to adapt the signature and to issue proper casts to c2-compiled stubs. The functions are used in generate_native_wrapper(). Adapt signature used by the compiler as in PhaseIdealLoop::intrinsify_fill(). Reviewed-by: kvn
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_X86_VM_BYTES_X86_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define CPU_X86_VM_BYTES_X86_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
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
#ifndef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  // Helper function for swap_u8
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  static inline u8   swap_u8_base(u4 x, u4 y);        // compiler-dependent implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  // Returns true if the byte ordering used by Java is different from the native byte ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // of the underlying machine. For example, this is true for Intel x86, but false for Solaris
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  // on Sparc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  static inline bool is_Java_byte_ordering_different(){ return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // (no special code is needed since x86 CPUs can access unaligned data)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  static inline u2   get_native_u2(address p)         { return *(u2*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  static inline u4   get_native_u4(address p)         { return *(u4*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  static inline u8   get_native_u8(address p)         { return *(u8*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  static inline void put_native_u2(address p, u2 x)   { *(u2*)p = x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  static inline void put_native_u4(address p, u4 x)   { *(u4*)p = x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  static inline void put_native_u8(address p, u8 x)   { *(u8*)p = x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Efficient reading and writing of unaligned unsigned data in Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // byte ordering (i.e. big-endian ordering). Byte-order reversal is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // needed since x86 CPUs use little-endian format.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  static inline u2   get_Java_u2(address p)           { return swap_u2(get_native_u2(p)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static inline u4   get_Java_u4(address p)           { return swap_u4(get_native_u4(p)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static inline u8   get_Java_u8(address p)           { return swap_u8(get_native_u8(p)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  static inline void put_Java_u2(address p, u2 x)     { put_native_u2(p, swap_u2(x)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  static inline void put_Java_u4(address p, u4 x)     { put_native_u4(p, swap_u4(x)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  static inline void put_Java_u8(address p, u8 x)     { put_native_u8(p, swap_u8(x)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Efficient swapping of byte ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  static inline u2   swap_u2(u2 x);                   // compiler-dependent implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  static inline u4   swap_u4(u4 x);                   // compiler-dependent implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  static inline u8   swap_u8(u8 x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// The following header contains the implementations of swap_u2, swap_u4, and swap_u8[_base]
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    75
#ifdef TARGET_OS_ARCH_linux_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    76
# include "bytes_linux_x86.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    77
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    78
#ifdef TARGET_OS_ARCH_solaris_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    79
# include "bytes_solaris_x86.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    80
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    81
#ifdef TARGET_OS_ARCH_windows_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    82
# include "bytes_windows_x86.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    83
#endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    84
#ifdef TARGET_OS_ARCH_bsd_x86
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    85
# include "bytes_bsd_x86.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    86
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    87
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    88
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    89
#endif // CPU_X86_VM_BYTES_X86_HPP