Thu, 19 Mar 2015 19:53:34 +0100
8074869: C2 code generator can replace -0.0f with +0.0f on Linux
Summary: Instead of 'fpclass', use cast float->int and double->long to check if value is +0.0f and +0.0d, respectively.
Reviewed-by: kvn, simonis, dlong
1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2012, 2013 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
26 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP
27 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP
29 #include "prims/jni.h"
31 // This file holds compiler-dependent includes,
32 // globally used constants & types, class (forward)
33 // declarations and a few frequently used utility functions.
35 #include <ctype.h>
36 #include <string.h>
37 #include <stdarg.h>
38 #include <stddef.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <wchar.h>
43 #include <math.h>
44 #include <time.h>
45 #include <fcntl.h>
46 #include <dlfcn.h>
47 #include <pthread.h>
49 #include <limits.h>
50 #include <errno.h>
52 #include <stdint.h>
54 // Use XLC compiler builtins instead of inline assembler
55 #define USE_XLC_BUILTINS
56 #ifdef USE_XLC_BUILTINS
57 #include <builtins.h>
58 #if __IBMCPP__ < 1000
59 // the funtion prototype for __dcbtst(void *) is missing in XLC V8.0
60 // I could compile a little test, where I provided the prototype.
61 // The generated code was correct there. This is the prototype:
62 // extern "builtin" void __dcbtst (void *);
63 // For now we don't make use of it when compiling with XLC V8.0
64 #else
65 // __IBMCPP__ >= 1000
66 // XLC V10 provides the prototype for __dcbtst (void *);
67 #define USE_XLC_PREFETCH_WRITE_BUILTIN
68 #endif
69 #endif // USE_XLC_BUILTINS
71 // NULL vs NULL_WORD:
72 // On Linux NULL is defined as a special type '__null'. Assigning __null to
73 // integer variable will cause gcc warning. Use NULL_WORD in places where a
74 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
75 // sizeof(void*), so here we want something which is integer type, but has the
76 // same size as a pointer.
77 #ifdef __GNUC__
78 #error XLC and __GNUC__?
79 #else
80 #define NULL_WORD NULL
81 #endif
83 // AIX also needs a 64 bit NULL to work as a null address pointer.
84 // Most system includes on AIX would define it as an int 0 if not already defined with one
85 // exception: /usr/include/dirent.h will unconditionally redefine NULL to int 0 again.
86 // In this case you need to copy the following defines to a position after #include <dirent.h>
87 // (see jmv_aix.h).
88 #ifdef AIX
89 #ifdef _LP64
90 #undef NULL
91 #define NULL 0L
92 #else
93 #ifndef NULL
94 #define NULL 0
95 #endif
96 #endif
97 #endif // AIX
99 // Compiler-specific primitive types
100 // All defs of int (uint16_6 etc) are defined in AIX' /usr/include/stdint.h
102 // Additional Java basic types
104 typedef uint8_t jubyte;
105 typedef uint16_t jushort;
106 typedef uint32_t juint;
107 typedef uint64_t julong;
110 //----------------------------------------------------------------------------------------------------
111 // Constant for jlong (specifying an long long canstant is C++ compiler specific)
113 // Build a 64bit integer constant
114 #define CONST64(x) (x ## LL)
115 #define UCONST64(x) (x ## ULL)
117 const jlong min_jlong = CONST64(0x8000000000000000);
118 const jlong max_jlong = CONST64(0x7fffffffffffffff);
120 //----------------------------------------------------------------------------------------------------
121 // Debugging
123 #define DEBUG_EXCEPTION ::abort();
125 extern "C" void breakpoint();
126 #define BREAKPOINT ::breakpoint()
128 // checking for nanness
129 #ifdef AIX
130 inline int g_isnan(float f) { return isnan(f); }
131 inline int g_isnan(double f) { return isnan(f); }
132 #else
133 #error "missing platform-specific definition here"
134 #endif
136 // Checking for finiteness
138 inline int g_isfinite(jfloat f) { return finite(f); }
139 inline int g_isfinite(jdouble f) { return finite(f); }
142 // Wide characters
144 inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
147 // Portability macros
148 #define PRAGMA_INTERFACE #pragma interface
149 #define PRAGMA_IMPLEMENTATION #pragma implementation
150 #define VALUE_OBJ_CLASS_SPEC
152 // Formatting.
153 #ifdef _LP64
154 #define FORMAT64_MODIFIER "l"
155 #else // !_LP64
156 #define FORMAT64_MODIFIER "ll"
157 #endif // _LP64
159 // Cannot use xlc's offsetof as implementation of hotspot's
160 // offset_of(), because xlc warns about applying offsetof() to non-POD
161 // object and xlc cannot compile the expression offsetof(DataLayout,
162 // _cells[index]) in DataLayout::cell_offset() . Therefore we define
163 // offset_of as it is defined for gcc.
164 #define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16)
166 // Some constant sizes used throughout the AIX port
167 #define SIZE_1K ((uint64_t) 0x400ULL)
168 #define SIZE_4K ((uint64_t) 0x1000ULL)
169 #define SIZE_64K ((uint64_t) 0x10000ULL)
170 #define SIZE_1M ((uint64_t) 0x100000ULL)
171 #define SIZE_4M ((uint64_t) 0x400000ULL)
172 #define SIZE_8M ((uint64_t) 0x800000ULL)
173 #define SIZE_16M ((uint64_t) 0x1000000ULL)
174 #define SIZE_256M ((uint64_t) 0x10000000ULL)
175 #define SIZE_1G ((uint64_t) 0x40000000ULL)
176 #define SIZE_2G ((uint64_t) 0x80000000ULL)
177 #define SIZE_4G ((uint64_t) 0x100000000ULL)
178 #define SIZE_16G ((uint64_t) 0x400000000ULL)
179 #define SIZE_32G ((uint64_t) 0x800000000ULL)
180 #define SIZE_64G ((uint64_t) 0x1000000000ULL)
181 #define SIZE_1T ((uint64_t) 0x10000000000ULL)
184 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP