Mercurial > hg > truffle
annotate src/share/vm/utilities/globalDefinitions_visCPP.hpp @ 14714:b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 20 Mar 2014 17:15:36 +0100 |
parents | de6a9e811145 |
children | 4ca6dc0799b6 b6a8cc1e0d92 |
rev | line source |
---|---|
0 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12316
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |
26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP | |
27 | |
28 #include "prims/jni.h" | |
29 | |
0 | 30 // This file holds compiler-dependent includes, |
31 // globally used constants & types, class (forward) | |
32 // declarations and a few frequently used utility functions. | |
33 | |
34 # include <ctype.h> | |
35 # include <string.h> | |
36 # include <stdarg.h> | |
37 # include <stdlib.h> | |
38 # include <stddef.h>// for offsetof | |
39 # include <io.h> // for stream.cpp | |
40 # include <float.h> // for _isnan | |
41 # include <stdio.h> // for va_list | |
42 # include <time.h> | |
43 # include <fcntl.h> | |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
44 # include <limits.h> |
0 | 45 // Need this on windows to get the math constants (e.g., M_PI). |
46 #define _USE_MATH_DEFINES | |
47 # include <math.h> | |
48 | |
49 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures | |
50 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in | |
51 // system header files. On 32-bit architectures, there is no problem. | |
52 // On 64-bit architectures, defining NULL as a 32-bit constant can cause | |
53 // problems with varargs functions: C++ integral promotion rules say for | |
54 // varargs, we pass the argument 0 as an int. So, if NULL was passed to a | |
55 // varargs function it will remain 32-bits. Depending on the calling | |
56 // convention of the machine, if the argument is passed on the stack then | |
57 // only 32-bits of the "NULL" pointer may be initialized to zero. The | |
58 // other 32-bits will be garbage. If the varargs function is expecting a | |
59 // pointer when it extracts the argument, then we may have a problem. | |
60 // | |
61 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. | |
62 #ifdef _LP64 | |
63 #undef NULL | |
64 // 64-bit Windows uses a P64 data model (not LP64, although we define _LP64) | |
65 // Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific | |
66 // 64-bit integer-suffix (i64) instead. | |
67 #define NULL 0i64 | |
68 #else | |
69 #ifndef NULL | |
70 #define NULL 0 | |
71 #endif | |
72 #endif | |
73 | |
74 // NULL vs NULL_WORD: | |
75 // On Linux NULL is defined as a special type '__null'. Assigning __null to | |
76 // integer variable will cause gcc warning. Use NULL_WORD in places where a | |
77 // pointer is stored as integer value. | |
78 #define NULL_WORD NULL | |
79 | |
80 // Compiler-specific primitive types | |
81 typedef unsigned __int8 uint8_t; | |
82 typedef unsigned __int16 uint16_t; | |
83 typedef unsigned __int32 uint32_t; | |
84 typedef unsigned __int64 uint64_t; | |
85 | |
86 #ifdef _WIN64 | |
87 typedef unsigned __int64 uintptr_t; | |
88 #else | |
89 typedef unsigned int uintptr_t; | |
90 #endif | |
91 typedef signed __int8 int8_t; | |
92 typedef signed __int16 int16_t; | |
93 typedef signed __int32 int32_t; | |
94 typedef signed __int64 int64_t; | |
95 #ifdef _WIN64 | |
96 typedef signed __int64 intptr_t; | |
97 typedef signed __int64 ssize_t; | |
98 #else | |
99 typedef signed int intptr_t; | |
100 typedef signed int ssize_t; | |
101 #endif | |
102 | |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
103 #ifndef UINTPTR_MAX |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
104 #ifdef _WIN64 |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
105 #define UINTPTR_MAX _UI64_MAX |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
106 #else |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
107 #define UINTPTR_MAX _UI32_MAX |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
108 #endif |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
109 #endif |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
1972
diff
changeset
|
110 |
0 | 111 //---------------------------------------------------------------------------------------------------- |
112 // Additional Java basic types | |
113 | |
114 typedef unsigned char jubyte; | |
115 typedef unsigned short jushort; | |
116 typedef unsigned int juint; | |
117 typedef unsigned __int64 julong; | |
118 | |
119 //---------------------------------------------------------------------------------------------------- | |
120 // Special (possibly not-portable) casts | |
121 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern | |
122 | |
123 inline jint jint_cast (jfloat x) { return *(jint* )&x; } | |
124 inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } | |
125 | |
126 inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } | |
127 inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } | |
128 | |
129 | |
130 //---------------------------------------------------------------------------------------------------- | |
131 // Non-standard stdlib-like stuff: | |
132 inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); } | |
4849
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
3960
diff
changeset
|
133 inline int strncasecmp(const char *s1, const char *s2, size_t n) { |
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
3960
diff
changeset
|
134 return _strnicmp(s1,s2,n); |
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
3960
diff
changeset
|
135 } |
0 | 136 |
137 | |
138 //---------------------------------------------------------------------------------------------------- | |
139 // Debugging | |
140 | |
141 #if _WIN64 | |
142 extern "C" void breakpoint(); | |
143 #define BREAKPOINT ::breakpoint() | |
144 #else | |
145 #define BREAKPOINT __asm { int 3 } | |
146 #endif | |
147 | |
148 //---------------------------------------------------------------------------------------------------- | |
149 // Checking for nanness | |
150 | |
151 inline int g_isnan(jfloat f) { return _isnan(f); } | |
152 inline int g_isnan(jdouble f) { return _isnan(f); } | |
153 | |
154 //---------------------------------------------------------------------------------------------------- | |
155 // Checking for finiteness | |
156 | |
157 inline int g_isfinite(jfloat f) { return _finite(f); } | |
158 inline int g_isfinite(jdouble f) { return _finite(f); } | |
159 | |
160 //---------------------------------------------------------------------------------------------------- | |
161 // Constant for jlong (specifying an long long constant is C++ compiler specific) | |
162 | |
163 // Build a 64bit integer constant on with Visual C++ | |
164 #define CONST64(x) (x ## i64) | |
165 #define UCONST64(x) ((uint64_t)CONST64(x)) | |
166 | |
167 const jlong min_jlong = CONST64(0x8000000000000000); | |
168 const jlong max_jlong = CONST64(0x7fffffffffffffff); | |
169 | |
170 //---------------------------------------------------------------------------------------------------- | |
171 // Miscellaneous | |
172 | |
173 // Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead | |
645
c3a720eefe82
6816308: Changes to allow builds with latest Windows SDK 6.1 on 64bit Windows 2003
kvn
parents:
0
diff
changeset
|
174 #if _MSC_VER >= 1400 |
0 | 175 #define open _open |
176 #define close _close | |
177 #define read _read | |
178 #define write _write | |
179 #define lseek _lseek | |
180 #define unlink _unlink | |
181 #define strdup _strdup | |
182 #endif | |
183 | |
184 #pragma warning( disable : 4100 ) // unreferenced formal parameter | |
185 #pragma warning( disable : 4127 ) // conditional expression is constant | |
186 #pragma warning( disable : 4514 ) // unreferenced inline function has been removed | |
187 #pragma warning( disable : 4244 ) // possible loss of data | |
188 #pragma warning( disable : 4512 ) // assignment operator could not be generated | |
189 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h) | |
190 #pragma warning( disable : 4511 ) // copy constructor could not be generated | |
191 #pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception | |
12316
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
6842
diff
changeset
|
192 #ifdef CHECK_UNHANDLED_OOPS |
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
6842
diff
changeset
|
193 #pragma warning( disable : 4521 ) // class has multiple copy ctors of a single type |
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
6842
diff
changeset
|
194 #pragma warning( disable : 4522 ) // class has multiple assignment operators of a single type |
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
6842
diff
changeset
|
195 #endif // CHECK_UNHANDLED_OOPS |
659
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
196 #if _MSC_VER >= 1400 |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
197 #pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
198 #endif |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
199 |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
200 inline int vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr) { |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
201 // If number of characters written == count, Windows doesn't write a |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
202 // terminating NULL, so we do it ourselves. |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
203 int ret = _vsnprintf(buf, count, fmt, argptr); |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
204 if (count > 0) buf[count-1] = '\0'; |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
205 return ret; |
520d43965b1f
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
645
diff
changeset
|
206 } |
0 | 207 |
208 // Portability macros | |
209 #define PRAGMA_INTERFACE | |
210 #define PRAGMA_IMPLEMENTATION | |
211 #define PRAGMA_IMPLEMENTATION_(arg) | |
212 #define VALUE_OBJ_CLASS_SPEC : public _ValueObj | |
213 | |
214 // Formatting. | |
215 #define FORMAT64_MODIFIER "I64" | |
216 | |
3960 | 217 // Visual Studio doesn't provide inttypes.h so provide appropriate definitions here. |
218 // The 32 bits ones might need I32 but seem to work ok without it. | |
219 #define PRId32 "d" | |
220 #define PRIu32 "u" | |
221 #define PRIx32 "x" | |
222 | |
223 #define PRId64 "I64d" | |
224 #define PRIu64 "I64u" | |
225 #define PRIx64 "I64x" | |
226 | |
6127
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
227 #ifdef _LP64 |
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
228 #define PRIdPTR "I64d" |
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
229 #define PRIuPTR "I64u" |
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
230 #define PRIxPTR "I64x" |
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
231 #else |
3960 | 232 #define PRIdPTR "d" |
233 #define PRIuPTR "u" | |
234 #define PRIxPTR "x" | |
6127
40b4aaf010e4
7172708: 32/64 bit type issues on Windows after Mac OS X port
dholmes
parents:
4849
diff
changeset
|
235 #endif |
3960 | 236 |
0 | 237 #define offset_of(klass,field) offsetof(klass,field) |
1972 | 238 |
239 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |