annotate src/share/vm/libadt/port.hpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 2b8e28fdf503
children 4ca6dc0799b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
12146
9758d9f36299 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
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: 579
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_LIBADT_PORT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_LIBADT_PORT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "utilities/top.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Typedefs for portable compiling
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #if defined(__GNUC__)
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #define INTERFACE #pragma interface
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #define IMPLEMENTATION #pragma implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
37 #include <stddef.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Access to the C++ class virtual function pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Put the class in the macro
a61af66fc99e Initial load
duke
parents:
diff changeset
43 typedef void *VPTR;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // G++ puts it at the end of the base class
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)((char*)this+sizeof(class)-sizeof(void*));}
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 #elif defined(__TURBOC__)
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 #include <mem.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
50 #include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
51 extern "C" int stricmp(const char *, const char *);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 inline void bcopy(const void *s, void *d, int l) { memmove(d,s,l); }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 inline void bzero(void *p, int l) { memset(p,0,l); }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 inline int bcmp(const void *s, const void *d, int l) { return memcmp(s,d,l); }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 inline int min( int a, int b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 inline int max( int a, int b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 //strcasecmp moved to globalDefinitions_visCPP.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
58 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 inline long abs( long x ) { return x < 0 ? -x : x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Access to the C++ class virtual function pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Put the class in the macro
a61af66fc99e Initial load
duke
parents:
diff changeset
62 typedef void near *VPTR;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // BorlandC puts it up front
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)this;}
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #elif defined(__hpux)
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
70 #define signed
a61af66fc99e Initial load
duke
parents:
diff changeset
71 #include <strings.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
72 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
73 inline long min( long a, long b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 inline long max( long a, long b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 inline int min( int a, int b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 inline int max( int a, int b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 inline long abs( long x ) { return x < 0 ? -x : x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 #elif defined(__MOTO__)
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Motorola's mcc
a61af66fc99e Initial load
duke
parents:
diff changeset
81 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
82 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
83 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #include <memory.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
85 inline int min( int a, int b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 inline int max( int a, int b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #elif defined(_AIX)
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // IBM's xlC compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
90 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
91 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
92 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
93 #include <memory.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #elif defined(_MSC_VER)
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Microsoft Visual C++
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //#define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
98 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
99 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #undef small
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //strcasecmp moved to globalDefinitions_visCPP.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 #elif defined(SPARC_WORKS)
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
108 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 #include <stddef.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
111 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
112 #include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 #elif defined(SOLARIS)
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
117 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #include <stddef.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
120 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
121 #include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #elif defined(__TANDEM)
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // This case is for the Tandem Business Unit of Compaq Computer Corporation.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // The Tandem case must precede the AT&T case,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // because the Tandem c89 compiler also defines __cplusplus.
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #include "port_tandem.hpp"
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #elif defined(__cplusplus)
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // AT&Ts cfront
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #define INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
135 #define IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
136 #include <unistd.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #define signed
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // #include <bstring.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
139 inline int min( int a, int b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 inline int max( int a, int b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 #else // All other machines
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 #define signed
a61af66fc99e Initial load
duke
parents:
diff changeset
145 extern "C" void bcopy(void *b1, void *b2, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 inline int min( int a, int b) { return a < b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 inline int max( int a, int b) { return a > b ? a : b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 //-----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Safer memory allocations
a61af66fc99e Initial load
duke
parents:
diff changeset
153 #ifdef SAFE_MEMORY
a61af66fc99e Initial load
duke
parents:
diff changeset
154 #define malloc(size) safe_malloc(__FILE__,__LINE__,size)
a61af66fc99e Initial load
duke
parents:
diff changeset
155 #define free(ptr) safe_free(__FILE__,__LINE__,ptr)
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #define realloc(ptr,size) safe_realloc(__FILE__,__LINE__,ptr,size)
a61af66fc99e Initial load
duke
parents:
diff changeset
157 #define calloc(nitems,size) safe_calloc(__FILE__,__LINE__,nitems,size)
a61af66fc99e Initial load
duke
parents:
diff changeset
158 #define strdup(ptr) safe_strdup(__FILE__,__LINE__,ptr)
a61af66fc99e Initial load
duke
parents:
diff changeset
159 extern void *safe_malloc (const char *file, unsigned line, unsigned size);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 extern void safe_free (const char *file, unsigned line, void *ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 extern char *safe_strdup (const char *file, unsigned line, const char *src);
12146
9758d9f36299 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 1972
diff changeset
164 inline void *operator new( size_t size ) throw() { return malloc(size); }
9758d9f36299 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 1972
diff changeset
165 inline void operator delete( void *ptr ) { free(ptr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
166 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 //-----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // And now, the bit-size-specified integer sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
170 typedef signed char int8;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 typedef unsigned char uint8;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 typedef unsigned char byte;
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // All uses of *int16 changed to 32-bit to speed up compiler on Intel
a61af66fc99e Initial load
duke
parents:
diff changeset
175 //typedef signed short int16; // Exactly 16bits signed
a61af66fc99e Initial load
duke
parents:
diff changeset
176 //typedef unsigned short uint16; // Exactly 16bits unsigned
a61af66fc99e Initial load
duke
parents:
diff changeset
177 //const unsigned int min_uint16 = 0x0000; // smallest uint16
a61af66fc99e Initial load
duke
parents:
diff changeset
178 //const unsigned int max_uint16 = 0xFFFF; // largest uint16
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 typedef unsigned int uint; // When you need a fast >=16bit unsigned value
a61af66fc99e Initial load
duke
parents:
diff changeset
181 /*typedef int int; */ // When you need a fast >=16bit value
a61af66fc99e Initial load
duke
parents:
diff changeset
182 const unsigned int max_uint = (uint)-1;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 typedef int32_t int32; // Exactly 32bits signed
a61af66fc99e Initial load
duke
parents:
diff changeset
184 typedef uint32_t uint32; // Exactly 32bits unsigned
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Bit-sized floating point and long thingies
a61af66fc99e Initial load
duke
parents:
diff changeset
187 #ifndef __TANDEM
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // Do not define these for Tandem, because they conflict with typedefs in softieee.h.
a61af66fc99e Initial load
duke
parents:
diff changeset
189 typedef float float32; // 32-bit float
a61af66fc99e Initial load
duke
parents:
diff changeset
190 typedef double float64; // 64-bit float
a61af66fc99e Initial load
duke
parents:
diff changeset
191 #endif // __TANDEM
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 typedef jlong int64; // Java long for my 64-bit type
a61af66fc99e Initial load
duke
parents:
diff changeset
194 typedef julong uint64; // Java long for my 64-bit type
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 //-----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Nice constants
a61af66fc99e Initial load
duke
parents:
diff changeset
198 uint32 gcd( uint32 x, uint32 y );
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int ff1( uint32 mask );
a61af66fc99e Initial load
duke
parents:
diff changeset
200 int fh1( uint32 mask );
a61af66fc99e Initial load
duke
parents:
diff changeset
201 uint32 rotate32( uint32 x, int32 cnt );
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 //-----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
205 extern uint32 heap_totalmem; // Current total memory allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
206 extern uint32 heap_highwater; // Highwater mark to date for memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
207
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
208 #endif // SHARE_VM_LIBADT_PORT_HPP