author | redestad |
Thu, 17 Oct 2019 00:00:13 +0200 | |
changeset 58654 | 562bf1878089 |
parent 58548 | 430b9a492a05 |
child 58679 | 9c3209ff7550 |
child 59016 | 3b9eeae66fa0 |
permissions | -rw-r--r-- |
10565 | 1 |
/* |
53155
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
10565 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
// no precompiled headers |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47524
diff
changeset
|
26 |
#include "jvm.h" |
10565 | 27 |
#include "classfile/classLoader.hpp" |
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "classfile/vmSymbols.hpp" |
|
30 |
#include "code/icBuffer.hpp" |
|
31 |
#include "code/vtableStubs.hpp" |
|
32 |
#include "compiler/compileBroker.hpp" |
|
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
14471
diff
changeset
|
33 |
#include "compiler/disassembler.hpp" |
10565 | 34 |
#include "interpreter/interpreter.hpp" |
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
35 |
#include "logging/log.hpp" |
54280
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
36 |
#include "logging/logStream.hpp" |
10565 | 37 |
#include "memory/allocation.inline.hpp" |
38 |
#include "memory/filemap.hpp" |
|
39 |
#include "oops/oop.inline.hpp" |
|
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
25354
diff
changeset
|
40 |
#include "os_bsd.inline.hpp" |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53461
diff
changeset
|
41 |
#include "os_posix.inline.hpp" |
10565 | 42 |
#include "os_share_bsd.hpp" |
43 |
#include "prims/jniFastGetField.hpp" |
|
44 |
#include "prims/jvm_misc.hpp" |
|
45 |
#include "runtime/arguments.hpp" |
|
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
40377
diff
changeset
|
46 |
#include "runtime/atomic.hpp" |
10565 | 47 |
#include "runtime/extendedPC.hpp" |
48 |
#include "runtime/globals.hpp" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
48865
diff
changeset
|
49 |
#include "runtime/interfaceSupport.inline.hpp" |
10565 | 50 |
#include "runtime/java.hpp" |
51 |
#include "runtime/javaCalls.hpp" |
|
52 |
#include "runtime/mutexLocker.hpp" |
|
53 |
#include "runtime/objectMonitor.hpp" |
|
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
50184
diff
changeset
|
54 |
#include "runtime/orderAccess.hpp" |
10565 | 55 |
#include "runtime/osThread.hpp" |
56 |
#include "runtime/perfMemory.hpp" |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
57 |
#include "runtime/semaphore.hpp" |
10565 | 58 |
#include "runtime/sharedRuntime.hpp" |
59 |
#include "runtime/statSampler.hpp" |
|
60 |
#include "runtime/stubRoutines.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14471
diff
changeset
|
61 |
#include "runtime/thread.inline.hpp" |
10565 | 62 |
#include "runtime/threadCritical.hpp" |
63 |
#include "runtime/timer.hpp" |
|
64 |
#include "services/attachListener.hpp" |
|
15927
f256c20146f4
8008257: NMT: assert(new_rec->is_allocation_record()) failed when running with shared memory option
zgu
parents:
15855
diff
changeset
|
65 |
#include "services/memTracker.hpp" |
10565 | 66 |
#include "services/runtimeService.hpp" |
46625 | 67 |
#include "utilities/align.hpp" |
10565 | 68 |
#include "utilities/decoder.hpp" |
69 |
#include "utilities/defaultStream.hpp" |
|
70 |
#include "utilities/events.hpp" |
|
71 |
#include "utilities/growableArray.hpp" |
|
72 |
#include "utilities/vmError.hpp" |
|
73 |
||
74 |
// put OS-includes here |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
75 |
# include <dlfcn.h> |
10565 | 76 |
# include <errno.h> |
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
77 |
# include <fcntl.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
78 |
# include <inttypes.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
79 |
# include <poll.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
80 |
# include <pthread.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
81 |
# include <pwd.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
82 |
# include <signal.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
83 |
# include <stdint.h> |
10565 | 84 |
# include <stdio.h> |
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
85 |
# include <string.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
86 |
# include <sys/ioctl.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
87 |
# include <sys/mman.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
88 |
# include <sys/param.h> |
10565 | 89 |
# include <sys/resource.h> |
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
90 |
# include <sys/socket.h> |
10565 | 91 |
# include <sys/stat.h> |
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
92 |
# include <sys/syscall.h> |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
93 |
# include <sys/sysctl.h> |
10565 | 94 |
# include <sys/time.h> |
95 |
# include <sys/times.h> |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
96 |
# include <sys/types.h> |
10565 | 97 |
# include <sys/wait.h> |
98 |
# include <time.h> |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
99 |
# include <unistd.h> |
10565 | 100 |
|
101 |
#if defined(__FreeBSD__) || defined(__NetBSD__) |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
102 |
#include <elf.h> |
10565 | 103 |
#endif |
104 |
||
105 |
#ifdef __APPLE__ |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
106 |
#include <mach-o/dyld.h> |
10565 | 107 |
#endif |
108 |
||
109 |
#ifndef MAP_ANONYMOUS |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
110 |
#define MAP_ANONYMOUS MAP_ANON |
10565 | 111 |
#endif |
112 |
||
113 |
#define MAX_PATH (2 * K) |
|
114 |
||
115 |
// for timer info max values which include all bits |
|
116 |
#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
|
117 |
||
118 |
//////////////////////////////////////////////////////////////////////////////// |
|
119 |
// global variables |
|
120 |
julong os::Bsd::_physical_memory = 0; |
|
121 |
||
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
122 |
#ifdef __APPLE__ |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
123 |
mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0}; |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
124 |
volatile uint64_t os::Bsd::_max_abstime = 0; |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
125 |
#else |
10565 | 126 |
int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL; |
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
127 |
#endif |
10565 | 128 |
pthread_t os::Bsd::_main_thread; |
129 |
int os::Bsd::_page_size = -1; |
|
130 |
||
131 |
static jlong initial_time_count=0; |
|
132 |
||
133 |
static int clock_tics_per_sec = 100; |
|
134 |
||
135 |
// For diagnostics to print a message once. see run_periodic_checks |
|
136 |
static sigset_t check_signal_done; |
|
14286 | 137 |
static bool check_signals = true; |
10565 | 138 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
139 |
// Signal number used to suspend/resume a thread |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
140 |
|
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
141 |
// do not use any signal number less than SIGSEGV, see 4355769 |
10565 | 142 |
static int SR_signum = SIGUSR2; |
143 |
sigset_t SR_sigset; |
|
144 |
||
145 |
||
146 |
//////////////////////////////////////////////////////////////////////////////// |
|
147 |
// utility functions |
|
148 |
||
149 |
static int SR_initialize(); |
|
150 |
||
151 |
julong os::available_memory() { |
|
152 |
return Bsd::available_memory(); |
|
153 |
} |
|
154 |
||
20683
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
155 |
// available here means free |
10565 | 156 |
julong os::Bsd::available_memory() { |
20683
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
157 |
uint64_t available = physical_memory() >> 2; |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
158 |
#ifdef __APPLE__ |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
159 |
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
160 |
vm_statistics64_data_t vmstat; |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
161 |
kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64, |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
162 |
(host_info64_t)&vmstat, &count); |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
163 |
assert(kerr == KERN_SUCCESS, |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
164 |
"host_statistics64 failed - check mach_host_self() and count"); |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
165 |
if (kerr == KERN_SUCCESS) { |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
166 |
available = vmstat.free_count * os::vm_page_size(); |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
167 |
} |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
168 |
#endif |
7b211e525ab8
8025942: os::Bsd::available_memory() needs implementation
hseigel
parents:
20377
diff
changeset
|
169 |
return available; |
10565 | 170 |
} |
171 |
||
172 |
julong os::physical_memory() { |
|
173 |
return Bsd::physical_memory(); |
|
174 |
} |
|
175 |
||
176 |
// Return true if user is running as root. |
|
177 |
||
178 |
bool os::have_special_privileges() { |
|
179 |
static bool init = false; |
|
180 |
static bool privileges = false; |
|
181 |
if (!init) { |
|
182 |
privileges = (getuid() != geteuid()) || (getgid() != getegid()); |
|
183 |
init = true; |
|
184 |
} |
|
185 |
return privileges; |
|
186 |
} |
|
187 |
||
188 |
||
189 |
||
190 |
// Cpu architecture string |
|
191 |
#if defined(ZERO) |
|
192 |
static char cpu_arch[] = ZERO_LIBARCH; |
|
193 |
#elif defined(IA64) |
|
194 |
static char cpu_arch[] = "ia64"; |
|
195 |
#elif defined(IA32) |
|
196 |
static char cpu_arch[] = "i386"; |
|
197 |
#elif defined(AMD64) |
|
198 |
static char cpu_arch[] = "amd64"; |
|
199 |
#elif defined(ARM) |
|
200 |
static char cpu_arch[] = "arm"; |
|
22806 | 201 |
#elif defined(PPC32) |
10565 | 202 |
static char cpu_arch[] = "ppc"; |
203 |
#elif defined(SPARC) |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
204 |
#ifdef _LP64 |
10565 | 205 |
static char cpu_arch[] = "sparcv9"; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
206 |
#else |
10565 | 207 |
static char cpu_arch[] = "sparc"; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
208 |
#endif |
10565 | 209 |
#else |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
210 |
#error Add appropriate cpu_arch setting |
10565 | 211 |
#endif |
212 |
||
11593 | 213 |
// Compiler variant |
214 |
#ifdef COMPILER2 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
215 |
#define COMPILER_VARIANT "server" |
11593 | 216 |
#else |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
217 |
#define COMPILER_VARIANT "client" |
11593 | 218 |
#endif |
10565 | 219 |
|
14286 | 220 |
|
10565 | 221 |
void os::Bsd::initialize_system_info() { |
222 |
int mib[2]; |
|
223 |
size_t len; |
|
224 |
int cpu_val; |
|
15231
cddea19288cf
8006431: os::Bsd::initialize_system_info() sets _physical_memory too large
brutisso
parents:
15096
diff
changeset
|
225 |
julong mem_val; |
10565 | 226 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
227 |
// get processors count via hw.ncpus sysctl |
10565 | 228 |
mib[0] = CTL_HW; |
229 |
mib[1] = HW_NCPU; |
|
230 |
len = sizeof(cpu_val); |
|
231 |
if (sysctl(mib, 2, &cpu_val, &len, NULL, 0) != -1 && cpu_val >= 1) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
232 |
assert(len == sizeof(cpu_val), "unexpected data size"); |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
233 |
set_processor_count(cpu_val); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
234 |
} else { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
235 |
set_processor_count(1); // fallback |
10565 | 236 |
} |
237 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
238 |
// get physical memory via hw.memsize sysctl (hw.memsize is used |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
239 |
// since it returns a 64 bit value) |
10565 | 240 |
mib[0] = CTL_HW; |
20373
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
241 |
|
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
242 |
#if defined (HW_MEMSIZE) // Apple |
15231
cddea19288cf
8006431: os::Bsd::initialize_system_info() sets _physical_memory too large
brutisso
parents:
15096
diff
changeset
|
243 |
mib[1] = HW_MEMSIZE; |
20373
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
244 |
#elif defined(HW_PHYSMEM) // Most of BSD |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
245 |
mib[1] = HW_PHYSMEM; |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
246 |
#elif defined(HW_REALMEM) // Old FreeBSD |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
247 |
mib[1] = HW_REALMEM; |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
248 |
#else |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
249 |
#error No ways to get physmem |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
250 |
#endif |
5d68702ea998
8025283: Nits in os_bsd file breaks compilation of open hotspot
dsamersoff
parents:
19986
diff
changeset
|
251 |
|
10565 | 252 |
len = sizeof(mem_val); |
15231
cddea19288cf
8006431: os::Bsd::initialize_system_info() sets _physical_memory too large
brutisso
parents:
15096
diff
changeset
|
253 |
if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
254 |
assert(len == sizeof(mem_val), "unexpected data size"); |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
255 |
_physical_memory = mem_val; |
15231
cddea19288cf
8006431: os::Bsd::initialize_system_info() sets _physical_memory too large
brutisso
parents:
15096
diff
changeset
|
256 |
} else { |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
257 |
_physical_memory = 256 * 1024 * 1024; // fallback (XXXBSD?) |
15231
cddea19288cf
8006431: os::Bsd::initialize_system_info() sets _physical_memory too large
brutisso
parents:
15096
diff
changeset
|
258 |
} |
10565 | 259 |
|
260 |
#ifdef __OpenBSD__ |
|
261 |
{ |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
262 |
// limit _physical_memory memory view on OpenBSD since |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
263 |
// datasize rlimit restricts us anyway. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
264 |
struct rlimit limits; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
265 |
getrlimit(RLIMIT_DATA, &limits); |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
266 |
_physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur); |
10565 | 267 |
} |
268 |
#endif |
|
269 |
} |
|
270 |
||
10739 | 271 |
#ifdef __APPLE__ |
272 |
static const char *get_home() { |
|
273 |
const char *home_dir = ::getenv("HOME"); |
|
274 |
if ((home_dir == NULL) || (*home_dir == '\0')) { |
|
275 |
struct passwd *passwd_info = getpwuid(geteuid()); |
|
276 |
if (passwd_info != NULL) { |
|
277 |
home_dir = passwd_info->pw_dir; |
|
278 |
} |
|
279 |
} |
|
280 |
||
281 |
return home_dir; |
|
282 |
} |
|
283 |
#endif |
|
284 |
||
10565 | 285 |
void os::init_system_properties_values() { |
286 |
// The next steps are taken in the product version: |
|
287 |
// |
|
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
288 |
// Obtain the JAVA_HOME value from the location of libjvm.so. |
10565 | 289 |
// This library should be located at: |
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
290 |
// <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm.so. |
10565 | 291 |
// |
292 |
// If "/jre/lib/" appears at the right place in the path, then we |
|
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
293 |
// assume libjvm.so is installed in a JDK and we use this path. |
10565 | 294 |
// |
295 |
// Otherwise exit with message: "Could not create the Java virtual machine." |
|
296 |
// |
|
297 |
// The following extra steps are taken in the debugging version: |
|
298 |
// |
|
299 |
// If "/jre/lib/" does NOT appear at the right place in the path |
|
300 |
// instead of exit check for $JAVA_HOME environment variable. |
|
301 |
// |
|
302 |
// If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>, |
|
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
303 |
// then we append a fake suffix "hotspot/libjvm.so" to this path so |
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
304 |
// it looks like libjvm.so is installed there |
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
305 |
// <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm.so. |
10565 | 306 |
// |
307 |
// Otherwise exit. |
|
308 |
// |
|
309 |
// Important note: if the location of libjvm.so changes this |
|
310 |
// code needs to be changed accordingly. |
|
311 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
312 |
// See ld(1): |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
313 |
// The linker uses the following search paths to locate required |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
314 |
// shared libraries: |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
315 |
// 1: ... |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
316 |
// ... |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
317 |
// 7: The default directories, normally /lib and /usr/lib. |
10565 | 318 |
#ifndef DEFAULT_LIBPATH |
52734
d537553ed639
8214332: Add a flag for overriding default JNI library search path
dholmes
parents:
52581
diff
changeset
|
319 |
#ifndef OVERRIDE_LIBPATH |
d537553ed639
8214332: Add a flag for overriding default JNI library search path
dholmes
parents:
52581
diff
changeset
|
320 |
#define DEFAULT_LIBPATH "/lib:/usr/lib" |
d537553ed639
8214332: Add a flag for overriding default JNI library search path
dholmes
parents:
52581
diff
changeset
|
321 |
#else |
d537553ed639
8214332: Add a flag for overriding default JNI library search path
dholmes
parents:
52581
diff
changeset
|
322 |
#define DEFAULT_LIBPATH OVERRIDE_LIBPATH |
d537553ed639
8214332: Add a flag for overriding default JNI library search path
dholmes
parents:
52581
diff
changeset
|
323 |
#endif |
10565 | 324 |
#endif |
325 |
||
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
326 |
// Base path of extensions installed on the system. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
327 |
#define SYS_EXT_DIR "/usr/java/packages" |
10565 | 328 |
#define EXTENSIONS_DIR "/lib/ext" |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
329 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
330 |
#ifndef __APPLE__ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
331 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
332 |
// Buffer that fits several sprintfs. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
333 |
// Note that the space for the colon and the trailing null are provided |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
334 |
// by the nulls included by the sizeof operator. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
335 |
const size_t bufsize = |
27562 | 336 |
MAX2((size_t)MAXPATHLEN, // For dll_dir & friends. |
337 |
(size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir |
|
58083 | 338 |
char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
339 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
340 |
// sysclasspath, java_home, dll_dir |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
341 |
{ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
342 |
char *pslash; |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
343 |
os::jvm_path(buf, bufsize); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
344 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
345 |
// Found the full path to libjvm.so. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
346 |
// Now cut the path to <java_home>/jre if we can. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
347 |
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
348 |
pslash = strrchr(buf, '/'); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
349 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
350 |
*pslash = '\0'; // Get rid of /{client|server|hotspot}. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
351 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
352 |
Arguments::set_dll_dir(buf); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
353 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
354 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
355 |
pslash = strrchr(buf, '/'); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
356 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
357 |
*pslash = '\0'; // Get rid of /<arch>. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
358 |
pslash = strrchr(buf, '/'); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
359 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
360 |
*pslash = '\0'; // Get rid of /lib. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
361 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
362 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
363 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
364 |
Arguments::set_java_home(buf); |
50962
dbe8aa90d4dd
8205946: JVM crash after call to ClassLoader::setup_bootstrap_search_path()
ccheung
parents:
50930
diff
changeset
|
365 |
if (!set_boot_path('/', ':')) { |
dbe8aa90d4dd
8205946: JVM crash after call to ClassLoader::setup_bootstrap_search_path()
ccheung
parents:
50930
diff
changeset
|
366 |
vm_exit_during_initialization("Failed setting boot class path.", NULL); |
dbe8aa90d4dd
8205946: JVM crash after call to ClassLoader::setup_bootstrap_search_path()
ccheung
parents:
50930
diff
changeset
|
367 |
} |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
368 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
369 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
370 |
// Where to look for native libraries. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
371 |
// |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
372 |
// Note: Due to a legacy implementation, most of the library path |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
373 |
// is set in the launcher. This was to accomodate linking restrictions |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
374 |
// on legacy Bsd implementations (which are no longer supported). |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
375 |
// Eventually, all the library path setting will be done here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
376 |
// |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
377 |
// However, to prevent the proliferation of improperly built native |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
378 |
// libraries, the new path component /usr/java/packages is added here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
379 |
// Eventually, all the library path setting will be done here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
380 |
{ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
381 |
// Get the user setting of LD_LIBRARY_PATH, and prepended it. It |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
382 |
// should always exist (until the legacy problem cited above is |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
383 |
// addressed). |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
384 |
const char *v = ::getenv("LD_LIBRARY_PATH"); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
385 |
const char *v_colon = ":"; |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
386 |
if (v == NULL) { v = ""; v_colon = ""; } |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
387 |
// That's +1 for the colon and +1 for the trailing '\0'. |
58083 | 388 |
char *ld_library_path = NEW_C_HEAP_ARRAY(char, |
389 |
strlen(v) + 1 + |
|
390 |
sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1, |
|
391 |
mtInternal); |
|
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
392 |
sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
393 |
Arguments::set_library_path(ld_library_path); |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27474
diff
changeset
|
394 |
FREE_C_HEAP_ARRAY(char, ld_library_path); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
395 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
396 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
397 |
// Extensions directories. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
398 |
sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home()); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
399 |
Arguments::set_ext_dirs(buf); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
400 |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27474
diff
changeset
|
401 |
FREE_C_HEAP_ARRAY(char, buf); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
402 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
403 |
#else // __APPLE__ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
404 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
405 |
#define SYS_EXTENSIONS_DIR "/Library/Java/Extensions" |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
406 |
#define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java" |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
407 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
408 |
const char *user_home_dir = get_home(); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
409 |
// The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
410 |
size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) + |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
411 |
sizeof(SYS_EXTENSIONS_DIRS); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
412 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
413 |
// Buffer that fits several sprintfs. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
414 |
// Note that the space for the colon and the trailing null are provided |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
415 |
// by the nulls included by the sizeof operator. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
416 |
const size_t bufsize = |
27562 | 417 |
MAX2((size_t)MAXPATHLEN, // for dll_dir & friends. |
418 |
(size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size); // extensions dir |
|
58083 | 419 |
char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
420 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
421 |
// sysclasspath, java_home, dll_dir |
10565 | 422 |
{ |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
423 |
char *pslash; |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
424 |
os::jvm_path(buf, bufsize); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
425 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
426 |
// Found the full path to libjvm.so. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
427 |
// Now cut the path to <java_home>/jre if we can. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
428 |
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
429 |
pslash = strrchr(buf, '/'); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
430 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
431 |
*pslash = '\0'; // Get rid of /{client|server|hotspot}. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
432 |
} |
33583
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
433 |
#ifdef STATIC_BUILD |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
434 |
strcat(buf, "/lib"); |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
435 |
#endif |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
436 |
|
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
437 |
Arguments::set_dll_dir(buf); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
438 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
439 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
440 |
pslash = strrchr(buf, '/'); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
441 |
if (pslash != NULL) { |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
442 |
*pslash = '\0'; // Get rid of /lib. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
443 |
} |
10565 | 444 |
} |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
445 |
Arguments::set_java_home(buf); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
446 |
set_boot_path('/', ':'); |
10565 | 447 |
} |
448 |
||
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
449 |
// Where to look for native libraries. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
450 |
// |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
451 |
// Note: Due to a legacy implementation, most of the library path |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
452 |
// is set in the launcher. This was to accomodate linking restrictions |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
453 |
// on legacy Bsd implementations (which are no longer supported). |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
454 |
// Eventually, all the library path setting will be done here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
455 |
// |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
456 |
// However, to prevent the proliferation of improperly built native |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
457 |
// libraries, the new path component /usr/java/packages is added here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
458 |
// Eventually, all the library path setting will be done here. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
459 |
{ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
460 |
// Get the user setting of LD_LIBRARY_PATH, and prepended it. It |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
461 |
// should always exist (until the legacy problem cited above is |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
462 |
// addressed). |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
463 |
// Prepend the default path with the JAVA_LIBRARY_PATH so that the app launcher code |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
464 |
// can specify a directory inside an app wrapper |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
465 |
const char *l = ::getenv("JAVA_LIBRARY_PATH"); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
466 |
const char *l_colon = ":"; |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
467 |
if (l == NULL) { l = ""; l_colon = ""; } |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
468 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
469 |
const char *v = ::getenv("DYLD_LIBRARY_PATH"); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
470 |
const char *v_colon = ":"; |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
471 |
if (v == NULL) { v = ""; v_colon = ""; } |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
472 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
473 |
// Apple's Java6 has "." at the beginning of java.library.path. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
474 |
// OpenJDK on Windows has "." at the end of java.library.path. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
475 |
// OpenJDK on Linux and Solaris don't have "." in java.library.path |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
476 |
// at all. To ease the transition from Apple's Java6 to OpenJDK7, |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
477 |
// "." is appended to the end of java.library.path. Yes, this |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
478 |
// could cause a change in behavior, but Apple's Java6 behavior |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
479 |
// can be achieved by putting "." at the beginning of the |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
480 |
// JAVA_LIBRARY_PATH environment variable. |
58083 | 481 |
char *ld_library_path = NEW_C_HEAP_ARRAY(char, |
482 |
strlen(v) + 1 + strlen(l) + 1 + |
|
483 |
system_ext_size + 3, |
|
484 |
mtInternal); |
|
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
485 |
sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.", |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
486 |
v, v_colon, l, l_colon, user_home_dir); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
487 |
Arguments::set_library_path(ld_library_path); |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27474
diff
changeset
|
488 |
FREE_C_HEAP_ARRAY(char, ld_library_path); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
489 |
} |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
490 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
491 |
// Extensions directories. |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
492 |
// |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
493 |
// Note that the space for the colon and the trailing null are provided |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
494 |
// by the nulls included by the sizeof operator (so actually one byte more |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
495 |
// than necessary is allocated). |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
496 |
sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS, |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
497 |
user_home_dir, Arguments::get_java_home()); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
498 |
Arguments::set_ext_dirs(buf); |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
499 |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27474
diff
changeset
|
500 |
FREE_C_HEAP_ARRAY(char, buf); |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
501 |
|
10739 | 502 |
#undef SYS_EXTENSIONS_DIR |
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
503 |
#undef SYS_EXTENSIONS_DIRS |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
504 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
505 |
#endif // __APPLE__ |
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
506 |
|
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
507 |
#undef SYS_EXT_DIR |
10565 | 508 |
#undef EXTENSIONS_DIR |
509 |
} |
|
510 |
||
511 |
//////////////////////////////////////////////////////////////////////////////// |
|
512 |
// breakpoint support |
|
513 |
||
514 |
void os::breakpoint() { |
|
515 |
BREAKPOINT; |
|
516 |
} |
|
517 |
||
518 |
extern "C" void breakpoint() { |
|
519 |
// use debugger to set breakpoint here |
|
520 |
} |
|
521 |
||
522 |
//////////////////////////////////////////////////////////////////////////////// |
|
523 |
// signal support |
|
524 |
||
525 |
debug_only(static bool signal_sets_initialized = false); |
|
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
526 |
static sigset_t unblocked_sigs, vm_sigs; |
10565 | 527 |
|
528 |
void os::Bsd::signal_sets_init() { |
|
529 |
// Should also have an assertion stating we are still single-threaded. |
|
530 |
assert(!signal_sets_initialized, "Already initialized"); |
|
531 |
// Fill in signals that are necessarily unblocked for all threads in |
|
532 |
// the VM. Currently, we unblock the following signals: |
|
533 |
// SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden |
|
534 |
// by -Xrs (=ReduceSignalUsage)); |
|
535 |
// BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all |
|
536 |
// other threads. The "ReduceSignalUsage" boolean tells us not to alter |
|
537 |
// the dispositions or masks wrt these signals. |
|
538 |
// Programs embedding the VM that want to use the above signals for their |
|
539 |
// own purposes must, at this time, use the "-Xrs" option to prevent |
|
540 |
// interference with shutdown hooks and BREAK_SIGNAL thread dumping. |
|
541 |
// (See bug 4345157, and other related bugs). |
|
542 |
// In reality, though, unblocking these signals is really a nop, since |
|
543 |
// these signals are not blocked by default. |
|
544 |
sigemptyset(&unblocked_sigs); |
|
545 |
sigaddset(&unblocked_sigs, SIGILL); |
|
546 |
sigaddset(&unblocked_sigs, SIGSEGV); |
|
547 |
sigaddset(&unblocked_sigs, SIGBUS); |
|
548 |
sigaddset(&unblocked_sigs, SIGFPE); |
|
549 |
sigaddset(&unblocked_sigs, SR_signum); |
|
550 |
||
551 |
if (!ReduceSignalUsage) { |
|
50177
9806f23d5e5e
8134537: Much nearly duplicated code for sun.misc.Signal support
coleenp
parents:
49449
diff
changeset
|
552 |
if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) { |
10565 | 553 |
sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); |
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
554 |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
555 |
} |
50177
9806f23d5e5e
8134537: Much nearly duplicated code for sun.misc.Signal support
coleenp
parents:
49449
diff
changeset
|
556 |
if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) { |
10565 | 557 |
sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL); |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
558 |
} |
50177
9806f23d5e5e
8134537: Much nearly duplicated code for sun.misc.Signal support
coleenp
parents:
49449
diff
changeset
|
559 |
if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) { |
10565 | 560 |
sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL); |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
561 |
} |
10565 | 562 |
} |
563 |
// Fill in signals that are blocked by all but the VM thread. |
|
564 |
sigemptyset(&vm_sigs); |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
565 |
if (!ReduceSignalUsage) { |
10565 | 566 |
sigaddset(&vm_sigs, BREAK_SIGNAL); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
567 |
} |
10565 | 568 |
debug_only(signal_sets_initialized = true); |
569 |
||
570 |
} |
|
571 |
||
572 |
// These are signals that are unblocked while a thread is running Java. |
|
573 |
// (For some reason, they get blocked by default.) |
|
574 |
sigset_t* os::Bsd::unblocked_signals() { |
|
575 |
assert(signal_sets_initialized, "Not initialized"); |
|
576 |
return &unblocked_sigs; |
|
577 |
} |
|
578 |
||
579 |
// These are the signals that are blocked while a (non-VM) thread is |
|
580 |
// running Java. Only the VM thread handles these signals. |
|
581 |
sigset_t* os::Bsd::vm_signals() { |
|
582 |
assert(signal_sets_initialized, "Not initialized"); |
|
583 |
return &vm_sigs; |
|
584 |
} |
|
585 |
||
586 |
void os::Bsd::hotspot_sigmask(Thread* thread) { |
|
587 |
||
588 |
//Save caller's signal mask before setting VM signal mask |
|
589 |
sigset_t caller_sigmask; |
|
590 |
pthread_sigmask(SIG_BLOCK, NULL, &caller_sigmask); |
|
591 |
||
592 |
OSThread* osthread = thread->osthread(); |
|
593 |
osthread->set_caller_sigmask(caller_sigmask); |
|
594 |
||
595 |
pthread_sigmask(SIG_UNBLOCK, os::Bsd::unblocked_signals(), NULL); |
|
596 |
||
597 |
if (!ReduceSignalUsage) { |
|
598 |
if (thread->is_VM_thread()) { |
|
599 |
// Only the VM thread handles BREAK_SIGNAL ... |
|
600 |
pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL); |
|
601 |
} else { |
|
602 |
// ... all other threads block BREAK_SIGNAL |
|
603 |
pthread_sigmask(SIG_BLOCK, vm_signals(), NULL); |
|
604 |
} |
|
605 |
} |
|
606 |
} |
|
607 |
||
608 |
||
609 |
////////////////////////////////////////////////////////////////////////////// |
|
610 |
// create new thread |
|
611 |
||
10739 | 612 |
#ifdef __APPLE__ |
613 |
// library handle for calling objc_registerThreadWithCollector() |
|
614 |
// without static linking to the libobjc library |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
615 |
#define OBJC_LIB "/usr/lib/libobjc.dylib" |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
616 |
#define OBJC_GCREGISTER "objc_registerThreadWithCollector" |
10739 | 617 |
typedef void (*objc_registerThreadWithCollector_t)(); |
618 |
extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction; |
|
619 |
objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL; |
|
620 |
#endif |
|
621 |
||
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
622 |
#ifdef __APPLE__ |
19531 | 623 |
static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) { |
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
624 |
// Additional thread_id used to correlate threads in SA |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
625 |
thread_identifier_info_data_t m_ident_info; |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
626 |
mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
627 |
|
19531 | 628 |
thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO, |
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
629 |
(thread_info_t) &m_ident_info, &count); |
19531 | 630 |
|
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
631 |
return m_ident_info.thread_id; |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
632 |
} |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
633 |
#endif |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
15234
diff
changeset
|
634 |
|
10565 | 635 |
// Thread start routine for all newly created threads |
38290
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
636 |
static void *thread_native_entry(Thread *thread) { |
52302
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
637 |
|
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
638 |
thread->record_stack_base_and_size(); |
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
639 |
|
10565 | 640 |
// Try to randomize the cache line index of hot stack frames. |
641 |
// This helps when threads of the same stack traces evict each other's |
|
642 |
// cache lines. The threads can be either from the same JVM instance, or |
|
643 |
// from different JVM instances. The benefit is especially true for |
|
644 |
// processors with hyperthreading technology. |
|
645 |
static int counter = 0; |
|
646 |
int pid = os::current_process_id(); |
|
647 |
alloca(((pid ^ counter++) & 7) * 128); |
|
648 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
34621
diff
changeset
|
649 |
thread->initialize_thread_current(); |
10565 | 650 |
|
651 |
OSThread* osthread = thread->osthread(); |
|
652 |
Monitor* sync = osthread->startThread_lock(); |
|
653 |
||
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
654 |
osthread->set_thread_id(os::Bsd::gettid()); |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
655 |
|
36379
0c596dc28ed7
8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
36355
diff
changeset
|
656 |
log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", |
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
657 |
os::current_thread_id(), (uintx) pthread_self()); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
658 |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
659 |
#ifdef __APPLE__ |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
660 |
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id()); |
19531 | 661 |
guarantee(unique_thread_id != 0, "unique thread id was not found"); |
662 |
osthread->set_unique_thread_id(unique_thread_id); |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
663 |
#endif |
10565 | 664 |
// initialize signal mask for this thread |
665 |
os::Bsd::hotspot_sigmask(thread); |
|
666 |
||
667 |
// initialize floating point control register |
|
668 |
os::Bsd::init_thread_fpu_state(); |
|
669 |
||
10739 | 670 |
#ifdef __APPLE__ |
671 |
// register thread with objc gc |
|
672 |
if (objc_registerThreadWithCollectorFunction != NULL) { |
|
673 |
objc_registerThreadWithCollectorFunction(); |
|
674 |
} |
|
675 |
#endif |
|
676 |
||
10565 | 677 |
// handshaking with parent thread |
678 |
{ |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54420
diff
changeset
|
679 |
MutexLocker ml(sync, Mutex::_no_safepoint_check_flag); |
10565 | 680 |
|
681 |
// notify parent thread |
|
682 |
osthread->set_state(INITIALIZED); |
|
683 |
sync->notify_all(); |
|
684 |
||
685 |
// wait until os::start_thread() |
|
686 |
while (osthread->get_state() == INITIALIZED) { |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54420
diff
changeset
|
687 |
sync->wait_without_safepoint_check(); |
10565 | 688 |
} |
689 |
} |
|
690 |
||
691 |
// call one more level start routine |
|
52302
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
692 |
thread->call_run(); |
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
693 |
|
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
694 |
// Note: at this point the thread object may already have deleted itself. |
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
695 |
// Prevent dereferencing it from here on out. |
912b79d983d9
8212173: Thread._stack_base/_stack_size initialized too late for new threads
stuefe
parents:
52109
diff
changeset
|
696 |
thread = NULL; |
10565 | 697 |
|
36379
0c596dc28ed7
8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
36355
diff
changeset
|
698 |
log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", |
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
699 |
os::current_thread_id(), (uintx) pthread_self()); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
700 |
|
10565 | 701 |
return 0; |
702 |
} |
|
703 |
||
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40667
diff
changeset
|
704 |
bool os::create_thread(Thread* thread, ThreadType thr_type, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40667
diff
changeset
|
705 |
size_t req_stack_size) { |
10565 | 706 |
assert(thread->osthread() == NULL, "caller responsible"); |
707 |
||
708 |
// Allocate the OSThread object |
|
709 |
OSThread* osthread = new OSThread(NULL, NULL); |
|
710 |
if (osthread == NULL) { |
|
711 |
return false; |
|
712 |
} |
|
713 |
||
714 |
// set the correct thread state |
|
715 |
osthread->set_thread_type(thr_type); |
|
716 |
||
717 |
// Initial state is ALLOCATED but not INITIALIZED |
|
718 |
osthread->set_state(ALLOCATED); |
|
719 |
||
720 |
thread->set_osthread(osthread); |
|
721 |
||
722 |
// init thread attributes |
|
723 |
pthread_attr_t attr; |
|
724 |
pthread_attr_init(&attr); |
|
725 |
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
|
726 |
||
32080
9d2ace436482
8080298: Clean up os::...::supports_variable_stack_size()
dholmes
parents:
31963
diff
changeset
|
727 |
// calculate stack size if it's not specified by caller |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40667
diff
changeset
|
728 |
size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); |
46346
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
46331
diff
changeset
|
729 |
int status = pthread_attr_setstacksize(&attr, stack_size); |
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
46331
diff
changeset
|
730 |
assert_status(status == 0, status, "pthread_attr_setstacksize"); |
32080
9d2ace436482
8080298: Clean up os::...::supports_variable_stack_size()
dholmes
parents:
31963
diff
changeset
|
731 |
|
10565 | 732 |
ThreadState state; |
733 |
||
734 |
{ |
|
735 |
pthread_t tid; |
|
38290
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
736 |
int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); |
10565 | 737 |
|
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
738 |
char buf[64]; |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
739 |
if (ret == 0) { |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
740 |
log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
741 |
(uintx) tid, os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
742 |
} else { |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
743 |
log_warning(os, thread)("Failed to start thread - pthread_create failed (%s) for attributes: %s.", |
37113 | 744 |
os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); |
54280
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
745 |
// Log some OS information which might explain why creating the thread failed. |
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
746 |
log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); |
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
747 |
LogStream st(Log(os, thread)::info()); |
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
748 |
os::Posix::print_rlimit_info(&st); |
a33c42262338
8220570: Additonal trace when native thread creation fails
rschmelter
parents:
54090
diff
changeset
|
749 |
os::print_memory_info(&st); |
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
750 |
} |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
751 |
|
10565 | 752 |
pthread_attr_destroy(&attr); |
753 |
||
754 |
if (ret != 0) { |
|
755 |
// Need to clean up stuff we've allocated so far |
|
756 |
thread->set_osthread(NULL); |
|
757 |
delete osthread; |
|
758 |
return false; |
|
759 |
} |
|
760 |
||
761 |
// Store pthread info into the OSThread |
|
762 |
osthread->set_pthread_id(tid); |
|
763 |
||
764 |
// Wait until child thread is either initialized or aborted |
|
765 |
{ |
|
766 |
Monitor* sync_with_child = osthread->startThread_lock(); |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54420
diff
changeset
|
767 |
MutexLocker ml(sync_with_child, Mutex::_no_safepoint_check_flag); |
10565 | 768 |
while ((state = osthread->get_state()) == ALLOCATED) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54420
diff
changeset
|
769 |
sync_with_child->wait_without_safepoint_check(); |
10565 | 770 |
} |
771 |
} |
|
772 |
||
773 |
} |
|
774 |
||
775 |
// Aborted due to thread limit being reached |
|
776 |
if (state == ZOMBIE) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
777 |
thread->set_osthread(NULL); |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
778 |
delete osthread; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
779 |
return false; |
10565 | 780 |
} |
781 |
||
782 |
// The thread is returned suspended (in state INITIALIZED), |
|
783 |
// and is started higher up in the call chain |
|
784 |
assert(state == INITIALIZED, "race condition"); |
|
785 |
return true; |
|
786 |
} |
|
787 |
||
788 |
///////////////////////////////////////////////////////////////////////////// |
|
789 |
// attach existing thread |
|
790 |
||
791 |
// bootstrap the main thread |
|
792 |
bool os::create_main_thread(JavaThread* thread) { |
|
793 |
assert(os::Bsd::_main_thread == pthread_self(), "should be called inside main thread"); |
|
794 |
return create_attached_thread(thread); |
|
795 |
} |
|
796 |
||
797 |
bool os::create_attached_thread(JavaThread* thread) { |
|
798 |
#ifdef ASSERT |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
799 |
thread->verify_not_published(); |
10565 | 800 |
#endif |
801 |
||
802 |
// Allocate the OSThread object |
|
803 |
OSThread* osthread = new OSThread(NULL, NULL); |
|
804 |
||
805 |
if (osthread == NULL) { |
|
806 |
return false; |
|
807 |
} |
|
808 |
||
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
809 |
osthread->set_thread_id(os::Bsd::gettid()); |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
810 |
|
10565 | 811 |
// Store pthread info into the OSThread |
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
812 |
#ifdef __APPLE__ |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
813 |
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id()); |
19531 | 814 |
guarantee(unique_thread_id != 0, "just checking"); |
815 |
osthread->set_unique_thread_id(unique_thread_id); |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
816 |
#endif |
10565 | 817 |
osthread->set_pthread_id(::pthread_self()); |
818 |
||
819 |
// initialize floating point control register |
|
820 |
os::Bsd::init_thread_fpu_state(); |
|
821 |
||
822 |
// Initial thread state is RUNNABLE |
|
823 |
osthread->set_state(RUNNABLE); |
|
824 |
||
825 |
thread->set_osthread(osthread); |
|
826 |
||
827 |
// initialize signal mask for this thread |
|
828 |
// and save the caller's signal mask |
|
829 |
os::Bsd::hotspot_sigmask(thread); |
|
830 |
||
36379
0c596dc28ed7
8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
36355
diff
changeset
|
831 |
log_info(os, thread)("Thread attached (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", |
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
832 |
os::current_thread_id(), (uintx) pthread_self()); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36087
diff
changeset
|
833 |
|
10565 | 834 |
return true; |
835 |
} |
|
836 |
||
837 |
void os::pd_start_thread(Thread* thread) { |
|
838 |
OSThread * osthread = thread->osthread(); |
|
839 |
assert(osthread->get_state() != INITIALIZED, "just checking"); |
|
840 |
Monitor* sync_with_child = osthread->startThread_lock(); |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54420
diff
changeset
|
841 |
MutexLocker ml(sync_with_child, Mutex::_no_safepoint_check_flag); |
10565 | 842 |
sync_with_child->notify(); |
843 |
} |
|
844 |
||
845 |
// Free Bsd resources related to the OSThread |
|
846 |
void os::free_thread(OSThread* osthread) { |
|
847 |
assert(osthread != NULL, "osthread not set"); |
|
848 |
||
38290
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
849 |
// We are told to free resources of the argument thread, |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
850 |
// but we can only really operate on the current thread. |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
851 |
assert(Thread::current()->osthread() == osthread, |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
852 |
"os::free_thread but not current thread"); |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
853 |
|
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
854 |
// Restore caller's signal mask |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
855 |
sigset_t sigmask = osthread->caller_sigmask(); |
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
37465
diff
changeset
|
856 |
pthread_sigmask(SIG_SETMASK, &sigmask, NULL); |
10565 | 857 |
|
858 |
delete osthread; |
|
859 |
} |
|
860 |
||
861 |
//////////////////////////////////////////////////////////////////////////////// |
|
862 |
// time support |
|
863 |
||
864 |
// Time since start-up in seconds to a fine granularity. |
|
865 |
// Used by VMSelfDestructTimer and the MemProfiler. |
|
866 |
double os::elapsedTime() { |
|
867 |
||
21185
9d53434b1ef5
8027294: Prepare hotspot for non TOD based uptime counter
jbachorik
parents:
20683
diff
changeset
|
868 |
return ((double)os::elapsed_counter()) / os::elapsed_frequency(); |
10565 | 869 |
} |
870 |
||
871 |
jlong os::elapsed_counter() { |
|
21185
9d53434b1ef5
8027294: Prepare hotspot for non TOD based uptime counter
jbachorik
parents:
20683
diff
changeset
|
872 |
return javaTimeNanos() - initial_time_count; |
10565 | 873 |
} |
874 |
||
875 |
jlong os::elapsed_frequency() { |
|
21185
9d53434b1ef5
8027294: Prepare hotspot for non TOD based uptime counter
jbachorik
parents:
20683
diff
changeset
|
876 |
return NANOSECS_PER_SEC; // nanosecond resolution |
10565 | 877 |
} |
878 |
||
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17134
diff
changeset
|
879 |
bool os::supports_vtime() { return true; } |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17134
diff
changeset
|
880 |
|
10565 | 881 |
double os::elapsedVTime() { |
882 |
// better than nothing, but not much |
|
883 |
return elapsedTime(); |
|
884 |
} |
|
885 |
||
886 |
jlong os::javaTimeMillis() { |
|
887 |
timeval time; |
|
888 |
int status = gettimeofday(&time, NULL); |
|
889 |
assert(status != -1, "bsd error"); |
|
890 |
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000); |
|
891 |
} |
|
892 |
||
28737
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
893 |
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
894 |
timeval time; |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
895 |
int status = gettimeofday(&time, NULL); |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
896 |
assert(status != -1, "bsd error"); |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
897 |
seconds = jlong(time.tv_sec); |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
898 |
nanos = jlong(time.tv_usec) * 1000; |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
899 |
} |
ca4b6a6e5cc8
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28172
diff
changeset
|
900 |
|
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
901 |
#ifndef __APPLE__ |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
902 |
#ifndef CLOCK_MONOTONIC |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
903 |
#define CLOCK_MONOTONIC (1) |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
904 |
#endif |
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
905 |
#endif |
10565 | 906 |
|
907 |
#ifdef __APPLE__ |
|
908 |
void os::Bsd::clock_init() { |
|
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
909 |
mach_timebase_info(&_timebase_info); |
10565 | 910 |
} |
14286 | 911 |
#else |
10565 | 912 |
void os::Bsd::clock_init() { |
913 |
struct timespec res; |
|
914 |
struct timespec tp; |
|
915 |
if (::clock_getres(CLOCK_MONOTONIC, &res) == 0 && |
|
916 |
::clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { |
|
917 |
// yes, monotonic clock is supported |
|
918 |
_clock_gettime = ::clock_gettime; |
|
919 |
} |
|
920 |
} |
|
921 |
#endif |
|
922 |
||
923 |
||
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
924 |
|
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
925 |
#ifdef __APPLE__ |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
926 |
|
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
927 |
jlong os::javaTimeNanos() { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
928 |
const uint64_t tm = mach_absolute_time(); |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
929 |
const uint64_t now = (tm * Bsd::_timebase_info.numer) / Bsd::_timebase_info.denom; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
930 |
const uint64_t prev = Bsd::_max_abstime; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
931 |
if (now <= prev) { |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
932 |
return prev; // same or retrograde time; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
933 |
} |
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46630
diff
changeset
|
934 |
const uint64_t obsv = Atomic::cmpxchg(now, &Bsd::_max_abstime, prev); |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
935 |
assert(obsv >= prev, "invariant"); // Monotonicity |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
936 |
// If the CAS succeeded then we're done and return "now". |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
937 |
// If the CAS failed and the observed value "obsv" is >= now then |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
938 |
// we should return "obsv". If the CAS failed and now > obsv > prv then |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
939 |
// some other thread raced this thread and installed a new value, in which case |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
940 |
// we could either (a) retry the entire operation, (b) retry trying to install now |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
941 |
// or (c) just return obsv. We use (c). No loop is required although in some cases |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
942 |
// we might discard a higher "now" value in deference to a slightly lower but freshly |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
943 |
// installed obsv value. That's entirely benign -- it admits no new orderings compared |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
944 |
// to (a) or (b) -- and greatly reduces coherence traffic. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
945 |
// We might also condition (c) on the magnitude of the delta between obsv and now. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
946 |
// Avoiding excessive CAS operations to hot RW locations is critical. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
947 |
// See https://blogs.oracle.com/dave/entry/cas_and_cache_trivia_invalidate |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
948 |
return (prev == obsv) ? now : obsv; |
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
949 |
} |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
950 |
|
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
951 |
#else // __APPLE__ |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
952 |
|
10565 | 953 |
jlong os::javaTimeNanos() { |
22891
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22784
diff
changeset
|
954 |
if (os::supports_monotonic_clock()) { |
10565 | 955 |
struct timespec tp; |
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
956 |
int status = Bsd::_clock_gettime(CLOCK_MONOTONIC, &tp); |
10565 | 957 |
assert(status == 0, "gettime error"); |
958 |
jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec); |
|
959 |
return result; |
|
960 |
} else { |
|
961 |
timeval time; |
|
962 |
int status = gettimeofday(&time, NULL); |
|
963 |
assert(status != -1, "bsd error"); |
|
964 |
jlong usecs = jlong(time.tv_sec) * (1000 * 1000) + jlong(time.tv_usec); |
|
965 |
return 1000 * usecs; |
|
966 |
} |
|
967 |
} |
|
968 |
||
24239
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
969 |
#endif // __APPLE__ |
db81abb281bc
8040140: System.nanoTime() is slow and non-monotonic on OS X
sla
parents:
23866
diff
changeset
|
970 |
|
10565 | 971 |
void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { |
22891
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22784
diff
changeset
|
972 |
if (os::supports_monotonic_clock()) { |
10565 | 973 |
info_ptr->max_value = ALL_64_BITS; |
974 |
||
975 |
// CLOCK_MONOTONIC - amount of time since some arbitrary point in the past |
|
976 |
info_ptr->may_skip_backward = false; // not subject to resetting or drifting |
|
977 |
info_ptr->may_skip_forward = false; // not subject to resetting or drifting |
|
978 |
} else { |
|
979 |
// gettimeofday - based on time in seconds since the Epoch thus does not wrap |
|
980 |
info_ptr->max_value = ALL_64_BITS; |
|
981 |
||
982 |
// gettimeofday is a real time clock so it skips |
|
983 |
info_ptr->may_skip_backward = true; |
|
984 |
info_ptr->may_skip_forward = true; |
|
985 |
} |
|
986 |
||
987 |
info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time |
|
988 |
} |
|
989 |
||
990 |
// Return the real, user, and system times in seconds from an |
|
991 |
// arbitrary fixed point in the past. |
|
992 |
bool os::getTimesSecs(double* process_real_time, |
|
993 |
double* process_user_time, |
|
994 |
double* process_system_time) { |
|
995 |
struct tms ticks; |
|
996 |
clock_t real_ticks = times(&ticks); |
|
997 |
||
998 |
if (real_ticks == (clock_t) (-1)) { |
|
999 |
return false; |
|
1000 |
} else { |
|
1001 |
double ticks_per_second = (double) clock_tics_per_sec; |
|
1002 |
*process_user_time = ((double) ticks.tms_utime) / ticks_per_second; |
|
1003 |
*process_system_time = ((double) ticks.tms_stime) / ticks_per_second; |
|
1004 |
*process_real_time = ((double) real_ticks) / ticks_per_second; |
|
1005 |
||
1006 |
return true; |
|
1007 |
} |
|
1008 |
} |
|
1009 |
||
1010 |
||
1011 |
char * os::local_time_string(char *buf, size_t buflen) { |
|
1012 |
struct tm t; |
|
1013 |
time_t long_time; |
|
1014 |
time(&long_time); |
|
1015 |
localtime_r(&long_time, &t); |
|
1016 |
jio_snprintf(buf, buflen, "%d-%02d-%02d %02d:%02d:%02d", |
|
1017 |
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, |
|
1018 |
t.tm_hour, t.tm_min, t.tm_sec); |
|
1019 |
return buf; |
|
1020 |
} |
|
1021 |
||
1022 |
struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { |
|
1023 |
return localtime_r(clock, res); |
|
1024 |
} |
|
1025 |
||
1026 |
//////////////////////////////////////////////////////////////////////////////// |
|
1027 |
// runtime exit support |
|
1028 |
||
1029 |
// Note: os::shutdown() might be called very early during initialization, or |
|
1030 |
// called from signal handler. Before adding something to os::shutdown(), make |
|
1031 |
// sure it is async-safe and can handle partially initialized VM. |
|
1032 |
void os::shutdown() { |
|
1033 |
||
1034 |
// allow PerfMemory to attempt cleanup of any persistent resources |
|
1035 |
perfMemory_exit(); |
|
1036 |
||
1037 |
// needs to remove object in file system |
|
1038 |
AttachListener::abort(); |
|
1039 |
||
1040 |
// flush buffered output, finish log files |
|
1041 |
ostream_abort(); |
|
1042 |
||
1043 |
// Check for abort hook |
|
1044 |
abort_hook_t abort_hook = Arguments::abort_hook(); |
|
1045 |
if (abort_hook != NULL) { |
|
1046 |
abort_hook(); |
|
1047 |
} |
|
1048 |
||
1049 |
} |
|
1050 |
||
1051 |
// Note: os::abort() might be called very early during initialization, or |
|
1052 |
// called from signal handler. Before adding something to os::abort(), make |
|
1053 |
// sure it is async-safe and can handle partially initialized VM. |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
1054 |
void os::abort(bool dump_core, void* siginfo, const void* context) { |
10565 | 1055 |
os::shutdown(); |
1056 |
if (dump_core) { |
|
1057 |
#ifndef PRODUCT |
|
1058 |
fdStream out(defaultStream::output_fd()); |
|
1059 |
out.print_raw("Current thread is "); |
|
1060 |
char buf[16]; |
|
1061 |
jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); |
|
1062 |
out.print_raw_cr(buf); |
|
1063 |
out.print_raw_cr("Dumping core ..."); |
|
1064 |
#endif |
|
1065 |
::abort(); // dump core |
|
1066 |
} |
|
1067 |
||
1068 |
::exit(1); |
|
1069 |
} |
|
1070 |
||
1071 |
// Die immediately, no exit hook, no abort hook, no cleanup. |
|
55238
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1072 |
// Dump a core file, if possible, for debugging. |
10565 | 1073 |
void os::die() { |
55238
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1074 |
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) { |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1075 |
// For TimeoutInErrorHandlingTest.java, we just kill the VM |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1076 |
// and don't take the time to generate a core file. |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1077 |
os::signal_raise(SIGKILL); |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1078 |
} else { |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1079 |
// _exit() on BsdThreads only kills current thread |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1080 |
::abort(); |
3bd979f09721
8224793: os::die() does not honor CreateCoredumpOnCrash option
dcubed
parents:
55154
diff
changeset
|
1081 |
} |
10565 | 1082 |
} |
1083 |
||
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1084 |
// Information of current thread in variety of formats |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1085 |
pid_t os::Bsd::gettid() { |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1086 |
int retval = -1; |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1087 |
|
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1088 |
#ifdef __APPLE__ //XNU kernel |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1089 |
// despite the fact mach port is actually not a thread id use it |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1090 |
// instead of syscall(SYS_thread_selfid) as it certainly fits to u4 |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1091 |
retval = ::pthread_mach_thread_np(::pthread_self()); |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1092 |
guarantee(retval != 0, "just checking"); |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1093 |
return retval; |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1094 |
|
30252
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1095 |
#else |
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1096 |
#ifdef __FreeBSD__ |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1097 |
retval = syscall(SYS_thr_self); |
30252
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1098 |
#else |
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1099 |
#ifdef __OpenBSD__ |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1100 |
retval = syscall(SYS_getthrid); |
30252
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1101 |
#else |
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1102 |
#ifdef __NetBSD__ |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1103 |
retval = (pid_t) syscall(SYS__lwp_self); |
30252
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1104 |
#endif |
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1105 |
#endif |
b9faf31ff015
8077674: BSD build failures due to undefined macros
dholmes
parents:
30240
diff
changeset
|
1106 |
#endif |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1107 |
#endif |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1108 |
|
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1109 |
if (retval == -1) { |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1110 |
return getpid(); |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1111 |
} |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1112 |
} |
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1113 |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1114 |
intx os::current_thread_id() { |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1115 |
#ifdef __APPLE__ |
19531 | 1116 |
return (intx)::pthread_mach_thread_np(::pthread_self()); |
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1117 |
#else |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1118 |
return (intx)::pthread_self(); |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1119 |
#endif |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
1120 |
} |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
20373
diff
changeset
|
1121 |
|
10565 | 1122 |
int os::current_process_id() { |
58280
ef8c8cf9256a
8231171: remove remaining sun.java.launcher.pid references
mbaesken
parents:
58083
diff
changeset
|
1123 |
return (int)(getpid()); |
10565 | 1124 |
} |
1125 |
||
1126 |
// DLL functions |
|
1127 |
||
1128 |
const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; } |
|
1129 |
||
1130 |
// This must be hard coded because it's the system's temporary |
|
1131 |
// directory not the java application's temp directory, ala java.io.tmpdir. |
|
10739 | 1132 |
#ifdef __APPLE__ |
1133 |
// macosx has a secure per-user temporary directory |
|
1134 |
char temp_path_storage[PATH_MAX]; |
|
1135 |
const char* os::get_temp_directory() { |
|
1136 |
static char *temp_path = NULL; |
|
1137 |
if (temp_path == NULL) { |
|
1138 |
int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX); |
|
1139 |
if (pathSize == 0 || pathSize > PATH_MAX) { |
|
1140 |
strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage)); |
|
1141 |
} |
|
1142 |
temp_path = temp_path_storage; |
|
1143 |
} |
|
1144 |
return temp_path; |
|
1145 |
} |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1146 |
#else // __APPLE__ |
10565 | 1147 |
const char* os::get_temp_directory() { return "/tmp"; } |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1148 |
#endif // __APPLE__ |
10565 | 1149 |
|
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
1150 |
// check if addr is inside libjvm.so |
10565 | 1151 |
bool os::address_is_in_vm(address addr) { |
1152 |
static address libjvm_base_addr; |
|
1153 |
Dl_info dlinfo; |
|
1154 |
||
1155 |
if (libjvm_base_addr == NULL) { |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1156 |
if (dladdr(CAST_FROM_FN_PTR(void *, os::address_is_in_vm), &dlinfo) != 0) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1157 |
libjvm_base_addr = (address)dlinfo.dli_fbase; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1158 |
} |
10565 | 1159 |
assert(libjvm_base_addr !=NULL, "Cannot obtain base address for libjvm"); |
1160 |
} |
|
1161 |
||
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1162 |
if (dladdr((void *)addr, &dlinfo) != 0) { |
10565 | 1163 |
if (libjvm_base_addr == (address)dlinfo.dli_fbase) return true; |
1164 |
} |
|
1165 |
||
1166 |
return false; |
|
1167 |
} |
|
1168 |
||
13340 | 1169 |
|
1170 |
#define MACH_MAXSYMLEN 256 |
|
1171 |
||
10565 | 1172 |
bool os::dll_address_to_function_name(address addr, char *buf, |
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1173 |
int buflen, int *offset, |
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1174 |
bool demangle) { |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1175 |
// buf is not optional, but offset is optional |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1176 |
assert(buf != NULL, "sanity check"); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1177 |
|
10565 | 1178 |
Dl_info dlinfo; |
13340 | 1179 |
char localbuf[MACH_MAXSYMLEN]; |
1180 |
||
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1181 |
if (dladdr((void*)addr, &dlinfo) != 0) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1182 |
// see if we have a matching symbol |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1183 |
if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) { |
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1184 |
if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) { |
10565 | 1185 |
jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); |
1186 |
} |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1187 |
if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1188 |
return true; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1189 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1190 |
// no matching symbol so try for just file info |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1191 |
if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1192 |
if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), |
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1193 |
buf, buflen, offset, dlinfo.dli_fname, demangle)) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1194 |
return true; |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1195 |
} |
10565 | 1196 |
} |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1197 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1198 |
// Handle non-dynamic manually: |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1199 |
if (dlinfo.dli_fbase != NULL && |
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1200 |
Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset, |
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1201 |
dlinfo.dli_fbase)) { |
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
31026
diff
changeset
|
1202 |
if (!(demangle && Decoder::demangle(localbuf, buf, buflen))) { |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1203 |
jio_snprintf(buf, buflen, "%s", localbuf); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1204 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1205 |
return true; |
10565 | 1206 |
} |
1207 |
} |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1208 |
buf[0] = '\0'; |
10565 | 1209 |
if (offset != NULL) *offset = -1; |
1210 |
return false; |
|
1211 |
} |
|
1212 |
||
1213 |
// ported from solaris version |
|
1214 |
bool os::dll_address_to_library_name(address addr, char* buf, |
|
1215 |
int buflen, int* offset) { |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1216 |
// buf is not optional, but offset is optional |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1217 |
assert(buf != NULL, "sanity check"); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1218 |
|
10565 | 1219 |
Dl_info dlinfo; |
1220 |
||
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1221 |
if (dladdr((void*)addr, &dlinfo) != 0) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1222 |
if (dlinfo.dli_fname != NULL) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1223 |
jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1224 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1225 |
if (dlinfo.dli_fbase != NULL && offset != NULL) { |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1226 |
*offset = addr - (address)dlinfo.dli_fbase; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1227 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1228 |
return true; |
10565 | 1229 |
} |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1230 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1231 |
buf[0] = '\0'; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1232 |
if (offset) *offset = -1; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1233 |
return false; |
10565 | 1234 |
} |
14286 | 1235 |
|
1236 |
// Loads .dll/.so and |
|
1237 |
// in case of error it checks if .dll/.so was built for the |
|
1238 |
// same architecture as Hotspot is running on |
|
10565 | 1239 |
|
1240 |
#ifdef __APPLE__ |
|
1241 |
void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { |
|
33583
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1242 |
#ifdef STATIC_BUILD |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1243 |
return os::get_default_process_handle(); |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1244 |
#else |
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1245 |
log_info(os)("attempting shared library load of %s", filename); |
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1246 |
|
10565 | 1247 |
void * result= ::dlopen(filename, RTLD_LAZY); |
1248 |
if (result != NULL) { |
|
55291 | 1249 |
Events::log(NULL, "Loaded shared library %s", filename); |
10565 | 1250 |
// Successful loading |
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1251 |
log_info(os)("shared library load of %s was successful", filename); |
10565 | 1252 |
return result; |
1253 |
} |
|
1254 |
||
55291 | 1255 |
const char* error_report = ::dlerror(); |
1256 |
if (error_report == NULL) { |
|
1257 |
error_report = "dlerror returned no error description"; |
|
1258 |
} |
|
1259 |
if (ebuf != NULL && ebuflen > 0) { |
|
1260 |
// Read system error message into ebuf |
|
1261 |
::strncpy(ebuf, error_report, ebuflen-1); |
|
1262 |
ebuf[ebuflen-1]='\0'; |
|
1263 |
} |
|
1264 |
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report); |
|
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1265 |
log_info(os)("shared library load of %s failed, %s", filename, error_report); |
10565 | 1266 |
|
1267 |
return NULL; |
|
33583
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1268 |
#endif // STATIC_BUILD |
10565 | 1269 |
} |
1270 |
#else |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1271 |
void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { |
33583
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1272 |
#ifdef STATIC_BUILD |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1273 |
return os::get_default_process_handle(); |
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1274 |
#else |
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1275 |
log_info(os)("attempting shared library load of %s", filename); |
10565 | 1276 |
void * result= ::dlopen(filename, RTLD_LAZY); |
1277 |
if (result != NULL) { |
|
55291 | 1278 |
Events::log(NULL, "Loaded shared library %s", filename); |
10565 | 1279 |
// Successful loading |
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1280 |
log_info(os)("shared library load of %s was successful", filename); |
10565 | 1281 |
return result; |
1282 |
} |
|
1283 |
||
1284 |
Elf32_Ehdr elf_head; |
|
1285 |
||
55291 | 1286 |
const char* const error_report = ::dlerror(); |
1287 |
if (error_report == NULL) { |
|
1288 |
error_report = "dlerror returned no error description"; |
|
1289 |
} |
|
1290 |
if (ebuf != NULL && ebuflen > 0) { |
|
1291 |
// Read system error message into ebuf |
|
1292 |
::strncpy(ebuf, error_report, ebuflen-1); |
|
1293 |
ebuf[ebuflen-1]='\0'; |
|
1294 |
} |
|
1295 |
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report); |
|
57651
ddae2da329ed
8228902: add os::dll_load to the unified logging os category
mbaesken
parents:
57599
diff
changeset
|
1296 |
log_info(os)("shared library load of %s failed, %s", filename, error_report); |
55291 | 1297 |
|
10565 | 1298 |
int diag_msg_max_length=ebuflen-strlen(ebuf); |
1299 |
char* diag_msg_buf=ebuf+strlen(ebuf); |
|
1300 |
||
1301 |
if (diag_msg_max_length==0) { |
|
1302 |
// No more space in ebuf for additional diagnostics message |
|
1303 |
return NULL; |
|
1304 |
} |
|
1305 |
||
1306 |
||
1307 |
int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK); |
|
1308 |
||
1309 |
if (file_descriptor < 0) { |
|
1310 |
// Can't open library, report dlerror() message |
|
1311 |
return NULL; |
|
1312 |
} |
|
1313 |
||
1314 |
bool failed_to_read_elf_head= |
|
1315 |
(sizeof(elf_head)!= |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1316 |
(::read(file_descriptor, &elf_head,sizeof(elf_head)))); |
10565 | 1317 |
|
1318 |
::close(file_descriptor); |
|
1319 |
if (failed_to_read_elf_head) { |
|
1320 |
// file i/o error - report dlerror() msg |
|
1321 |
return NULL; |
|
1322 |
} |
|
1323 |
||
1324 |
typedef struct { |
|
1325 |
Elf32_Half code; // Actual value as defined in elf.h |
|
1326 |
Elf32_Half compat_class; // Compatibility of archs at VM's sense |
|
1327 |
char elf_class; // 32 or 64 bit |
|
1328 |
char endianess; // MSB or LSB |
|
1329 |
char* name; // String representation |
|
1330 |
} arch_t; |
|
1331 |
||
1332 |
#ifndef EM_486 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1333 |
#define EM_486 6 /* Intel 80486 */ |
10565 | 1334 |
#endif |
1335 |
||
1336 |
#ifndef EM_MIPS_RS3_LE |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1337 |
#define EM_MIPS_RS3_LE 10 /* MIPS */ |
10565 | 1338 |
#endif |
1339 |
||
1340 |
#ifndef EM_PPC64 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1341 |
#define EM_PPC64 21 /* PowerPC64 */ |
10565 | 1342 |
#endif |
1343 |
||
1344 |
#ifndef EM_S390 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1345 |
#define EM_S390 22 /* IBM System/390 */ |
10565 | 1346 |
#endif |
1347 |
||
1348 |
#ifndef EM_IA_64 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1349 |
#define EM_IA_64 50 /* HP/Intel IA-64 */ |
10565 | 1350 |
#endif |
1351 |
||
1352 |
#ifndef EM_X86_64 |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1353 |
#define EM_X86_64 62 /* AMD x86-64 */ |
10565 | 1354 |
#endif |
1355 |
||
1356 |
static const arch_t arch_array[]={ |
|
1357 |
{EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"}, |
|
1358 |
{EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"}, |
|
1359 |
{EM_IA_64, EM_IA_64, ELFCLASS64, ELFDATA2LSB, (char*)"IA 64"}, |
|
1360 |
{EM_X86_64, EM_X86_64, ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"}, |
|
1361 |
{EM_SPARC, EM_SPARC, ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"}, |
|
1362 |
{EM_SPARC32PLUS, EM_SPARC, ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"}, |
|
1363 |
{EM_SPARCV9, EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"}, |
|
1364 |
{EM_PPC, EM_PPC, ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"}, |
|
1365 |
{EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"}, |
|
1366 |
{EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"}, |
|
1367 |
{EM_S390, EM_S390, ELFCLASSNONE, ELFDATA2MSB, (char*)"IBM System/390"}, |
|
1368 |
{EM_ALPHA, EM_ALPHA, ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"}, |
|
1369 |
{EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"}, |
|
1370 |
{EM_MIPS, EM_MIPS, ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"}, |
|
1371 |
{EM_PARISC, EM_PARISC, ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"}, |
|
1372 |
{EM_68K, EM_68K, ELFCLASS32, ELFDATA2MSB, (char*)"M68k"} |
|
1373 |
}; |
|
1374 |
||
1375 |
#if (defined IA32) |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1376 |
static Elf32_Half running_arch_code=EM_386; |
10565 | 1377 |
#elif (defined AMD64) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1378 |
static Elf32_Half running_arch_code=EM_X86_64; |
10565 | 1379 |
#elif (defined IA64) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1380 |
static Elf32_Half running_arch_code=EM_IA_64; |
10565 | 1381 |
#elif (defined __sparc) && (defined _LP64) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1382 |
static Elf32_Half running_arch_code=EM_SPARCV9; |
10565 | 1383 |
#elif (defined __sparc) && (!defined _LP64) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1384 |
static Elf32_Half running_arch_code=EM_SPARC; |
10565 | 1385 |
#elif (defined __powerpc64__) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1386 |
static Elf32_Half running_arch_code=EM_PPC64; |
10565 | 1387 |
#elif (defined __powerpc__) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1388 |
static Elf32_Half running_arch_code=EM_PPC; |
10565 | 1389 |
#elif (defined ARM) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1390 |
static Elf32_Half running_arch_code=EM_ARM; |
10565 | 1391 |
#elif (defined S390) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1392 |
static Elf32_Half running_arch_code=EM_S390; |
10565 | 1393 |
#elif (defined ALPHA) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1394 |
static Elf32_Half running_arch_code=EM_ALPHA; |
10565 | 1395 |
#elif (defined MIPSEL) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1396 |
static Elf32_Half running_arch_code=EM_MIPS_RS3_LE; |
10565 | 1397 |
#elif (defined PARISC) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1398 |
static Elf32_Half running_arch_code=EM_PARISC; |
10565 | 1399 |
#elif (defined MIPS) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1400 |
static Elf32_Half running_arch_code=EM_MIPS; |
10565 | 1401 |
#elif (defined M68K) |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1402 |
static Elf32_Half running_arch_code=EM_68K; |
10565 | 1403 |
#else |
1404 |
#error Method os::dll_load requires that one of following is defined:\ |
|
1405 |
IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K |
|
1406 |
#endif |
|
1407 |
||
1408 |
// Identify compatability class for VM's architecture and library's architecture |
|
1409 |
// Obtain string descriptions for architectures |
|
1410 |
||
1411 |
arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL}; |
|
1412 |
int running_arch_index=-1; |
|
1413 |
||
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
1414 |
for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) { |
10565 | 1415 |
if (running_arch_code == arch_array[i].code) { |
1416 |
running_arch_index = i; |
|
1417 |
} |
|
1418 |
if (lib_arch.code == arch_array[i].code) { |
|
1419 |
lib_arch.compat_class = arch_array[i].compat_class; |
|
1420 |
lib_arch.name = arch_array[i].name; |
|
1421 |
} |
|
1422 |
} |
|
1423 |
||
1424 |
assert(running_arch_index != -1, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1425 |
"Didn't find running architecture code (running_arch_code) in arch_array"); |
10565 | 1426 |
if (running_arch_index == -1) { |
1427 |
// Even though running architecture detection failed |
|
1428 |
// we may still continue with reporting dlerror() message |
|
1429 |
return NULL; |
|
1430 |
} |
|
1431 |
||
1432 |
if (lib_arch.endianess != arch_array[running_arch_index].endianess) { |
|
1433 |
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: endianness mismatch)"); |
|
1434 |
return NULL; |
|
1435 |
} |
|
1436 |
||
1437 |
#ifndef S390 |
|
1438 |
if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) { |
|
1439 |
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)"); |
|
1440 |
return NULL; |
|
1441 |
} |
|
1442 |
#endif // !S390 |
|
1443 |
||
1444 |
if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) { |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
1445 |
if (lib_arch.name!=NULL) { |
10565 | 1446 |
::snprintf(diag_msg_buf, diag_msg_max_length-1, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1447 |
" (Possible cause: can't load %s-bit .so on a %s-bit platform)", |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1448 |
lib_arch.name, arch_array[running_arch_index].name); |
10565 | 1449 |
} else { |
1450 |
::snprintf(diag_msg_buf, diag_msg_max_length-1, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1451 |
" (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)", |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1452 |
lib_arch.code, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1453 |
arch_array[running_arch_index].name); |
10565 | 1454 |
} |
1455 |
} |
|
1456 |
||
1457 |
return NULL; |
|
33583
af842015bfaa
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32080
diff
changeset
|
1458 |
#endif // STATIC_BUILD |
10565 | 1459 |
} |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1460 |
#endif // !__APPLE__ |
10565 | 1461 |
|
22528
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1462 |
void* os::get_default_process_handle() { |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1463 |
#ifdef __APPLE__ |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1464 |
// MacOS X needs to use RTLD_FIRST instead of RTLD_LAZY |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1465 |
// to avoid finding unexpected symbols on second (or later) |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1466 |
// loads of a library. |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1467 |
return (void*)::dlopen(NULL, RTLD_FIRST); |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1468 |
#else |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1469 |
return (void*)::dlopen(NULL, RTLD_LAZY); |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1470 |
#endif |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1471 |
} |
bd3821442010
8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked.
sla
parents:
21213
diff
changeset
|
1472 |
|
10565 | 1473 |
// XXX: Do we need a lock around this as per Linux? |
1474 |
void* os::dll_lookup(void* handle, const char* name) { |
|
1475 |
return dlsym(handle, name); |
|
1476 |
} |
|
1477 |
||
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1478 |
int _print_dll_info_cb(const char * name, address base_address, address top_address, void * param) { |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1479 |
outputStream * out = (outputStream *) param; |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
1480 |
out->print_cr(INTPTR_FORMAT " \t%s", (intptr_t)base_address, name); |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1481 |
return 0; |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1482 |
} |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1483 |
|
10565 | 1484 |
void os::print_dll_info(outputStream *st) { |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1485 |
st->print_cr("Dynamic libraries:"); |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1486 |
if (get_loaded_modules_info(_print_dll_info_cb, (void *)st)) { |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1487 |
st->print_cr("Error: Cannot print dynamic libraries."); |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1488 |
} |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1489 |
} |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1490 |
|
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1491 |
int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { |
10565 | 1492 |
#ifdef RTLD_DI_LINKMAP |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1493 |
Dl_info dli; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1494 |
void *handle; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1495 |
Link_map *map; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1496 |
Link_map *p; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1497 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1498 |
if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1499 |
dli.dli_fname == NULL) { |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1500 |
return 1; |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1501 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1502 |
handle = dlopen(dli.dli_fname, RTLD_LAZY); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1503 |
if (handle == NULL) { |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1504 |
return 1; |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1505 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1506 |
dlinfo(handle, RTLD_DI_LINKMAP, &map); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1507 |
if (map == NULL) { |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1508 |
dlclose(handle); |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1509 |
return 1; |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1510 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1511 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1512 |
while (map->l_prev != NULL) |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1513 |
map = map->l_prev; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1514 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1515 |
while (map != NULL) { |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1516 |
// Value for top_address is returned as 0 since we don't have any information about module size |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1517 |
if (callback(map->l_name, (address)map->l_addr, (address)0, param)) { |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1518 |
dlclose(handle); |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1519 |
return 1; |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1520 |
} |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1521 |
map = map->l_next; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1522 |
} |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1523 |
|
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1524 |
dlclose(handle); |
10565 | 1525 |
#elif defined(__APPLE__) |
26409
9f717958a2bb
8055755: Information about loaded dynamic libraries is wrong on MacOSX
sla
parents:
25946
diff
changeset
|
1526 |
for (uint32_t i = 1; i < _dyld_image_count(); i++) { |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1527 |
// Value for top_address is returned as 0 since we don't have any information about module size |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1528 |
if (callback(_dyld_get_image_name(i), (address)_dyld_get_image_header(i), (address)0, param)) { |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1529 |
return 1; |
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1530 |
} |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1531 |
} |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1532 |
return 0; |
10565 | 1533 |
#else |
26557
e399effe36f9
8056242: Add function to return structured information about loaded libraries.
sla
parents:
26409
diff
changeset
|
1534 |
return 1; |
10565 | 1535 |
#endif |
1536 |
} |
|
1537 |
||
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1538 |
void os::get_summary_os_info(char* buf, size_t buflen) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1539 |
// These buffers are small because we want this to be brief |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1540 |
// and not use a lot of stack while generating the hs_err file. |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1541 |
char os[100]; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1542 |
size_t size = sizeof(os); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1543 |
int mib_kern[] = { CTL_KERN, KERN_OSTYPE }; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1544 |
if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1545 |
#ifdef __APPLE__ |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1546 |
strncpy(os, "Darwin", sizeof(os)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1547 |
#elif __OpenBSD__ |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1548 |
strncpy(os, "OpenBSD", sizeof(os)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1549 |
#else |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1550 |
strncpy(os, "BSD", sizeof(os)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1551 |
#endif |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1552 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1553 |
|
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1554 |
char release[100]; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1555 |
size = sizeof(release); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1556 |
int mib_release[] = { CTL_KERN, KERN_OSRELEASE }; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1557 |
if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1558 |
// if error, leave blank |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1559 |
strncpy(release, "", sizeof(release)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1560 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1561 |
snprintf(buf, buflen, "%s %s", os, release); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1562 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1563 |
|
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1564 |
void os::print_os_info_brief(outputStream* st) { |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1565 |
os::Posix::print_uname_info(st); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1566 |
} |
10565 | 1567 |
|
1568 |
void os::print_os_info(outputStream* st) { |
|
1569 |
st->print("OS:"); |
|
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1570 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1571 |
os::Posix::print_uname_info(st); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1572 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1573 |
os::Posix::print_rlimit_info(st); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1574 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
12101
diff
changeset
|
1575 |
os::Posix::print_load_average(st); |
10565 | 1576 |
} |
1577 |
||
31356
55ee785c49c5
8085865: hs_err improvement: Printing /proc/cpuinfo makes too long hs_err files
coleenp
parents:
31026
diff
changeset
|
1578 |
void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { |
10565 | 1579 |
// Nothing to do for now. |
1580 |
} |
|
1581 |
||
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1582 |
void os::get_summary_cpu_info(char* buf, size_t buflen) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1583 |
unsigned int mhz; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1584 |
size_t size = sizeof(mhz); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1585 |
int mib[] = { CTL_HW, HW_CPU_FREQ }; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1586 |
if (sysctl(mib, 2, &mhz, &size, NULL, 0) < 0) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1587 |
mhz = 1; // looks like an error but can be divided by |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1588 |
} else { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1589 |
mhz /= 1000000; // reported in millions |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1590 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1591 |
|
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1592 |
char model[100]; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1593 |
size = sizeof(model); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1594 |
int mib_model[] = { CTL_HW, HW_MODEL }; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1595 |
if (sysctl(mib_model, 2, model, &size, NULL, 0) < 0) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1596 |
strncpy(model, cpu_arch, sizeof(model)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1597 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1598 |
|
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1599 |
char machine[100]; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1600 |
size = sizeof(machine); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1601 |
int mib_machine[] = { CTL_HW, HW_MACHINE }; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1602 |
if (sysctl(mib_machine, 2, machine, &size, NULL, 0) < 0) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1603 |
strncpy(machine, "", sizeof(machine)); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1604 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1605 |
|
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1606 |
snprintf(buf, buflen, "%s %s %d MHz", model, machine, mhz); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1607 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
1608 |
|
10565 | 1609 |
void os::print_memory_info(outputStream* st) { |
54420
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1610 |
xsw_usage swap_usage; |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1611 |
size_t size = sizeof(swap_usage); |
10565 | 1612 |
|
1613 |
st->print("Memory:"); |
|
1614 |
st->print(" %dk page", os::vm_page_size()>>10); |
|
1615 |
||
1616 |
st->print(", physical " UINT64_FORMAT "k", |
|
1617 |
os::physical_memory() >> 10); |
|
1618 |
st->print("(" UINT64_FORMAT "k free)", |
|
1619 |
os::available_memory() >> 10); |
|
54420
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1620 |
|
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1621 |
if((sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) || (errno == ENOMEM)) { |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1622 |
if (size >= offset_of(xsw_usage, xsu_used)) { |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1623 |
st->print(", swap " UINT64_FORMAT "k", |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1624 |
((julong) swap_usage.xsu_total) >> 10); |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1625 |
st->print("(" UINT64_FORMAT "k free)", |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1626 |
((julong) swap_usage.xsu_avail) >> 10); |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1627 |
} |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1628 |
} |
724b9e361cb6
8221325: Add information about swap space to print_memory_info() on MacOS
rschmelter
parents:
54280
diff
changeset
|
1629 |
|
10565 | 1630 |
st->cr(); |
1631 |
} |
|
1632 |
||
1633 |
static void print_signal_handler(outputStream* st, int sig, |
|
1634 |
char* buf, size_t buflen); |
|
1635 |
||
1636 |
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) { |
|
1637 |
st->print_cr("Signal Handlers:"); |
|
1638 |
print_signal_handler(st, SIGSEGV, buf, buflen); |
|
1639 |
print_signal_handler(st, SIGBUS , buf, buflen); |
|
1640 |
print_signal_handler(st, SIGFPE , buf, buflen); |
|
1641 |
print_signal_handler(st, SIGPIPE, buf, buflen); |
|
1642 |
print_signal_handler(st, SIGXFSZ, buf, buflen); |
|
1643 |
print_signal_handler(st, SIGILL , buf, buflen); |
|
1644 |
print_signal_handler(st, SR_signum, buf, buflen); |
|
1645 |
print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen); |
|
1646 |
print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen); |
|
1647 |
print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen); |
|
1648 |
print_signal_handler(st, BREAK_SIGNAL, buf, buflen); |
|
1649 |
} |
|
1650 |
||
1651 |
static char saved_jvm_path[MAXPATHLEN] = {0}; |
|
1652 |
||
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
1653 |
// Find the full path to the current module, libjvm |
10565 | 1654 |
void os::jvm_path(char *buf, jint buflen) { |
1655 |
// Error checking. |
|
1656 |
if (buflen < MAXPATHLEN) { |
|
1657 |
assert(false, "must use a large-enough buffer"); |
|
1658 |
buf[0] = '\0'; |
|
1659 |
return; |
|
1660 |
} |
|
1661 |
// Lazy resolve the path to current module. |
|
1662 |
if (saved_jvm_path[0] != 0) { |
|
1663 |
strcpy(buf, saved_jvm_path); |
|
1664 |
return; |
|
1665 |
} |
|
1666 |
||
1667 |
char dli_fname[MAXPATHLEN]; |
|
1668 |
bool ret = dll_address_to_library_name( |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1669 |
CAST_FROM_FN_PTR(address, os::jvm_path), |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1670 |
dli_fname, sizeof(dli_fname), NULL); |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1671 |
assert(ret, "cannot locate libjvm"); |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1672 |
char *rp = NULL; |
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1673 |
if (ret && dli_fname[0] != '\0') { |
46331 | 1674 |
rp = os::Posix::realpath(dli_fname, buf, buflen); |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
1675 |
} |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1676 |
if (rp == NULL) { |
10565 | 1677 |
return; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1678 |
} |
10565 | 1679 |
|
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1680 |
if (Arguments::sun_java_launcher_is_altjvm()) { |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1681 |
// Support for the java launcher's '-XXaltjvm=<path>' option. Typical |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1682 |
// value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so" |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1683 |
// or "<JAVA_HOME>/jre/lib/<vmtype>/libjvm.dylib". If "/jre/lib/" |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1684 |
// appears at the right place in the string, then assume we are |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1685 |
// installed in a JDK and we're done. Otherwise, check for a |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1686 |
// JAVA_HOME environment variable and construct a path to the JVM |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22533
diff
changeset
|
1687 |
// being overridden. |
11593 | 1688 |
|
10565 | 1689 |
const char *p = buf + strlen(buf) - 1; |
1690 |
for (int count = 0; p > buf && count < 5; ++count) { |
|
1691 |
for (--p; p > buf && *p != '/'; --p) |
|
1692 |
/* empty */ ; |
|
1693 |
} |
|
1694 |
||
1695 |
if (strncmp(p, "/jre/lib/", 9) != 0) { |
|
1696 |
// Look for JAVA_HOME in the environment. |
|
1697 |
char* java_home_var = ::getenv("JAVA_HOME"); |
|
1698 |
if (java_home_var != NULL && java_home_var[0] != 0) { |
|
1699 |
char* jrelib_p; |
|
1700 |
int len; |
|
1701 |
||
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
1702 |
// Check the current module name "libjvm" |
10565 | 1703 |
p = strrchr(buf, '/'); |
1704 |
assert(strstr(p, "/libjvm") == p, "invalid library name"); |
|
1705 |
||
46331 | 1706 |
rp = os::Posix::realpath(java_home_var, buf, buflen); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1707 |
if (rp == NULL) { |
10565 | 1708 |
return; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1709 |
} |
10565 | 1710 |
|
1711 |
// determine if this is a legacy image or modules image |
|
1712 |
// modules image doesn't have "jre" subdirectory |
|
1713 |
len = strlen(buf); |
|
25503 | 1714 |
assert(len < buflen, "Ran out of buffer space"); |
10565 | 1715 |
jrelib_p = buf + len; |
11593 | 1716 |
|
1717 |
// Add the appropriate library subdir |
|
1718 |
snprintf(jrelib_p, buflen-len, "/jre/lib"); |
|
10565 | 1719 |
if (0 != access(buf, F_OK)) { |
11593 | 1720 |
snprintf(jrelib_p, buflen-len, "/lib"); |
10565 | 1721 |
} |
1722 |
||
11593 | 1723 |
// Add the appropriate client or server subdir |
1724 |
len = strlen(buf); |
|
1725 |
jrelib_p = buf + len; |
|
1726 |
snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT); |
|
1727 |
if (0 != access(buf, F_OK)) { |
|
22784
f264891fc7a8
8030350: Enable additional compiler warnings for GCC
mduigou
parents:
22734
diff
changeset
|
1728 |
snprintf(jrelib_p, buflen-len, "%s", ""); |
11593 | 1729 |
} |
1730 |
||
1731 |
// If the path exists within JAVA_HOME, add the JVM library name |
|
1732 |
// to complete the path to JVM being overridden. Otherwise fallback |
|
1733 |
// to the path to the current library. |
|
10565 | 1734 |
if (0 == access(buf, F_OK)) { |
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
1735 |
// Use current module name "libjvm" |
10565 | 1736 |
len = strlen(buf); |
15096
3db45569f8c0
8005044: remove crufty '_g' support from HS runtime code
dcubed
parents:
14633
diff
changeset
|
1737 |
snprintf(buf + len, buflen-len, "/libjvm%s", JNI_LIB_SUFFIX); |
10565 | 1738 |
} else { |
11593 | 1739 |
// Fall back to path of current library |
46331 | 1740 |
rp = os::Posix::realpath(dli_fname, buf, buflen); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1741 |
if (rp == NULL) { |
10565 | 1742 |
return; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1743 |
} |
10565 | 1744 |
} |
1745 |
} |
|
1746 |
} |
|
1747 |
} |
|
1748 |
||
25503 | 1749 |
strncpy(saved_jvm_path, buf, MAXPATHLEN); |
27471 | 1750 |
saved_jvm_path[MAXPATHLEN - 1] = '\0'; |
10565 | 1751 |
} |
1752 |
||
1753 |
void os::print_jni_name_prefix_on(outputStream* st, int args_size) { |
|
1754 |
// no prefix required, not even "_" |
|
1755 |
} |
|
1756 |
||
1757 |
void os::print_jni_name_suffix_on(outputStream* st, int args_size) { |
|
1758 |
// no suffix required |
|
1759 |
} |
|
1760 |
||
1761 |
//////////////////////////////////////////////////////////////////////////////// |
|
1762 |
// sun.misc.Signal support |
|
1763 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1764 |
static void UserHandler(int sig, void *siginfo, void *context) { |
10565 | 1765 |
// Ctrl-C is pressed during error reporting, likely because the error |
1766 |
// handler fails to abort. Let VM die immediately. |
|
46589 | 1767 |
if (sig == SIGINT && VMError::is_error_reported()) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1768 |
os::die(); |
10565 | 1769 |
} |
1770 |
||
1771 |
os::signal_notify(sig); |
|
1772 |
} |
|
1773 |
||
1774 |
void* os::user_handler() { |
|
1775 |
return CAST_FROM_FN_PTR(void*, UserHandler); |
|
1776 |
} |
|
1777 |
||
1778 |
extern "C" { |
|
1779 |
typedef void (*sa_handler_t)(int); |
|
1780 |
typedef void (*sa_sigaction_t)(int, siginfo_t *, void *); |
|
1781 |
} |
|
1782 |
||
1783 |
void* os::signal(int signal_number, void* handler) { |
|
1784 |
struct sigaction sigAct, oldSigAct; |
|
1785 |
||
1786 |
sigfillset(&(sigAct.sa_mask)); |
|
1787 |
sigAct.sa_flags = SA_RESTART|SA_SIGINFO; |
|
1788 |
sigAct.sa_handler = CAST_TO_FN_PTR(sa_handler_t, handler); |
|
1789 |
||
1790 |
if (sigaction(signal_number, &sigAct, &oldSigAct)) { |
|
1791 |
// -1 means registration failed |
|
1792 |
return (void *)-1; |
|
1793 |
} |
|
1794 |
||
1795 |
return CAST_FROM_FN_PTR(void*, oldSigAct.sa_handler); |
|
1796 |
} |
|
1797 |
||
1798 |
void os::signal_raise(int signal_number) { |
|
1799 |
::raise(signal_number); |
|
1800 |
} |
|
1801 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1802 |
// The following code is moved from os.cpp for making this |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
1803 |
// code platform specific, which it is by its very nature. |
10565 | 1804 |
|
1805 |
// Will be modified when max signal is changed to be dynamic |
|
1806 |
int os::sigexitnum_pd() { |
|
1807 |
return NSIG; |
|
1808 |
} |
|
1809 |
||
1810 |
// a counter for each possible signal value |
|
1811 |
static volatile jint pending_signals[NSIG+1] = { 0 }; |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1812 |
static Semaphore* sig_sem = NULL; |
18025 | 1813 |
|
50184
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
1814 |
static void jdk_misc_signal_init() { |
10565 | 1815 |
// Initialize signal structures |
1816 |
::memset((void*)pending_signals, 0, sizeof(pending_signals)); |
|
1817 |
||
1818 |
// Initialize signal semaphore |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1819 |
sig_sem = new Semaphore(); |
10565 | 1820 |
} |
1821 |
||
1822 |
void os::signal_notify(int sig) { |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1823 |
if (sig_sem != NULL) { |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1824 |
Atomic::inc(&pending_signals[sig]); |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1825 |
sig_sem->signal(); |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1826 |
} else { |
50184
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
1827 |
// Signal thread is not created with ReduceSignalUsage and jdk_misc_signal_init |
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1828 |
// initialization isn't called. |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1829 |
assert(ReduceSignalUsage, "signal semaphore should be created"); |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1830 |
} |
10565 | 1831 |
} |
1832 |
||
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1833 |
static int check_pending_signals() { |
10565 | 1834 |
for (;;) { |
1835 |
for (int i = 0; i < NSIG + 1; i++) { |
|
1836 |
jint n = pending_signals[i]; |
|
1837 |
if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) { |
|
1838 |
return i; |
|
1839 |
} |
|
1840 |
} |
|
1841 |
JavaThread *thread = JavaThread::current(); |
|
1842 |
ThreadBlockInVM tbivm(thread); |
|
1843 |
||
1844 |
bool threadIsSuspended; |
|
1845 |
do { |
|
1846 |
thread->set_suspend_equivalent(); |
|
1847 |
// cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1848 |
sig_sem->wait(); |
10565 | 1849 |
|
1850 |
// were we externally suspended while we were waiting? |
|
1851 |
threadIsSuspended = thread->handle_special_suspend_equivalent_condition(); |
|
1852 |
if (threadIsSuspended) { |
|
1853 |
// The semaphore has been incremented, but while we were waiting |
|
1854 |
// another thread suspended us. We don't want to continue running |
|
1855 |
// while suspended because that would surprise the thread that |
|
1856 |
// suspended us. |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1857 |
sig_sem->signal(); |
10565 | 1858 |
|
1859 |
thread->java_suspend_self(); |
|
1860 |
} |
|
1861 |
} while (threadIsSuspended); |
|
1862 |
} |
|
1863 |
} |
|
1864 |
||
1865 |
int os::signal_wait() { |
|
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
1866 |
return check_pending_signals(); |
10565 | 1867 |
} |
1868 |
||
1869 |
//////////////////////////////////////////////////////////////////////////////// |
|
1870 |
// Virtual Memory |
|
1871 |
||
1872 |
int os::vm_page_size() { |
|
1873 |
// Seems redundant as all get out |
|
1874 |
assert(os::Bsd::page_size() != -1, "must call os::init"); |
|
1875 |
return os::Bsd::page_size(); |
|
1876 |
} |
|
1877 |
||
1878 |
// Solaris allocates memory by pages. |
|
1879 |
int os::vm_allocation_granularity() { |
|
1880 |
assert(os::Bsd::page_size() != -1, "must call os::init"); |
|
1881 |
return os::Bsd::page_size(); |
|
1882 |
} |
|
1883 |
||
1884 |
// Rationale behind this function: |
|
1885 |
// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable |
|
1886 |
// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get |
|
1887 |
// samples for JITted code. Here we create private executable mapping over the code cache |
|
1888 |
// and then we can use standard (well, almost, as mapping can change) way to provide |
|
1889 |
// info for the reporting script by storing timestamp and location of symbol |
|
1890 |
void bsd_wrap_code(char* base, size_t size) { |
|
1891 |
static volatile jint cnt = 0; |
|
1892 |
||
1893 |
if (!UseOprofile) { |
|
1894 |
return; |
|
1895 |
} |
|
1896 |
||
1897 |
char buf[PATH_MAX + 1]; |
|
1898 |
int num = Atomic::add(1, &cnt); |
|
1899 |
||
1900 |
snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d", |
|
1901 |
os::get_temp_directory(), os::current_process_id(), num); |
|
1902 |
unlink(buf); |
|
1903 |
||
1904 |
int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU); |
|
1905 |
||
1906 |
if (fd != -1) { |
|
1907 |
off_t rv = ::lseek(fd, size-2, SEEK_SET); |
|
1908 |
if (rv != (off_t)-1) { |
|
1909 |
if (::write(fd, "", 1) == 1) { |
|
1910 |
mmap(base, size, |
|
1911 |
PROT_READ|PROT_WRITE|PROT_EXEC, |
|
1912 |
MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0); |
|
1913 |
} |
|
1914 |
} |
|
1915 |
::close(fd); |
|
1916 |
unlink(buf); |
|
1917 |
} |
|
1918 |
} |
|
1919 |
||
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1920 |
static void warn_fail_commit_memory(char* addr, size_t size, bool exec, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1921 |
int err) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
1922 |
warning("INFO: os::commit_memory(" INTPTR_FORMAT ", " SIZE_FORMAT |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
1923 |
", %d) failed; error='%s' (errno=%d)", (intptr_t)addr, size, exec, |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
1924 |
os::errno_name(err), err); |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1925 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1926 |
|
10565 | 1927 |
// NOTE: Bsd kernel does not really reserve the pages for us. |
1928 |
// All it does is to check if there are enough free pages |
|
1929 |
// left at the time of mmap(). This could be a potential |
|
1930 |
// problem. |
|
13195 | 1931 |
bool os::pd_commit_memory(char* addr, size_t size, bool exec) { |
10565 | 1932 |
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; |
1933 |
#ifdef __OpenBSD__ |
|
1934 |
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD |
|
55044 | 1935 |
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1936 |
if (::mprotect(addr, size, prot) == 0) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1937 |
return true; |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1938 |
} |
10565 | 1939 |
#else |
1940 |
uintptr_t res = (uintptr_t) ::mmap(addr, size, prot, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1941 |
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0); |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1942 |
if (res != (uintptr_t) MAP_FAILED) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1943 |
return true; |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1944 |
} |
10565 | 1945 |
#endif |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1946 |
|
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1947 |
// Warn about any commit errors we see in non-product builds just |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1948 |
// in case mmap() doesn't work as described on the man page. |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1949 |
NOT_PRODUCT(warn_fail_commit_memory(addr, size, exec, errno);) |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1950 |
|
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1951 |
return false; |
10565 | 1952 |
} |
1953 |
||
13195 | 1954 |
bool os::pd_commit_memory(char* addr, size_t size, size_t alignment_hint, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
1955 |
bool exec) { |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1956 |
// alignment_hint is ignored on this OS |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1957 |
return pd_commit_memory(addr, size, exec); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1958 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1959 |
|
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1960 |
void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1961 |
const char* mesg) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1962 |
assert(mesg != NULL, "mesg must be specified"); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1963 |
if (!pd_commit_memory(addr, size, exec)) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1964 |
// add extra info in product mode for vm_exit_out_of_memory(): |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1965 |
PRODUCT_ONLY(warn_fail_commit_memory(addr, size, exec, errno);) |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32080
diff
changeset
|
1966 |
vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "%s", mesg); |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1967 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1968 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1969 |
|
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1970 |
void os::pd_commit_memory_or_exit(char* addr, size_t size, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1971 |
size_t alignment_hint, bool exec, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1972 |
const char* mesg) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1973 |
// alignment_hint is ignored on this OS |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1974 |
pd_commit_memory_or_exit(addr, size, exec, mesg); |
10565 | 1975 |
} |
1976 |
||
13195 | 1977 |
void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { |
10565 | 1978 |
} |
1979 |
||
13195 | 1980 |
void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { |
10565 | 1981 |
::madvise(addr, bytes, MADV_DONTNEED); |
1982 |
} |
|
1983 |
||
1984 |
void os::numa_make_global(char *addr, size_t bytes) { |
|
1985 |
} |
|
1986 |
||
1987 |
void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { |
|
1988 |
} |
|
1989 |
||
1990 |
bool os::numa_topology_changed() { return false; } |
|
1991 |
||
1992 |
size_t os::numa_get_groups_num() { |
|
1993 |
return 1; |
|
1994 |
} |
|
1995 |
||
1996 |
int os::numa_get_group_id() { |
|
1997 |
return 0; |
|
1998 |
} |
|
1999 |
||
2000 |
size_t os::numa_get_leaf_groups(int *ids, size_t size) { |
|
2001 |
if (size > 0) { |
|
2002 |
ids[0] = 0; |
|
2003 |
return 1; |
|
2004 |
} |
|
2005 |
return 0; |
|
2006 |
} |
|
2007 |
||
2008 |
bool os::get_page_info(char *start, page_info* info) { |
|
2009 |
return false; |
|
2010 |
} |
|
2011 |
||
2012 |
char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { |
|
2013 |
return end; |
|
2014 |
} |
|
2015 |
||
2016 |
||
13195 | 2017 |
bool os::pd_uncommit_memory(char* addr, size_t size) { |
10565 | 2018 |
#ifdef __OpenBSD__ |
2019 |
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD |
|
55044 | 2020 |
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size)); |
10565 | 2021 |
return ::mprotect(addr, size, PROT_NONE) == 0; |
2022 |
#else |
|
2023 |
uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2024 |
MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0); |
10565 | 2025 |
return res != (uintptr_t) MAP_FAILED; |
2026 |
#endif |
|
2027 |
} |
|
2028 |
||
13195 | 2029 |
bool os::pd_create_stack_guard_pages(char* addr, size_t size) { |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
2030 |
return os::commit_memory(addr, size, !ExecMem); |
10565 | 2031 |
} |
2032 |
||
2033 |
// If this is a growable mapping, remove the guard pages entirely by |
|
2034 |
// munmap()ping them. If not, just call uncommit_memory(). |
|
2035 |
bool os::remove_stack_guard_pages(char* addr, size_t size) { |
|
2036 |
return os::uncommit_memory(addr, size); |
|
2037 |
} |
|
2038 |
||
2039 |
// If 'fixed' is true, anon_mmap() will attempt to reserve anonymous memory |
|
2040 |
// at 'requested_addr'. If there are existing memory mappings at the same |
|
2041 |
// location, however, they will be overwritten. If 'fixed' is false, |
|
2042 |
// 'requested_addr' is only treated as a hint, the return value may or |
|
2043 |
// may not start from the requested address. Unlike Bsd mmap(), this |
|
2044 |
// function returns NULL to indicate failure. |
|
2045 |
static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) { |
|
2046 |
char * addr; |
|
2047 |
int flags; |
|
2048 |
||
2049 |
flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS; |
|
2050 |
if (fixed) { |
|
2051 |
assert((uintptr_t)requested_addr % os::Bsd::page_size() == 0, "unaligned address"); |
|
2052 |
flags |= MAP_FIXED; |
|
2053 |
} |
|
2054 |
||
17083 | 2055 |
// Map reserved/uncommitted pages PROT_NONE so we fail early if we |
2056 |
// touch an uncommitted page. Otherwise, the read/write might |
|
2057 |
// succeed if we have enough swap space to back the physical page. |
|
2058 |
addr = (char*)::mmap(requested_addr, bytes, PROT_NONE, |
|
10565 | 2059 |
flags, -1, 0); |
2060 |
||
2061 |
return addr == MAP_FAILED ? NULL : addr; |
|
2062 |
} |
|
2063 |
||
2064 |
static int anon_munmap(char * addr, size_t size) { |
|
2065 |
return ::munmap(addr, size) == 0; |
|
2066 |
} |
|
2067 |
||
13195 | 2068 |
char* os::pd_reserve_memory(size_t bytes, char* requested_addr, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2069 |
size_t alignment_hint) { |
10565 | 2070 |
return anon_mmap(requested_addr, bytes, (requested_addr != NULL)); |
2071 |
} |
|
2072 |
||
13195 | 2073 |
bool os::pd_release_memory(char* addr, size_t size) { |
10565 | 2074 |
return anon_munmap(addr, size); |
2075 |
} |
|
2076 |
||
2077 |
static bool bsd_mprotect(char* addr, size_t size, int prot) { |
|
2078 |
// Bsd wants the mprotect address argument to be page aligned. |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46589
diff
changeset
|
2079 |
char* bottom = (char*)align_down((intptr_t)addr, os::Bsd::page_size()); |
10565 | 2080 |
|
2081 |
// According to SUSv3, mprotect() should only be used with mappings |
|
2082 |
// established by mmap(), and mmap() always maps whole pages. Unaligned |
|
2083 |
// 'addr' likely indicates problem in the VM (e.g. trying to change |
|
2084 |
// protection of malloc'ed or statically allocated memory). Check the |
|
2085 |
// caller if you hit this assert. |
|
2086 |
assert(addr == bottom, "sanity check"); |
|
2087 |
||
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46589
diff
changeset
|
2088 |
size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size()); |
55044 | 2089 |
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot); |
10565 | 2090 |
return ::mprotect(bottom, size, prot) == 0; |
2091 |
} |
|
2092 |
||
2093 |
// Set protections specified |
|
2094 |
bool os::protect_memory(char* addr, size_t bytes, ProtType prot, |
|
2095 |
bool is_committed) { |
|
2096 |
unsigned int p = 0; |
|
2097 |
switch (prot) { |
|
2098 |
case MEM_PROT_NONE: p = PROT_NONE; break; |
|
2099 |
case MEM_PROT_READ: p = PROT_READ; break; |
|
2100 |
case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break; |
|
2101 |
case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break; |
|
2102 |
default: |
|
2103 |
ShouldNotReachHere(); |
|
2104 |
} |
|
2105 |
// is_committed is unused. |
|
2106 |
return bsd_mprotect(addr, bytes, p); |
|
2107 |
} |
|
2108 |
||
2109 |
bool os::guard_memory(char* addr, size_t size) { |
|
2110 |
return bsd_mprotect(addr, size, PROT_NONE); |
|
2111 |
} |
|
2112 |
||
2113 |
bool os::unguard_memory(char* addr, size_t size) { |
|
2114 |
return bsd_mprotect(addr, size, PROT_READ|PROT_WRITE); |
|
2115 |
} |
|
2116 |
||
2117 |
bool os::Bsd::hugetlbfs_sanity_check(bool warn, size_t page_size) { |
|
14286 | 2118 |
return false; |
10565 | 2119 |
} |
2120 |
||
2121 |
// Large page support |
|
2122 |
||
2123 |
static size_t _large_page_size = 0; |
|
2124 |
||
2125 |
void os::large_page_init() { |
|
2126 |
} |
|
2127 |
||
2128 |
||
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
2129 |
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) { |
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2130 |
fatal("os::reserve_memory_special should not be called on BSD."); |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2131 |
return NULL; |
10565 | 2132 |
} |
2133 |
||
2134 |
bool os::release_memory_special(char* base, size_t bytes) { |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2135 |
fatal("os::release_memory_special should not be called on BSD."); |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2136 |
return false; |
10565 | 2137 |
} |
2138 |
||
2139 |
size_t os::large_page_size() { |
|
2140 |
return _large_page_size; |
|
2141 |
} |
|
2142 |
||
2143 |
bool os::can_commit_large_page_memory() { |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2144 |
// Does not matter, we do not support huge pages. |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2145 |
return false; |
10565 | 2146 |
} |
2147 |
||
2148 |
bool os::can_execute_large_page_memory() { |
|
52304
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2149 |
// Does not matter, we do not support huge pages. |
72f2fc52ef85
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
gziemski
parents:
52302
diff
changeset
|
2150 |
return false; |
10565 | 2151 |
} |
2152 |
||
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2153 |
char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr, int file_desc) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2154 |
assert(file_desc >= 0, "file_desc is not valid"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2155 |
char* result = pd_attempt_reserve_memory_at(bytes, requested_addr); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2156 |
if (result != NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2157 |
if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2158 |
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2159 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2160 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2161 |
return result; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2162 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48005
diff
changeset
|
2163 |
|
10565 | 2164 |
// Reserve memory at an arbitrary address, only if that area is |
2165 |
// available (and not reserved for something else). |
|
2166 |
||
13195 | 2167 |
char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) { |
10565 | 2168 |
// Assert only that the size is a multiple of the page size, since |
2169 |
// that's all that mmap requires, and since that's all we really know |
|
2170 |
// about at this low abstraction level. If we need higher alignment, |
|
2171 |
// we can either pass an alignment to this method or verify alignment |
|
2172 |
// in one of the methods further up the call chain. See bug 5044738. |
|
2173 |
assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block"); |
|
2174 |
||
2175 |
// Repeatedly allocate blocks until the block is allocated at the |
|
31377
229b4eb67c2b
8078513: [linux] Clean up code relevant to LinuxThreads implementation
stuefe
parents:
31357
diff
changeset
|
2176 |
// right spot. |
10565 | 2177 |
|
2178 |
// Bsd mmap allows caller to pass an address as hint; give it a try first, |
|
2179 |
// if kernel honors the hint then we can return immediately. |
|
2180 |
char * addr = anon_mmap(requested_addr, bytes, false); |
|
2181 |
if (addr == requested_addr) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2182 |
return requested_addr; |
10565 | 2183 |
} |
2184 |
||
2185 |
if (addr != NULL) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2186 |
// mmap() is successful but it fails to reserve at the requested address |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2187 |
anon_munmap(addr, bytes); |
10565 | 2188 |
} |
2189 |
||
55325
24c59b1579d7
8224871: os::attempt_reserve_memory_at() tries too hard
eosterlund
parents:
55291
diff
changeset
|
2190 |
return NULL; |
10565 | 2191 |
} |
2192 |
||
2193 |
// Sleep forever; naked call to OS-specific sleep; use with CAUTION |
|
2194 |
void os::infinite_sleep() { |
|
2195 |
while (true) { // sleep forever ... |
|
2196 |
::sleep(100); // ... 100 seconds at a time |
|
2197 |
} |
|
2198 |
} |
|
2199 |
||
2200 |
// Used to convert frequent JVM_Yield() to nops |
|
2201 |
bool os::dont_yield() { |
|
2202 |
return DontYieldALot; |
|
2203 |
} |
|
2204 |
||
25477
7dad9f95fd31
8047714: Fix for JDK-6546236 made Solaris os::yield() a no-op
fparain
parents:
25472
diff
changeset
|
2205 |
void os::naked_yield() { |
10565 | 2206 |
sched_yield(); |
2207 |
} |
|
2208 |
||
2209 |
//////////////////////////////////////////////////////////////////////////////// |
|
2210 |
// thread priority support |
|
2211 |
||
2212 |
// Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER |
|
2213 |
// only supports dynamic priority, static priority must be zero. For real-time |
|
2214 |
// applications, Bsd supports SCHED_RR which allows static priority (1-99). |
|
2215 |
// However, for large multi-threaded applications, SCHED_RR is not only slower |
|
2216 |
// than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out |
|
2217 |
// of 5 runs - Sep 2005). |
|
2218 |
// |
|
2219 |
// The following code actually changes the niceness of kernel-thread/LWP. It |
|
2220 |
// has an assumption that setpriority() only modifies one kernel-thread/LWP, |
|
2221 |
// not the entire user process, and user level threads are 1:1 mapped to kernel |
|
2222 |
// threads. It has always been the case, but could change in the future. For |
|
2223 |
// this reason, the code should not be used as default (ThreadPriorityPolicy=0). |
|
53155
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2224 |
// It is only used when ThreadPriorityPolicy=1 and may require system level permission |
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2225 |
// (e.g., root privilege or CAP_SYS_NICE capability). |
10565 | 2226 |
|
14286 | 2227 |
#if !defined(__APPLE__) |
11601
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2228 |
int os::java_to_os_priority[CriticalPriority + 1] = { |
10565 | 2229 |
19, // 0 Entry should never be used |
2230 |
||
2231 |
0, // 1 MinPriority |
|
2232 |
3, // 2 |
|
2233 |
6, // 3 |
|
2234 |
||
11601
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2235 |
10, // 4 |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2236 |
15, // 5 NormPriority |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2237 |
18, // 6 |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2238 |
|
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2239 |
21, // 7 |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2240 |
25, // 8 |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2241 |
28, // 9 NearMaxPriority |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2242 |
|
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2243 |
31, // 10 MaxPriority |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2244 |
|
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2245 |
31 // 11 CriticalPriority |
10565 | 2246 |
}; |
14286 | 2247 |
#else |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2248 |
// Using Mach high-level priority assignments |
11601
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2249 |
int os::java_to_os_priority[CriticalPriority + 1] = { |
10565 | 2250 |
0, // 0 Entry should never be used (MINPRI_USER) |
2251 |
||
2252 |
27, // 1 MinPriority |
|
2253 |
28, // 2 |
|
2254 |
29, // 3 |
|
2255 |
||
2256 |
30, // 4 |
|
2257 |
31, // 5 NormPriority (BASEPRI_DEFAULT) |
|
2258 |
32, // 6 |
|
2259 |
||
2260 |
33, // 7 |
|
2261 |
34, // 8 |
|
2262 |
35, // 9 NearMaxPriority |
|
2263 |
||
11601
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2264 |
36, // 10 MaxPriority |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2265 |
|
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2266 |
36 // 11 CriticalPriority |
10565 | 2267 |
}; |
2268 |
#endif |
|
2269 |
||
2270 |
static int prio_init() { |
|
2271 |
if (ThreadPriorityPolicy == 1) { |
|
2272 |
if (geteuid() != 0) { |
|
2273 |
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) { |
|
53155
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2274 |
warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \ |
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2275 |
"e.g., being the root user. If the necessary permission is not " \ |
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2276 |
"possessed, changes to priority will be silently ignored."); |
10565 | 2277 |
} |
2278 |
} |
|
2279 |
} |
|
11601
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2280 |
if (UseCriticalJavaThreadPriority) { |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2281 |
os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority]; |
f359304c1856
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
11593
diff
changeset
|
2282 |
} |
10565 | 2283 |
return 0; |
2284 |
} |
|
2285 |
||
2286 |
OSReturn os::set_native_priority(Thread* thread, int newpri) { |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
2287 |
if (!UseThreadPriorities || ThreadPriorityPolicy == 0) return OS_OK; |
10565 | 2288 |
|
2289 |
#ifdef __OpenBSD__ |
|
2290 |
// OpenBSD pthread_setprio starves low priority threads |
|
2291 |
return OS_OK; |
|
2292 |
#elif defined(__FreeBSD__) |
|
2293 |
int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri); |
|
53155
c3d6035c11f3
8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
mbaesken
parents:
53104
diff
changeset
|
2294 |
return (ret == 0) ? OS_OK : OS_ERR; |
10565 | 2295 |
#elif defined(__APPLE__) || defined(__NetBSD__) |
2296 |
struct sched_param sp; |
|
2297 |
int policy; |
|
53104
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2298 |
|
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2299 |
if (pthread_getschedparam(thread->osthread()->pthread_id(), &policy, &sp) != 0) { |
10565 | 2300 |
return OS_ERR; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2301 |
} |
10565 | 2302 |
|
2303 |
sp.sched_priority = newpri; |
|
53104
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2304 |
if (pthread_setschedparam(thread->osthread()->pthread_id(), policy, &sp) != 0) { |
10565 | 2305 |
return OS_ERR; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2306 |
} |
10565 | 2307 |
|
2308 |
return OS_OK; |
|
2309 |
#else |
|
2310 |
int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri); |
|
2311 |
return (ret == 0) ? OS_OK : OS_ERR; |
|
2312 |
#endif |
|
2313 |
} |
|
2314 |
||
2315 |
OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
2316 |
if (!UseThreadPriorities || ThreadPriorityPolicy == 0) { |
10565 | 2317 |
*priority_ptr = java_to_os_priority[NormPriority]; |
2318 |
return OS_OK; |
|
2319 |
} |
|
2320 |
||
2321 |
errno = 0; |
|
2322 |
#if defined(__OpenBSD__) || defined(__FreeBSD__) |
|
2323 |
*priority_ptr = pthread_getprio(thread->osthread()->pthread_id()); |
|
2324 |
#elif defined(__APPLE__) || defined(__NetBSD__) |
|
2325 |
int policy; |
|
2326 |
struct sched_param sp; |
|
2327 |
||
53104
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2328 |
int res = pthread_getschedparam(thread->osthread()->pthread_id(), &policy, &sp); |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2329 |
if (res != 0) { |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2330 |
*priority_ptr = -1; |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2331 |
return OS_ERR; |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2332 |
} else { |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2333 |
*priority_ptr = sp.sched_priority; |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2334 |
return OS_OK; |
95937fc2a05e
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
mbaesken
parents:
53077
diff
changeset
|
2335 |
} |
10565 | 2336 |
#else |
2337 |
*priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id()); |
|
2338 |
#endif |
|
2339 |
return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR); |
|
2340 |
} |
|
2341 |
||
2342 |
//////////////////////////////////////////////////////////////////////////////// |
|
2343 |
// suspend/resume support |
|
2344 |
||
47106 | 2345 |
// The low-level signal-based suspend/resume support is a remnant from the |
10565 | 2346 |
// old VM-suspension that used to be for java-suspension, safepoints etc, |
47106 | 2347 |
// within hotspot. Currently used by JFR's OSThreadSampler |
2348 |
// |
|
10565 | 2349 |
// The remaining code is greatly simplified from the more general suspension |
2350 |
// code that used to be used. |
|
2351 |
// |
|
2352 |
// The protocol is quite simple: |
|
2353 |
// - suspend: |
|
2354 |
// - sends a signal to the target thread |
|
2355 |
// - polls the suspend state of the osthread using a yield loop |
|
2356 |
// - target thread signal handler (SR_handler) sets suspend state |
|
2357 |
// and blocks in sigsuspend until continued |
|
2358 |
// - resume: |
|
2359 |
// - sets target osthread state to continue |
|
2360 |
// - sends signal to end the sigsuspend loop in the SR_handler |
|
2361 |
// |
|
40377
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2362 |
// Note that the SR_lock plays no role in this suspend/resume protocol, |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2363 |
// but is checked for NULL in SR_handler as a thread termination indicator. |
47106 | 2364 |
// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. |
2365 |
// |
|
2366 |
// Note that resume_clear_context() and suspend_save_context() are needed |
|
2367 |
// by SR_handler(), so that fetch_frame_from_ucontext() works, |
|
2368 |
// which in part is used by: |
|
2369 |
// - Forte Analyzer: AsyncGetCallTrace() |
|
2370 |
// - StackBanging: get_frame_at_stack_banging_point() |
|
10565 | 2371 |
|
2372 |
static void resume_clear_context(OSThread *osthread) { |
|
2373 |
osthread->set_ucontext(NULL); |
|
2374 |
osthread->set_siginfo(NULL); |
|
2375 |
} |
|
2376 |
||
2377 |
static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) { |
|
2378 |
osthread->set_ucontext(context); |
|
2379 |
osthread->set_siginfo(siginfo); |
|
2380 |
} |
|
2381 |
||
2382 |
// Handler function invoked when a thread's execution is suspended or |
|
2383 |
// resumed. We have to be careful that only async-safe functions are |
|
2384 |
// called here (Note: most pthread functions are not async safe and |
|
2385 |
// should be avoided.) |
|
2386 |
// |
|
2387 |
// Note: sigwait() is a more natural fit than sigsuspend() from an |
|
2388 |
// interface point of view, but sigwait() prevents the signal hander |
|
2389 |
// from being run. libpthread would get very confused by not having |
|
2390 |
// its signal handlers run and prevents sigwait()'s use with the |
|
2391 |
// mutex granting granting signal. |
|
2392 |
// |
|
18025 | 2393 |
// Currently only ever called on the VMThread or JavaThread |
10565 | 2394 |
// |
48635
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2395 |
#ifdef __APPLE__ |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2396 |
static OSXSemaphore sr_semaphore; |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2397 |
#else |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2398 |
static PosixSemaphore sr_semaphore; |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2399 |
#endif |
612dfa1d8aad
8130039: Move the platform-specific [OS]Semaphore code
coleenp
parents:
48153
diff
changeset
|
2400 |
|
10565 | 2401 |
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) { |
2402 |
// Save and restore errno to avoid confusing native code with EINTR |
|
2403 |
// after sigsuspend. |
|
2404 |
int old_errno = errno; |
|
2405 |
||
40377
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2406 |
Thread* thread = Thread::current_or_null_safe(); |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2407 |
assert(thread != NULL, "Missing current thread in SR_handler"); |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2408 |
|
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2409 |
// On some systems we have seen signal delivery get "stuck" until the signal |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2410 |
// mask is changed as part of thread termination. Check that the current thread |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2411 |
// has not already terminated (via SR_lock()) - else the following assertion |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2412 |
// will fail because the thread is no longer a JavaThread as the ~JavaThread |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2413 |
// destructor has completed. |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2414 |
|
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2415 |
if (thread->SR_lock() == NULL) { |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2416 |
return; |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2417 |
} |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2418 |
|
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2419 |
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread"); |
b77bf599c11b
8159461: bigapps/Kitchensink/stressExitCode hits assert: Must be VMThread or JavaThread
dholmes
parents:
40010
diff
changeset
|
2420 |
|
10565 | 2421 |
OSThread* osthread = thread->osthread(); |
18025 | 2422 |
|
2423 |
os::SuspendResume::State current = osthread->sr.state(); |
|
2424 |
if (current == os::SuspendResume::SR_SUSPEND_REQUEST) { |
|
10565 | 2425 |
suspend_save_context(osthread, siginfo, context); |
2426 |
||
18025 | 2427 |
// attempt to switch the state, we assume we had a SUSPEND_REQUEST |
2428 |
os::SuspendResume::State state = osthread->sr.suspended(); |
|
2429 |
if (state == os::SuspendResume::SR_SUSPENDED) { |
|
2430 |
sigset_t suspend_set; // signals for sigsuspend() |
|
2431 |
||
2432 |
// get current set of blocked signals and unblock resume signal |
|
2433 |
pthread_sigmask(SIG_BLOCK, NULL, &suspend_set); |
|
2434 |
sigdelset(&suspend_set, SR_signum); |
|
2435 |
||
2436 |
sr_semaphore.signal(); |
|
2437 |
// wait here until we are resumed |
|
2438 |
while (1) { |
|
2439 |
sigsuspend(&suspend_set); |
|
2440 |
||
2441 |
os::SuspendResume::State result = osthread->sr.running(); |
|
2442 |
if (result == os::SuspendResume::SR_RUNNING) { |
|
2443 |
sr_semaphore.signal(); |
|
2444 |
break; |
|
2445 |
} else if (result != os::SuspendResume::SR_SUSPENDED) { |
|
2446 |
ShouldNotReachHere(); |
|
2447 |
} |
|
2448 |
} |
|
2449 |
||
2450 |
} else if (state == os::SuspendResume::SR_RUNNING) { |
|
2451 |
// request was cancelled, continue |
|
2452 |
} else { |
|
2453 |
ShouldNotReachHere(); |
|
2454 |
} |
|
10565 | 2455 |
|
2456 |
resume_clear_context(osthread); |
|
18025 | 2457 |
} else if (current == os::SuspendResume::SR_RUNNING) { |
2458 |
// request was cancelled, continue |
|
2459 |
} else if (current == os::SuspendResume::SR_WAKEUP_REQUEST) { |
|
2460 |
// ignore |
|
10565 | 2461 |
} else { |
18025 | 2462 |
// ignore |
10565 | 2463 |
} |
2464 |
||
2465 |
errno = old_errno; |
|
2466 |
} |
|
2467 |
||
2468 |
||
2469 |
static int SR_initialize() { |
|
2470 |
struct sigaction act; |
|
2471 |
char *s; |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2472 |
// Get signal number to use for suspend/resume |
10565 | 2473 |
if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) { |
2474 |
int sig = ::strtol(s, 0, 10); |
|
34145 | 2475 |
if (sig > MAX2(SIGSEGV, SIGBUS) && // See 4355769. |
2476 |
sig < NSIG) { // Must be legal signal and fit into sigflags[]. |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2477 |
SR_signum = sig; |
34145 | 2478 |
} else { |
2479 |
warning("You set _JAVA_SR_SIGNUM=%d. It must be in range [%d, %d]. Using %d instead.", |
|
2480 |
sig, MAX2(SIGSEGV, SIGBUS)+1, NSIG-1, SR_signum); |
|
10565 | 2481 |
} |
2482 |
} |
|
2483 |
||
2484 |
assert(SR_signum > SIGSEGV && SR_signum > SIGBUS, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2485 |
"SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769"); |
10565 | 2486 |
|
2487 |
sigemptyset(&SR_sigset); |
|
2488 |
sigaddset(&SR_sigset, SR_signum); |
|
2489 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2490 |
// Set up signal handler for suspend/resume |
10565 | 2491 |
act.sa_flags = SA_RESTART|SA_SIGINFO; |
2492 |
act.sa_handler = (void (*)(int)) SR_handler; |
|
2493 |
||
2494 |
// SR_signum is blocked by default. |
|
2495 |
// 4528190 - We also need to block pthread restart signal (32 on all |
|
2496 |
// supported Bsd platforms). Note that BsdThreads need to block |
|
2497 |
// this signal for all threads to work properly. So we don't have |
|
2498 |
// to use hard-coded signal number when setting up the mask. |
|
2499 |
pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask); |
|
2500 |
||
2501 |
if (sigaction(SR_signum, &act, 0) == -1) { |
|
2502 |
return -1; |
|
2503 |
} |
|
2504 |
||
2505 |
// Save signal flag |
|
2506 |
os::Bsd::set_our_sigflags(SR_signum, act.sa_flags); |
|
2507 |
return 0; |
|
2508 |
} |
|
2509 |
||
18025 | 2510 |
static int sr_notify(OSThread* osthread) { |
2511 |
int status = pthread_kill(osthread->pthread_id(), SR_signum); |
|
2512 |
assert_status(status == 0, status, "pthread_kill"); |
|
2513 |
return status; |
|
2514 |
} |
|
2515 |
||
2516 |
// "Randomly" selected value for how long we want to spin |
|
2517 |
// before bailing out on suspending a thread, also how often |
|
2518 |
// we send a signal to a thread we want to resume |
|
2519 |
static const int RANDOMLY_LARGE_INTEGER = 1000000; |
|
2520 |
static const int RANDOMLY_LARGE_INTEGER2 = 100; |
|
10565 | 2521 |
|
2522 |
// returns true on success and false on error - really an error is fatal |
|
2523 |
// but this seems the normal response to library errors |
|
2524 |
static bool do_suspend(OSThread* osthread) { |
|
18025 | 2525 |
assert(osthread->sr.is_running(), "thread should be running"); |
2526 |
assert(!sr_semaphore.trywait(), "semaphore has invalid state"); |
|
2527 |
||
10565 | 2528 |
// mark as suspended and send signal |
18025 | 2529 |
if (osthread->sr.request_suspend() != os::SuspendResume::SR_SUSPEND_REQUEST) { |
2530 |
// failed to switch, state wasn't running? |
|
2531 |
ShouldNotReachHere(); |
|
10565 | 2532 |
return false; |
2533 |
} |
|
18025 | 2534 |
|
2535 |
if (sr_notify(osthread) != 0) { |
|
2536 |
ShouldNotReachHere(); |
|
2537 |
} |
|
2538 |
||
2539 |
// managed to send the signal and switch to SUSPEND_REQUEST, now wait for SUSPENDED |
|
2540 |
while (true) { |
|
53461
08d6edeb3145
8194860: Cleanup Semaphore timed-wait time calculations
dholmes
parents:
53266
diff
changeset
|
2541 |
if (sr_semaphore.timedwait(2)) { |
18025 | 2542 |
break; |
2543 |
} else { |
|
2544 |
// timeout |
|
2545 |
os::SuspendResume::State cancelled = osthread->sr.cancel_suspend(); |
|
2546 |
if (cancelled == os::SuspendResume::SR_RUNNING) { |
|
2547 |
return false; |
|
2548 |
} else if (cancelled == os::SuspendResume::SR_SUSPENDED) { |
|
2549 |
// make sure that we consume the signal on the semaphore as well |
|
2550 |
sr_semaphore.wait(); |
|
2551 |
break; |
|
2552 |
} else { |
|
2553 |
ShouldNotReachHere(); |
|
2554 |
return false; |
|
2555 |
} |
|
2556 |
} |
|
2557 |
} |
|
2558 |
||
2559 |
guarantee(osthread->sr.is_suspended(), "Must be suspended"); |
|
2560 |
return true; |
|
10565 | 2561 |
} |
2562 |
||
2563 |
static void do_resume(OSThread* osthread) { |
|
2564 |
assert(osthread->sr.is_suspended(), "thread should be suspended"); |
|
18025 | 2565 |
assert(!sr_semaphore.trywait(), "invalid semaphore state"); |
2566 |
||
2567 |
if (osthread->sr.request_wakeup() != os::SuspendResume::SR_WAKEUP_REQUEST) { |
|
2568 |
// failed to switch to WAKEUP_REQUEST |
|
2569 |
ShouldNotReachHere(); |
|
2570 |
return; |
|
2571 |
} |
|
2572 |
||
2573 |
while (true) { |
|
2574 |
if (sr_notify(osthread) == 0) { |
|
53461
08d6edeb3145
8194860: Cleanup Semaphore timed-wait time calculations
dholmes
parents:
53266
diff
changeset
|
2575 |
if (sr_semaphore.timedwait(2)) { |
18025 | 2576 |
if (osthread->sr.is_running()) { |
2577 |
return; |
|
2578 |
} |
|
2579 |
} |
|
2580 |
} else { |
|
2581 |
ShouldNotReachHere(); |
|
10565 | 2582 |
} |
2583 |
} |
|
18025 | 2584 |
|
2585 |
guarantee(osthread->sr.is_running(), "Must be running!"); |
|
10565 | 2586 |
} |
2587 |
||
2588 |
/////////////////////////////////////////////////////////////////////////////////// |
|
2589 |
// signal handling (except suspend/resume) |
|
2590 |
||
2591 |
// This routine may be used by user applications as a "hook" to catch signals. |
|
2592 |
// The user-defined signal handler must pass unrecognized signals to this |
|
2593 |
// routine, and if it returns true (non-zero), then the signal handler must |
|
2594 |
// return immediately. If the flag "abort_if_unrecognized" is true, then this |
|
2595 |
// routine will never retun false (zero), but instead will execute a VM panic |
|
2596 |
// routine kill the process. |
|
2597 |
// |
|
2598 |
// If this routine returns false, it is OK to call it again. This allows |
|
2599 |
// the user-defined signal handler to perform checks either before or after |
|
2600 |
// the VM performs its own checks. Naturally, the user code would be making |
|
2601 |
// a serious error if it tried to handle an exception (such as a null check |
|
2602 |
// or breakpoint) that the VM was generating for its own correct operation. |
|
2603 |
// |
|
2604 |
// This routine may recognize any of the following kinds of signals: |
|
2605 |
// SIGBUS, SIGSEGV, SIGILL, SIGFPE, SIGQUIT, SIGPIPE, SIGXFSZ, SIGUSR1. |
|
2606 |
// It should be consulted by handlers for any of those signals. |
|
2607 |
// |
|
2608 |
// The caller of this routine must pass in the three arguments supplied |
|
2609 |
// to the function referred to in the "sa_sigaction" (not the "sa_handler") |
|
2610 |
// field of the structure passed to sigaction(). This routine assumes that |
|
2611 |
// the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART. |
|
2612 |
// |
|
2613 |
// Note that the VM will print warnings if it detects conflicting signal |
|
2614 |
// handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". |
|
2615 |
// |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2616 |
extern "C" JNIEXPORT int JVM_handle_bsd_signal(int signo, siginfo_t* siginfo, |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2617 |
void* ucontext, |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2618 |
int abort_if_unrecognized); |
10565 | 2619 |
|
50184
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
2620 |
static void signalHandler(int sig, siginfo_t* info, void* uc) { |
10565 | 2621 |
assert(info != NULL && uc != NULL, "it must be old kernel"); |
15743
f708934a12e7
6749267: Signal handler should save/restore errno
hseigel
parents:
15593
diff
changeset
|
2622 |
int orig_errno = errno; // Preserve errno value over signal handler. |
10565 | 2623 |
JVM_handle_bsd_signal(sig, info, uc, true); |
15743
f708934a12e7
6749267: Signal handler should save/restore errno
hseigel
parents:
15593
diff
changeset
|
2624 |
errno = orig_errno; |
10565 | 2625 |
} |
2626 |
||
2627 |
||
2628 |
// This boolean allows users to forward their own non-matching signals |
|
2629 |
// to JVM_handle_bsd_signal, harmlessly. |
|
2630 |
bool os::Bsd::signal_handlers_are_installed = false; |
|
2631 |
||
2632 |
// For signal-chaining |
|
2633 |
bool os::Bsd::libjsig_is_loaded = false; |
|
2634 |
typedef struct sigaction *(*get_signal_t)(int); |
|
2635 |
get_signal_t os::Bsd::get_signal_action = NULL; |
|
2636 |
||
2637 |
struct sigaction* os::Bsd::get_chained_signal_action(int sig) { |
|
2638 |
struct sigaction *actp = NULL; |
|
2639 |
||
2640 |
if (libjsig_is_loaded) { |
|
2641 |
// Retrieve the old signal handler from libjsig |
|
2642 |
actp = (*get_signal_action)(sig); |
|
2643 |
} |
|
2644 |
if (actp == NULL) { |
|
2645 |
// Retrieve the preinstalled signal handler from jvm |
|
54090
3086f9259e97
8170639: [Linux] jsig is limited to a maximum of 64 signals
aoqi
parents:
53886
diff
changeset
|
2646 |
actp = os::Posix::get_preinstalled_handler(sig); |
10565 | 2647 |
} |
2648 |
||
2649 |
return actp; |
|
2650 |
} |
|
2651 |
||
2652 |
static bool call_chained_handler(struct sigaction *actp, int sig, |
|
2653 |
siginfo_t *siginfo, void *context) { |
|
2654 |
// Call the old signal handler |
|
2655 |
if (actp->sa_handler == SIG_DFL) { |
|
2656 |
// It's more reasonable to let jvm treat it as an unexpected exception |
|
2657 |
// instead of taking the default action. |
|
2658 |
return false; |
|
2659 |
} else if (actp->sa_handler != SIG_IGN) { |
|
2660 |
if ((actp->sa_flags & SA_NODEFER) == 0) { |
|
2661 |
// automaticlly block the signal |
|
2662 |
sigaddset(&(actp->sa_mask), sig); |
|
2663 |
} |
|
2664 |
||
2665 |
sa_handler_t hand; |
|
2666 |
sa_sigaction_t sa; |
|
2667 |
bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0; |
|
2668 |
// retrieve the chained handler |
|
2669 |
if (siginfo_flag_set) { |
|
2670 |
sa = actp->sa_sigaction; |
|
2671 |
} else { |
|
2672 |
hand = actp->sa_handler; |
|
2673 |
} |
|
2674 |
||
2675 |
if ((actp->sa_flags & SA_RESETHAND) != 0) { |
|
2676 |
actp->sa_handler = SIG_DFL; |
|
2677 |
} |
|
2678 |
||
2679 |
// try to honor the signal mask |
|
2680 |
sigset_t oset; |
|
2681 |
pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset); |
|
2682 |
||
2683 |
// call into the chained handler |
|
2684 |
if (siginfo_flag_set) { |
|
2685 |
(*sa)(sig, siginfo, context); |
|
2686 |
} else { |
|
2687 |
(*hand)(sig); |
|
2688 |
} |
|
2689 |
||
2690 |
// restore the signal mask |
|
2691 |
pthread_sigmask(SIG_SETMASK, &oset, 0); |
|
2692 |
} |
|
2693 |
// Tell jvm's signal handler the signal is taken care of. |
|
2694 |
return true; |
|
2695 |
} |
|
2696 |
||
2697 |
bool os::Bsd::chained_handler(int sig, siginfo_t* siginfo, void* context) { |
|
2698 |
bool chained = false; |
|
2699 |
// signal-chaining |
|
2700 |
if (UseSignalChaining) { |
|
2701 |
struct sigaction *actp = get_chained_signal_action(sig); |
|
2702 |
if (actp != NULL) { |
|
2703 |
chained = call_chained_handler(actp, sig, siginfo, context); |
|
2704 |
} |
|
2705 |
} |
|
2706 |
return chained; |
|
2707 |
} |
|
2708 |
||
2709 |
// for diagnostic |
|
34145 | 2710 |
int sigflags[NSIG]; |
10565 | 2711 |
|
2712 |
int os::Bsd::get_our_sigflags(int sig) { |
|
34145 | 2713 |
assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); |
10565 | 2714 |
return sigflags[sig]; |
2715 |
} |
|
2716 |
||
2717 |
void os::Bsd::set_our_sigflags(int sig, int flags) { |
|
34145 | 2718 |
assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); |
2719 |
if (sig > 0 && sig < NSIG) { |
|
2720 |
sigflags[sig] = flags; |
|
2721 |
} |
|
10565 | 2722 |
} |
2723 |
||
2724 |
void os::Bsd::set_signal_handler(int sig, bool set_installed) { |
|
2725 |
// Check for overwrite. |
|
2726 |
struct sigaction oldAct; |
|
2727 |
sigaction(sig, (struct sigaction*)NULL, &oldAct); |
|
2728 |
||
2729 |
void* oldhand = oldAct.sa_sigaction |
|
2730 |
? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
|
2731 |
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
|
2732 |
if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) && |
|
2733 |
oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) && |
|
2734 |
oldhand != CAST_FROM_FN_PTR(void*, (sa_sigaction_t)signalHandler)) { |
|
2735 |
if (AllowUserSignalHandlers || !set_installed) { |
|
2736 |
// Do not overwrite; user takes responsibility to forward to us. |
|
2737 |
return; |
|
2738 |
} else if (UseSignalChaining) { |
|
2739 |
// save the old handler in jvm |
|
54090
3086f9259e97
8170639: [Linux] jsig is limited to a maximum of 64 signals
aoqi
parents:
53886
diff
changeset
|
2740 |
os::Posix::save_preinstalled_handler(sig, oldAct); |
10565 | 2741 |
// libjsig also interposes the sigaction() call below and saves the |
2742 |
// old sigaction on it own. |
|
2743 |
} else { |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32080
diff
changeset
|
2744 |
fatal("Encountered unexpected pre-existing sigaction handler " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32080
diff
changeset
|
2745 |
"%#lx for signal %d.", (long)oldhand, sig); |
10565 | 2746 |
} |
2747 |
} |
|
2748 |
||
2749 |
struct sigaction sigAct; |
|
2750 |
sigfillset(&(sigAct.sa_mask)); |
|
2751 |
sigAct.sa_handler = SIG_DFL; |
|
2752 |
if (!set_installed) { |
|
2753 |
sigAct.sa_flags = SA_SIGINFO|SA_RESTART; |
|
2754 |
} else { |
|
2755 |
sigAct.sa_sigaction = signalHandler; |
|
2756 |
sigAct.sa_flags = SA_SIGINFO|SA_RESTART; |
|
2757 |
} |
|
23522
217a6a90aad3
8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents:
23444
diff
changeset
|
2758 |
#ifdef __APPLE__ |
17868
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2759 |
// Needed for main thread as XNU (Mac OS X kernel) will only deliver SIGSEGV |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2760 |
// (which starts as SIGBUS) on main thread with faulting address inside "stack+guard pages" |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2761 |
// if the signal handler declares it will handle it on alternate stack. |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2762 |
// Notice we only declare we will handle it on alt stack, but we are not |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2763 |
// actually going to use real alt stack - this is just a workaround. |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2764 |
// Please see ux_exception.c, method catch_mach_exception_raise for details |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2765 |
// link http://www.opensource.apple.com/source/xnu/xnu-2050.18.24/bsd/uxkern/ux_exception.c |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2766 |
if (sig == SIGSEGV) { |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2767 |
sigAct.sa_flags |= SA_ONSTACK; |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2768 |
} |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2769 |
#endif |
262aa770cb1b
8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread
hseigel
parents:
17134
diff
changeset
|
2770 |
|
10565 | 2771 |
// Save flags, which are set by ours |
34145 | 2772 |
assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); |
10565 | 2773 |
sigflags[sig] = sigAct.sa_flags; |
2774 |
||
2775 |
int ret = sigaction(sig, &sigAct, &oldAct); |
|
2776 |
assert(ret == 0, "check"); |
|
2777 |
||
2778 |
void* oldhand2 = oldAct.sa_sigaction |
|
2779 |
? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
|
2780 |
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
|
2781 |
assert(oldhand2 == oldhand, "no concurrent signal handler installation"); |
|
2782 |
} |
|
2783 |
||
2784 |
// install signal handlers for signals that HotSpot needs to |
|
2785 |
// handle in order to support Java-level exception handling. |
|
2786 |
||
2787 |
void os::Bsd::install_signal_handlers() { |
|
2788 |
if (!signal_handlers_are_installed) { |
|
2789 |
signal_handlers_are_installed = true; |
|
2790 |
||
2791 |
// signal-chaining |
|
2792 |
typedef void (*signal_setting_t)(); |
|
2793 |
signal_setting_t begin_signal_setting = NULL; |
|
2794 |
signal_setting_t end_signal_setting = NULL; |
|
2795 |
begin_signal_setting = CAST_TO_FN_PTR(signal_setting_t, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2796 |
dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting")); |
10565 | 2797 |
if (begin_signal_setting != NULL) { |
2798 |
end_signal_setting = CAST_TO_FN_PTR(signal_setting_t, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2799 |
dlsym(RTLD_DEFAULT, "JVM_end_signal_setting")); |
10565 | 2800 |
get_signal_action = CAST_TO_FN_PTR(get_signal_t, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2801 |
dlsym(RTLD_DEFAULT, "JVM_get_signal_action")); |
10565 | 2802 |
libjsig_is_loaded = true; |
2803 |
assert(UseSignalChaining, "should enable signal-chaining"); |
|
2804 |
} |
|
2805 |
if (libjsig_is_loaded) { |
|
2806 |
// Tell libjsig jvm is setting signal handlers |
|
2807 |
(*begin_signal_setting)(); |
|
2808 |
} |
|
2809 |
||
2810 |
set_signal_handler(SIGSEGV, true); |
|
2811 |
set_signal_handler(SIGPIPE, true); |
|
2812 |
set_signal_handler(SIGBUS, true); |
|
2813 |
set_signal_handler(SIGILL, true); |
|
2814 |
set_signal_handler(SIGFPE, true); |
|
2815 |
set_signal_handler(SIGXFSZ, true); |
|
2816 |
||
2817 |
#if defined(__APPLE__) |
|
2818 |
// In Mac OS X 10.4, CrashReporter will write a crash log for all 'fatal' signals, including |
|
2819 |
// signals caught and handled by the JVM. To work around this, we reset the mach task |
|
2820 |
// signal handler that's placed on our process by CrashReporter. This disables |
|
2821 |
// CrashReporter-based reporting. |
|
2822 |
// |
|
2823 |
// This work-around is not necessary for 10.5+, as CrashReporter no longer intercedes |
|
2824 |
// on caught fatal signals. |
|
2825 |
// |
|
2826 |
// Additionally, gdb installs both standard BSD signal handlers, and mach exception |
|
2827 |
// handlers. By replacing the existing task exception handler, we disable gdb's mach |
|
2828 |
// exception handling, while leaving the standard BSD signal handlers functional. |
|
2829 |
kern_return_t kr; |
|
2830 |
kr = task_set_exception_ports(mach_task_self(), |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2831 |
EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2832 |
MACH_PORT_NULL, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2833 |
EXCEPTION_STATE_IDENTITY, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2834 |
MACHINE_THREAD_STATE); |
10565 | 2835 |
|
2836 |
assert(kr == KERN_SUCCESS, "could not set mach task signal handler"); |
|
2837 |
#endif |
|
2838 |
||
2839 |
if (libjsig_is_loaded) { |
|
2840 |
// Tell libjsig jvm finishes setting signal handlers |
|
2841 |
(*end_signal_setting)(); |
|
2842 |
} |
|
2843 |
||
2844 |
// We don't activate signal checker if libjsig is in place, we trust ourselves |
|
2845 |
// and if UserSignalHandler is installed all bets are off |
|
2846 |
if (CheckJNICalls) { |
|
2847 |
if (libjsig_is_loaded) { |
|
19532
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2848 |
if (PrintJNIResolving) { |
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2849 |
tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); |
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2850 |
} |
10565 | 2851 |
check_signals = false; |
2852 |
} |
|
2853 |
if (AllowUserSignalHandlers) { |
|
19532
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2854 |
if (PrintJNIResolving) { |
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2855 |
tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); |
6a9f968b7b05
7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris
hseigel
parents:
19531
diff
changeset
|
2856 |
} |
10565 | 2857 |
check_signals = false; |
2858 |
} |
|
2859 |
} |
|
2860 |
} |
|
2861 |
} |
|
2862 |
||
2863 |
||
2864 |
///// |
|
2865 |
// glibc on Bsd platform uses non-documented flag |
|
2866 |
// to indicate, that some special sort of signal |
|
2867 |
// trampoline is used. |
|
2868 |
// We will never set this flag, and we should |
|
2869 |
// ignore this flag in our diagnostic |
|
2870 |
#ifdef SIGNIFICANT_SIGNAL_MASK |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2871 |
#undef SIGNIFICANT_SIGNAL_MASK |
10565 | 2872 |
#endif |
2873 |
#define SIGNIFICANT_SIGNAL_MASK (~0x04000000) |
|
2874 |
||
2875 |
static const char* get_signal_handler_name(address handler, |
|
2876 |
char* buf, int buflen) { |
|
2877 |
int offset; |
|
2878 |
bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset); |
|
2879 |
if (found) { |
|
2880 |
// skip directory names |
|
2881 |
const char *p1, *p2; |
|
2882 |
p1 = buf; |
|
2883 |
size_t len = strlen(os::file_separator()); |
|
2884 |
while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len; |
|
2885 |
jio_snprintf(buf, buflen, "%s+0x%x", p1, offset); |
|
2886 |
} else { |
|
2887 |
jio_snprintf(buf, buflen, PTR_FORMAT, handler); |
|
2888 |
} |
|
2889 |
return buf; |
|
2890 |
} |
|
2891 |
||
2892 |
static void print_signal_handler(outputStream* st, int sig, |
|
2893 |
char* buf, size_t buflen) { |
|
2894 |
struct sigaction sa; |
|
2895 |
||
2896 |
sigaction(sig, NULL, &sa); |
|
2897 |
||
2898 |
// See comment for SIGNIFICANT_SIGNAL_MASK define |
|
2899 |
sa.sa_flags &= SIGNIFICANT_SIGNAL_MASK; |
|
2900 |
||
2901 |
st->print("%s: ", os::exception_name(sig, buf, buflen)); |
|
2902 |
||
2903 |
address handler = (sa.sa_flags & SA_SIGINFO) |
|
2904 |
? CAST_FROM_FN_PTR(address, sa.sa_sigaction) |
|
2905 |
: CAST_FROM_FN_PTR(address, sa.sa_handler); |
|
2906 |
||
2907 |
if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) { |
|
2908 |
st->print("SIG_DFL"); |
|
2909 |
} else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) { |
|
2910 |
st->print("SIG_IGN"); |
|
2911 |
} else { |
|
2912 |
st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); |
|
2913 |
} |
|
2914 |
||
22826 | 2915 |
st->print(", sa_mask[0]="); |
2916 |
os::Posix::print_signal_set_short(st, &sa.sa_mask); |
|
10565 | 2917 |
|
2918 |
address rh = VMError::get_resetted_sighandler(sig); |
|
2919 |
// May be, handler was resetted by VMError? |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
2920 |
if (rh != NULL) { |
10565 | 2921 |
handler = rh; |
2922 |
sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; |
|
2923 |
} |
|
2924 |
||
22826 | 2925 |
st->print(", sa_flags="); |
2926 |
os::Posix::print_sa_flags(st, sa.sa_flags); |
|
10565 | 2927 |
|
2928 |
// Check: is it our handler? |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
2929 |
if (handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
2930 |
handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { |
10565 | 2931 |
// It is our signal handler |
2932 |
// check for flags, reset system-used one! |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
2933 |
if ((int)sa.sa_flags != os::Bsd::get_our_sigflags(sig)) { |
10565 | 2934 |
st->print( |
2935 |
", flags was changed from " PTR32_FORMAT ", consider using jsig library", |
|
2936 |
os::Bsd::get_our_sigflags(sig)); |
|
2937 |
} |
|
2938 |
} |
|
2939 |
st->cr(); |
|
2940 |
} |
|
2941 |
||
2942 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2943 |
#define DO_SIGNAL_CHECK(sig) \ |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2944 |
do { \ |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2945 |
if (!sigismember(&check_signal_done, sig)) { \ |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2946 |
os::Bsd::check_signal_handler(sig); \ |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2947 |
} \ |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
2948 |
} while (0) |
10565 | 2949 |
|
2950 |
// This method is a periodic task to check for misbehaving JNI applications |
|
2951 |
// under CheckJNI, we can add any periodic checks here |
|
2952 |
||
2953 |
void os::run_periodic_checks() { |
|
2954 |
||
2955 |
if (check_signals == false) return; |
|
2956 |
||
2957 |
// SEGV and BUS if overridden could potentially prevent |
|
2958 |
// generation of hs*.log in the event of a crash, debugging |
|
2959 |
// such a case can be very challenging, so we absolutely |
|
2960 |
// check the following for a good measure: |
|
2961 |
DO_SIGNAL_CHECK(SIGSEGV); |
|
2962 |
DO_SIGNAL_CHECK(SIGILL); |
|
2963 |
DO_SIGNAL_CHECK(SIGFPE); |
|
2964 |
DO_SIGNAL_CHECK(SIGBUS); |
|
2965 |
DO_SIGNAL_CHECK(SIGPIPE); |
|
2966 |
DO_SIGNAL_CHECK(SIGXFSZ); |
|
2967 |
||
2968 |
||
2969 |
// ReduceSignalUsage allows the user to override these handlers |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47524
diff
changeset
|
2970 |
// see comments at the very top and jvm_md.h |
10565 | 2971 |
if (!ReduceSignalUsage) { |
2972 |
DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL); |
|
2973 |
DO_SIGNAL_CHECK(SHUTDOWN2_SIGNAL); |
|
2974 |
DO_SIGNAL_CHECK(SHUTDOWN3_SIGNAL); |
|
2975 |
DO_SIGNAL_CHECK(BREAK_SIGNAL); |
|
2976 |
} |
|
2977 |
||
2978 |
DO_SIGNAL_CHECK(SR_signum); |
|
2979 |
} |
|
2980 |
||
2981 |
typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *); |
|
2982 |
||
2983 |
static os_sigaction_t os_sigaction = NULL; |
|
2984 |
||
2985 |
void os::Bsd::check_signal_handler(int sig) { |
|
2986 |
char buf[O_BUFLEN]; |
|
2987 |
address jvmHandler = NULL; |
|
2988 |
||
2989 |
||
2990 |
struct sigaction act; |
|
2991 |
if (os_sigaction == NULL) { |
|
2992 |
// only trust the default sigaction, in case it has been interposed |
|
2993 |
os_sigaction = (os_sigaction_t)dlsym(RTLD_DEFAULT, "sigaction"); |
|
2994 |
if (os_sigaction == NULL) return; |
|
2995 |
} |
|
2996 |
||
2997 |
os_sigaction(sig, (struct sigaction*)NULL, &act); |
|
2998 |
||
2999 |
||
3000 |
act.sa_flags &= SIGNIFICANT_SIGNAL_MASK; |
|
3001 |
||
3002 |
address thisHandler = (act.sa_flags & SA_SIGINFO) |
|
3003 |
? CAST_FROM_FN_PTR(address, act.sa_sigaction) |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
3004 |
: CAST_FROM_FN_PTR(address, act.sa_handler); |
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
3005 |
|
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
3006 |
|
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
3007 |
switch (sig) { |
10565 | 3008 |
case SIGSEGV: |
3009 |
case SIGBUS: |
|
3010 |
case SIGFPE: |
|
3011 |
case SIGPIPE: |
|
3012 |
case SIGILL: |
|
3013 |
case SIGXFSZ: |
|
3014 |
jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler); |
|
3015 |
break; |
|
3016 |
||
3017 |
case SHUTDOWN1_SIGNAL: |
|
3018 |
case SHUTDOWN2_SIGNAL: |
|
3019 |
case SHUTDOWN3_SIGNAL: |
|
3020 |
case BREAK_SIGNAL: |
|
3021 |
jvmHandler = (address)user_handler(); |
|
3022 |
break; |
|
3023 |
||
3024 |
default: |
|
3025 |
if (sig == SR_signum) { |
|
3026 |
jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler); |
|
3027 |
} else { |
|
3028 |
return; |
|
3029 |
} |
|
3030 |
break; |
|
3031 |
} |
|
3032 |
||
3033 |
if (thisHandler != jvmHandler) { |
|
3034 |
tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN)); |
|
3035 |
tty->print("expected:%s", get_signal_handler_name(jvmHandler, buf, O_BUFLEN)); |
|
3036 |
tty->print_cr(" found:%s", get_signal_handler_name(thisHandler, buf, O_BUFLEN)); |
|
3037 |
// No need to check this sig any longer |
|
3038 |
sigaddset(&check_signal_done, sig); |
|
23444
b5457261694b
6536943: Bogus -Xcheck:jni warning for SIG_INT action for SIGINT in JVM started from non-interactive shell
minqi
parents:
22894
diff
changeset
|
3039 |
// Running under non-interactive shell, SHUTDOWN2_SIGNAL will be reassigned SIG_IGN |
b5457261694b
6536943: Bogus -Xcheck:jni warning for SIG_INT action for SIGINT in JVM started from non-interactive shell
minqi
parents:
22894
diff
changeset
|
3040 |
if (sig == SHUTDOWN2_SIGNAL && !isatty(fileno(stdin))) { |
b5457261694b
6536943: Bogus -Xcheck:jni warning for SIG_INT action for SIGINT in JVM started from non-interactive shell
minqi
parents:
22894
diff
changeset
|
3041 |
tty->print_cr("Running in non-interactive shell, %s handler is replaced by shell", |
b5457261694b
6536943: Bogus -Xcheck:jni warning for SIG_INT action for SIGINT in JVM started from non-interactive shell
minqi
parents:
22894
diff
changeset
|
3042 |
exception_name(sig, buf, O_BUFLEN)); |
b5457261694b
6536943: Bogus -Xcheck:jni warning for SIG_INT action for SIGINT in JVM started from non-interactive shell
minqi
parents:
22894
diff
changeset
|
3043 |
} |
10565 | 3044 |
} else if(os::Bsd::get_our_sigflags(sig) != 0 && (int)act.sa_flags != os::Bsd::get_our_sigflags(sig)) { |
3045 |
tty->print("Warning: %s handler flags ", exception_name(sig, buf, O_BUFLEN)); |
|
34667 | 3046 |
tty->print("expected:"); |
3047 |
os::Posix::print_sa_flags(tty, os::Bsd::get_our_sigflags(sig)); |
|
3048 |
tty->cr(); |
|
3049 |
tty->print(" found:"); |
|
3050 |
os::Posix::print_sa_flags(tty, act.sa_flags); |
|
3051 |
tty->cr(); |
|
10565 | 3052 |
// No need to check this sig any longer |
3053 |
sigaddset(&check_signal_done, sig); |
|
3054 |
} |
|
3055 |
||
3056 |
// Dump all the signal |
|
3057 |
if (sigismember(&check_signal_done, sig)) { |
|
3058 |
print_signal_handlers(tty, buf, O_BUFLEN); |
|
3059 |
} |
|
3060 |
} |
|
3061 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3062 |
extern void report_error(char* file_name, int line_no, char* title, |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3063 |
char* format, ...); |
10565 | 3064 |
|
3065 |
// this is called _before_ the most of global arguments have been parsed |
|
3066 |
void os::init(void) { |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3067 |
char dummy; // used to get a guess on initial stack address |
10565 | 3068 |
|
3069 |
clock_tics_per_sec = CLK_TCK; |
|
3070 |
||
3071 |
init_random(1234567); |
|
3072 |
||
3073 |
Bsd::set_page_size(getpagesize()); |
|
3074 |
if (Bsd::page_size() == -1) { |
|
37113 | 3075 |
fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno)); |
10565 | 3076 |
} |
3077 |
init_page_sizes((size_t) Bsd::page_size()); |
|
3078 |
||
3079 |
Bsd::initialize_system_info(); |
|
3080 |
||
48005
9fd89aabb6cd
8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
dholmes
parents:
47903
diff
changeset
|
3081 |
// _main_thread points to the thread that created/loaded the JVM. |
10565 | 3082 |
Bsd::_main_thread = pthread_self(); |
3083 |
||
3084 |
Bsd::clock_init(); |
|
21185
9d53434b1ef5
8027294: Prepare hotspot for non TOD based uptime counter
jbachorik
parents:
20683
diff
changeset
|
3085 |
initial_time_count = javaTimeNanos(); |
10565 | 3086 |
|
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
3087 |
os::Posix::init(); |
10565 | 3088 |
} |
3089 |
||
3090 |
// To install functions for atexit system call |
|
3091 |
extern "C" { |
|
3092 |
static void perfMemory_exit_helper() { |
|
3093 |
perfMemory_exit(); |
|
3094 |
} |
|
3095 |
} |
|
3096 |
||
3097 |
// this is called _after_ the global arguments have been parsed |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3098 |
jint os::init_2(void) { |
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
3099 |
|
52581
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52304
diff
changeset
|
3100 |
// This could be set after os::Posix::init() but all platforms |
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52304
diff
changeset
|
3101 |
// have to set it the same so we have to mirror Solaris. |
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52304
diff
changeset
|
3102 |
DEBUG_ONLY(os::set_mutex_init_done();) |
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52304
diff
changeset
|
3103 |
|
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
3104 |
os::Posix::init_2(); |
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
3105 |
|
10565 | 3106 |
// initialize suspend/resume support - must do this before signal_sets_init() |
3107 |
if (SR_initialize() != 0) { |
|
3108 |
perror("SR_initialize failed"); |
|
3109 |
return JNI_ERR; |
|
3110 |
} |
|
3111 |
||
3112 |
Bsd::signal_sets_init(); |
|
3113 |
Bsd::install_signal_handlers(); |
|
50184
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
3114 |
// Initialize data for jdk.internal.misc.Signal |
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
3115 |
if (!ReduceSignalUsage) { |
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
3116 |
jdk_misc_signal_init(); |
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
50177
diff
changeset
|
3117 |
} |
10565 | 3118 |
|
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40667
diff
changeset
|
3119 |
// Check and sets minimum stack sizes against command line options |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40667
diff
changeset
|
3120 |
if (Posix::set_minimum_stack_sizes() == JNI_ERR) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3121 |
return JNI_ERR; |
10565 | 3122 |
} |
3123 |
||
3124 |
if (MaxFDLimit) { |
|
3125 |
// set the number of file descriptors to max. print out error |
|
3126 |
// if getrlimit/setrlimit fails but continue regardless. |
|
3127 |
struct rlimit nbr_files; |
|
3128 |
int status = getrlimit(RLIMIT_NOFILE, &nbr_files); |
|
3129 |
if (status != 0) { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
37113
diff
changeset
|
3130 |
log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno)); |
10565 | 3131 |
} else { |
3132 |
nbr_files.rlim_cur = nbr_files.rlim_max; |
|
3133 |
||
3134 |
#ifdef __APPLE__ |
|
3135 |
// Darwin returns RLIM_INFINITY for rlim_max, but fails with EINVAL if |
|
3136 |
// you attempt to use RLIM_INFINITY. As per setrlimit(2), OPEN_MAX must |
|
3137 |
// be used instead |
|
3138 |
nbr_files.rlim_cur = MIN(OPEN_MAX, nbr_files.rlim_cur); |
|
3139 |
#endif |
|
3140 |
||
3141 |
status = setrlimit(RLIMIT_NOFILE, &nbr_files); |
|
3142 |
if (status != 0) { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
37113
diff
changeset
|
3143 |
log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno)); |
10565 | 3144 |
} |
3145 |
} |
|
3146 |
} |
|
3147 |
||
3148 |
// at-exit methods are called in the reverse order of their registration. |
|
3149 |
// atexit functions are called on return from main or as a result of a |
|
3150 |
// call to exit(3C). There can be only 32 of these functions registered |
|
3151 |
// and atexit() does not set errno. |
|
3152 |
||
3153 |
if (PerfAllowAtExitRegistration) { |
|
3154 |
// only register atexit functions if PerfAllowAtExitRegistration is set. |
|
3155 |
// atexit functions can be delayed until process exit time, which |
|
3156 |
// can be problematic for embedded VM situations. Embedded VMs should |
|
3157 |
// call DestroyJavaVM() to assure that VM resources are released. |
|
3158 |
||
3159 |
// note: perfMemory_exit_helper atexit function may be removed in |
|
3160 |
// the future if the appropriate cleanup code can be added to the |
|
3161 |
// VM_Exit VMOperation's doit method. |
|
3162 |
if (atexit(perfMemory_exit_helper) != 0) { |
|
46507
7db40fa6eff7
8174231: Factor out and share PlatformEvent and Parker code for POSIX systems
dholmes
parents:
46346
diff
changeset
|
3163 |
warning("os::init_2 atexit(perfMemory_exit_helper) failed"); |
10565 | 3164 |
} |
3165 |
} |
|
3166 |
||
3167 |
// initialize thread priority policy |
|
3168 |
prio_init(); |
|
3169 |
||
10739 | 3170 |
#ifdef __APPLE__ |
3171 |
// dynamically link to objective c gc registration |
|
3172 |
void *handleLibObjc = dlopen(OBJC_LIB, RTLD_LAZY); |
|
3173 |
if (handleLibObjc != NULL) { |
|
3174 |
objc_registerThreadWithCollectorFunction = (objc_registerThreadWithCollector_t) dlsym(handleLibObjc, OBJC_GCREGISTER); |
|
3175 |
} |
|
3176 |
#endif |
|
3177 |
||
10565 | 3178 |
return JNI_OK; |
3179 |
} |
|
3180 |
||
3181 |
// Mark the polling page as unreadable |
|
3182 |
void os::make_polling_page_unreadable(void) { |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3183 |
if (!guard_memory((char*)_polling_page, Bsd::page_size())) { |
10565 | 3184 |
fatal("Could not disable polling page"); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3185 |
} |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3186 |
} |
10565 | 3187 |
|
3188 |
// Mark the polling page as readable |
|
3189 |
void os::make_polling_page_readable(void) { |
|
25064
244218e6ec0a
8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket
dcubed
parents:
24931
diff
changeset
|
3190 |
if (!bsd_mprotect((char *)_polling_page, Bsd::page_size(), PROT_READ)) { |
10565 | 3191 |
fatal("Could not enable polling page"); |
3192 |
} |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3193 |
} |
10565 | 3194 |
|
3195 |
int os::active_processor_count() { |
|
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3196 |
// User has overridden the number of active processors |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3197 |
if (ActiveProcessorCount > 0) { |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3198 |
log_trace(os)("active_processor_count: " |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3199 |
"active processor count set by user : %d", |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3200 |
ActiveProcessorCount); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3201 |
return ActiveProcessorCount; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3202 |
} |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
47881
diff
changeset
|
3203 |
|
10565 | 3204 |
return _processor_count; |
3205 |
} |
|
3206 |
||
55154
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3207 |
#ifdef __APPLE__ |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3208 |
uint os::processor_id() { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3209 |
static volatile int* volatile apic_to_cpu_mapping = NULL; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3210 |
static volatile int next_cpu_id = 0; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3211 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3212 |
volatile int* mapping = OrderAccess::load_acquire(&apic_to_cpu_mapping); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3213 |
if (mapping == NULL) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3214 |
// Calculate possible number space for APIC ids. This space is not necessarily |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3215 |
// in the range [0, number_of_cpus). |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3216 |
uint total_bits = 0; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3217 |
for (uint i = 0;; ++i) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3218 |
uint eax = 0xb; // Query topology leaf |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3219 |
uint ebx; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3220 |
uint ecx = i; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3221 |
uint edx; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3222 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3223 |
__asm__ ("cpuid\n\t" : "+a" (eax), "+b" (ebx), "+c" (ecx), "+d" (edx) : ); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3224 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3225 |
uint level_type = (ecx >> 8) & 0xFF; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3226 |
if (level_type == 0) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3227 |
// Invalid level; end of topology |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3228 |
break; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3229 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3230 |
uint level_apic_id_shift = eax & ((1u << 5) - 1); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3231 |
total_bits += level_apic_id_shift; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3232 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3233 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3234 |
uint max_apic_ids = 1u << total_bits; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3235 |
mapping = NEW_C_HEAP_ARRAY(int, max_apic_ids, mtInternal); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3236 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3237 |
for (uint i = 0; i < max_apic_ids; ++i) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3238 |
mapping[i] = -1; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3239 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3240 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3241 |
if (!Atomic::replace_if_null(mapping, &apic_to_cpu_mapping)) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3242 |
FREE_C_HEAP_ARRAY(int, mapping); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3243 |
mapping = OrderAccess::load_acquire(&apic_to_cpu_mapping); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3244 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3245 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3246 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3247 |
uint eax = 0xb; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3248 |
uint ebx; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3249 |
uint ecx = 0; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3250 |
uint edx; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3251 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3252 |
asm ("cpuid\n\t" : "+a" (eax), "+b" (ebx), "+c" (ecx), "+d" (edx) : ); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3253 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3254 |
// Map from APIC id to a unique logical processor ID in the expected |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3255 |
// [0, num_processors) range. |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3256 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3257 |
uint apic_id = edx; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3258 |
int cpu_id = Atomic::load(&mapping[apic_id]); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3259 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3260 |
while (cpu_id < 0) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3261 |
if (Atomic::cmpxchg(-2, &mapping[apic_id], -1)) { |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3262 |
Atomic::store(Atomic::add(1, &next_cpu_id) - 1, &mapping[apic_id]); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3263 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3264 |
cpu_id = Atomic::load(&mapping[apic_id]); |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3265 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3266 |
|
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3267 |
return (uint)cpu_id; |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3268 |
} |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3269 |
#endif |
fdddd05767ce
8224816: Provide os::processor_id() implementation for Mac OS
eosterlund
parents:
55044
diff
changeset
|
3270 |
|
10739 | 3271 |
void os::set_native_thread_name(const char *name) { |
3272 |
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5 |
|
3273 |
// This is only supported in Snow Leopard and beyond |
|
3274 |
if (name != NULL) { |
|
3275 |
// Add a "Java: " prefix to the name |
|
3276 |
char buf[MAXTHREADNAMESIZE]; |
|
3277 |
snprintf(buf, sizeof(buf), "Java: %s", name); |
|
3278 |
pthread_setname_np(buf); |
|
3279 |
} |
|
3280 |
#endif |
|
3281 |
} |
|
3282 |
||
10565 | 3283 |
bool os::bind_to_processor(uint processor_id) { |
3284 |
// Not yet implemented. |
|
3285 |
return false; |
|
3286 |
} |
|
3287 |
||
18025 | 3288 |
void os::SuspendedThreadTask::internal_do_task() { |
3289 |
if (do_suspend(_thread->osthread())) { |
|
3290 |
SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext()); |
|
3291 |
do_task(context); |
|
3292 |
do_resume(_thread->osthread()); |
|
3293 |
} |
|
3294 |
} |
|
3295 |
||
10565 | 3296 |
//////////////////////////////////////////////////////////////////////////////// |
3297 |
// debug support |
|
3298 |
||
3299 |
bool os::find(address addr, outputStream* st) { |
|
3300 |
Dl_info dlinfo; |
|
3301 |
memset(&dlinfo, 0, sizeof(dlinfo)); |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3302 |
if (dladdr(addr, &dlinfo) != 0) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
3303 |
st->print(INTPTR_FORMAT ": ", (intptr_t)addr); |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3304 |
if (dlinfo.dli_sname != NULL && dlinfo.dli_saddr != NULL) { |
10565 | 3305 |
st->print("%s+%#x", dlinfo.dli_sname, |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
3306 |
(uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_saddr)); |
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3307 |
} else if (dlinfo.dli_fbase != NULL) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
3308 |
st->print("<offset %#x>", (uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_fbase)); |
10565 | 3309 |
} else { |
3310 |
st->print("<absolute address>"); |
|
3311 |
} |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3312 |
if (dlinfo.dli_fname != NULL) { |
10565 | 3313 |
st->print(" in %s", dlinfo.dli_fname); |
3314 |
} |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3315 |
if (dlinfo.dli_fbase != NULL) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
3316 |
st->print(" at " INTPTR_FORMAT, (intptr_t)dlinfo.dli_fbase); |
10565 | 3317 |
} |
3318 |
st->cr(); |
|
3319 |
||
3320 |
if (Verbose) { |
|
3321 |
// decode some bytes around the PC |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16669
diff
changeset
|
3322 |
address begin = clamp_address_in_page(addr-40, addr, os::vm_page_size()); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16669
diff
changeset
|
3323 |
address end = clamp_address_in_page(addr+40, addr, os::vm_page_size()); |
10565 | 3324 |
address lowest = (address) dlinfo.dli_sname; |
3325 |
if (!lowest) lowest = (address) dlinfo.dli_fbase; |
|
3326 |
if (begin < lowest) begin = lowest; |
|
3327 |
Dl_info dlinfo2; |
|
18683
a6418e038255
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
18086
diff
changeset
|
3328 |
if (dladdr(end, &dlinfo2) != 0 && dlinfo2.dli_saddr != dlinfo.dli_saddr |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3329 |
&& end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin) { |
10565 | 3330 |
end = (address) dlinfo2.dli_saddr; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3331 |
} |
10565 | 3332 |
Disassembler::decode(begin, end, st); |
3333 |
} |
|
3334 |
return true; |
|
3335 |
} |
|
3336 |
return false; |
|
3337 |
} |
|
3338 |
||
3339 |
//////////////////////////////////////////////////////////////////////////////// |
|
3340 |
// misc |
|
3341 |
||
3342 |
// This does not do anything on Bsd. This is basically a hook for being |
|
3343 |
// able to use structured exception handling (thread-local exception filters) |
|
3344 |
// on, e.g., Win32. |
|
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3345 |
void os::os_exception_wrapper(java_call_t f, JavaValue* value, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
3346 |
const methodHandle& method, JavaCallArguments* args, |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3347 |
Thread* thread) { |
10565 | 3348 |
f(value, method, args, thread); |
3349 |
} |
|
3350 |
||
3351 |
void os::print_statistics() { |
|
3352 |
} |
|
3353 |
||
34305
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3354 |
bool os::message_box(const char* title, const char* message) { |
10565 | 3355 |
int i; |
3356 |
fdStream err(defaultStream::error_fd()); |
|
3357 |
for (i = 0; i < 78; i++) err.print_raw("="); |
|
3358 |
err.cr(); |
|
3359 |
err.print_raw_cr(title); |
|
3360 |
for (i = 0; i < 78; i++) err.print_raw("-"); |
|
3361 |
err.cr(); |
|
3362 |
err.print_raw_cr(message); |
|
3363 |
for (i = 0; i < 78; i++) err.print_raw("="); |
|
3364 |
err.cr(); |
|
3365 |
||
3366 |
char buf[16]; |
|
3367 |
// Prevent process from exiting upon "read error" without consuming all CPU |
|
3368 |
while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); } |
|
3369 |
||
3370 |
return buf[0] == 'y' || buf[0] == 'Y'; |
|
3371 |
} |
|
3372 |
||
37465
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3373 |
static inline struct timespec get_mtime(const char* filename) { |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3374 |
struct stat st; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3375 |
int ret = os::stat(filename, &st); |
52892 | 3376 |
assert(ret == 0, "failed to stat() file '%s': %s", filename, os::strerror(errno)); |
37465
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3377 |
#ifdef __APPLE__ |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3378 |
return st.st_mtimespec; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3379 |
#else |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3380 |
return st.st_mtim; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3381 |
#endif |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3382 |
} |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3383 |
|
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3384 |
int os::compare_file_modified_times(const char* file1, const char* file2) { |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3385 |
struct timespec filetime1 = get_mtime(file1); |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3386 |
struct timespec filetime2 = get_mtime(file2); |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3387 |
int diff = filetime1.tv_sec - filetime2.tv_sec; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3388 |
if (diff == 0) { |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3389 |
return filetime1.tv_nsec - filetime2.tv_nsec; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3390 |
} |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3391 |
return diff; |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3392 |
} |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37430
diff
changeset
|
3393 |
|
10565 | 3394 |
// Is a (classpath) directory empty? |
3395 |
bool os::dir_is_empty(const char* path) { |
|
3396 |
DIR *dir = NULL; |
|
3397 |
struct dirent *ptr; |
|
3398 |
||
3399 |
dir = opendir(path); |
|
3400 |
if (dir == NULL) return true; |
|
3401 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3402 |
// Scan the directory |
10565 | 3403 |
bool result = true; |
51106
f605c91e5219
8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents:
50962
diff
changeset
|
3404 |
while (result && (ptr = readdir(dir)) != NULL) { |
10565 | 3405 |
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { |
3406 |
result = false; |
|
3407 |
} |
|
3408 |
} |
|
3409 |
closedir(dir); |
|
3410 |
return result; |
|
3411 |
} |
|
3412 |
||
3413 |
// This code originates from JDK's sysOpen and open64_w |
|
3414 |
// from src/solaris/hpi/src/system_md.c |
|
3415 |
||
3416 |
int os::open(const char *path, int oflag, int mode) { |
|
3417 |
if (strlen(path) > MAX_PATH - 1) { |
|
3418 |
errno = ENAMETOOLONG; |
|
3419 |
return -1; |
|
3420 |
} |
|
3421 |
int fd; |
|
3422 |
||
3423 |
fd = ::open(path, oflag, mode); |
|
3424 |
if (fd == -1) return -1; |
|
3425 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3426 |
// If the open succeeded, the file might still be a directory |
10565 | 3427 |
{ |
3428 |
struct stat buf; |
|
3429 |
int ret = ::fstat(fd, &buf); |
|
3430 |
int st_mode = buf.st_mode; |
|
3431 |
||
3432 |
if (ret != -1) { |
|
3433 |
if ((st_mode & S_IFMT) == S_IFDIR) { |
|
3434 |
errno = EISDIR; |
|
3435 |
::close(fd); |
|
3436 |
return -1; |
|
3437 |
} |
|
3438 |
} else { |
|
3439 |
::close(fd); |
|
3440 |
return -1; |
|
3441 |
} |
|
3442 |
} |
|
3443 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3444 |
// All file descriptors that are opened in the JVM and not |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3445 |
// specifically destined for a subprocess should have the |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3446 |
// close-on-exec flag set. If we don't set it, then careless 3rd |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3447 |
// party native code might fork and exec without closing all |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3448 |
// appropriate file descriptors (e.g. as we do in closeDescriptors in |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3449 |
// UNIXProcess.c), and this in turn might: |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3450 |
// |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3451 |
// - cause end-of-file to fail to be detected on some file |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3452 |
// descriptors, resulting in mysterious hangs, or |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3453 |
// |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3454 |
// - might cause an fopen in the subprocess to fail on a system |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3455 |
// suffering from bug 1085341. |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3456 |
// |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3457 |
// (Yes, the default setting of the close-on-exec flag is a Unix |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3458 |
// design flaw) |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3459 |
// |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3460 |
// See: |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3461 |
// 1085341: 32-bit stdio routines should support file descriptors >255 |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3462 |
// 4843136: (process) pipe file descriptor from Runtime.exec not being closed |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3463 |
// 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9 |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3464 |
// |
10565 | 3465 |
#ifdef FD_CLOEXEC |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3466 |
{ |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3467 |
int flags = ::fcntl(fd, F_GETFD); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3468 |
if (flags != -1) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3469 |
::fcntl(fd, F_SETFD, flags | FD_CLOEXEC); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3470 |
} |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3471 |
} |
10565 | 3472 |
#endif |
3473 |
||
3474 |
return fd; |
|
3475 |
} |
|
3476 |
||
3477 |
||
3478 |
// create binary file, rewriting existing file if required |
|
3479 |
int os::create_binary_file(const char* path, bool rewrite_existing) { |
|
3480 |
int oflags = O_WRONLY | O_CREAT; |
|
3481 |
if (!rewrite_existing) { |
|
3482 |
oflags |= O_EXCL; |
|
3483 |
} |
|
3484 |
return ::open(path, oflags, S_IREAD | S_IWRITE); |
|
3485 |
} |
|
3486 |
||
3487 |
// return current position of file pointer |
|
3488 |
jlong os::current_file_offset(int fd) { |
|
3489 |
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); |
|
3490 |
} |
|
3491 |
||
3492 |
// move file pointer to the specified offset |
|
3493 |
jlong os::seek_to_file_offset(int fd, jlong offset) { |
|
3494 |
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); |
|
3495 |
} |
|
3496 |
||
3497 |
// This code originates from JDK's sysAvailable |
|
3498 |
// from src/solaris/hpi/src/native_threads/src/sys_api_td.c |
|
3499 |
||
3500 |
int os::available(int fd, jlong *bytes) { |
|
3501 |
jlong cur, end; |
|
3502 |
int mode; |
|
3503 |
struct stat buf; |
|
3504 |
||
3505 |
if (::fstat(fd, &buf) >= 0) { |
|
3506 |
mode = buf.st_mode; |
|
3507 |
if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { |
|
3508 |
int n; |
|
3509 |
if (::ioctl(fd, FIONREAD, &n) >= 0) { |
|
3510 |
*bytes = n; |
|
3511 |
return 1; |
|
3512 |
} |
|
3513 |
} |
|
3514 |
} |
|
3515 |
if ((cur = ::lseek(fd, 0L, SEEK_CUR)) == -1) { |
|
3516 |
return 0; |
|
3517 |
} else if ((end = ::lseek(fd, 0L, SEEK_END)) == -1) { |
|
3518 |
return 0; |
|
3519 |
} else if (::lseek(fd, cur, SEEK_SET) == -1) { |
|
3520 |
return 0; |
|
3521 |
} |
|
3522 |
*bytes = end - cur; |
|
3523 |
return 1; |
|
3524 |
} |
|
3525 |
||
3526 |
// Map a block of memory. |
|
13195 | 3527 |
char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3528 |
char *addr, size_t bytes, bool read_only, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3529 |
bool allow_exec) { |
10565 | 3530 |
int prot; |
3531 |
int flags; |
|
3532 |
||
3533 |
if (read_only) { |
|
3534 |
prot = PROT_READ; |
|
3535 |
flags = MAP_SHARED; |
|
3536 |
} else { |
|
3537 |
prot = PROT_READ | PROT_WRITE; |
|
3538 |
flags = MAP_PRIVATE; |
|
3539 |
} |
|
3540 |
||
3541 |
if (allow_exec) { |
|
3542 |
prot |= PROT_EXEC; |
|
3543 |
} |
|
3544 |
||
3545 |
if (addr != NULL) { |
|
3546 |
flags |= MAP_FIXED; |
|
3547 |
} |
|
3548 |
||
3549 |
char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags, |
|
3550 |
fd, file_offset); |
|
3551 |
if (mapped_address == MAP_FAILED) { |
|
3552 |
return NULL; |
|
3553 |
} |
|
3554 |
return mapped_address; |
|
3555 |
} |
|
3556 |
||
3557 |
||
3558 |
// Remap a block of memory. |
|
13195 | 3559 |
char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset, |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3560 |
char *addr, size_t bytes, bool read_only, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3561 |
bool allow_exec) { |
10565 | 3562 |
// same as map_memory() on this OS |
3563 |
return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only, |
|
3564 |
allow_exec); |
|
3565 |
} |
|
3566 |
||
3567 |
||
3568 |
// Unmap a block of memory. |
|
13195 | 3569 |
bool os::pd_unmap_memory(char* addr, size_t bytes) { |
10565 | 3570 |
return munmap(addr, bytes) == 0; |
3571 |
} |
|
3572 |
||
3573 |
// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) |
|
3574 |
// are used by JVM M&M and JVMTI to get user+sys or user CPU time |
|
3575 |
// of a thread. |
|
3576 |
// |
|
3577 |
// current_thread_cpu_time() and thread_cpu_time(Thread*) returns |
|
3578 |
// the fast estimate available on the platform. |
|
3579 |
||
3580 |
jlong os::current_thread_cpu_time() { |
|
3581 |
#ifdef __APPLE__ |
|
3582 |
return os::thread_cpu_time(Thread::current(), true /* user + sys */); |
|
15869
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3583 |
#else |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3584 |
Unimplemented(); |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3585 |
return 0; |
10565 | 3586 |
#endif |
3587 |
} |
|
3588 |
||
3589 |
jlong os::thread_cpu_time(Thread* thread) { |
|
15869
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3590 |
#ifdef __APPLE__ |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3591 |
return os::thread_cpu_time(thread, true /* user + sys */); |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3592 |
#else |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3593 |
Unimplemented(); |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3594 |
return 0; |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3595 |
#endif |
10565 | 3596 |
} |
3597 |
||
3598 |
jlong os::current_thread_cpu_time(bool user_sys_cpu_time) { |
|
3599 |
#ifdef __APPLE__ |
|
3600 |
return os::thread_cpu_time(Thread::current(), user_sys_cpu_time); |
|
15869
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3601 |
#else |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3602 |
Unimplemented(); |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3603 |
return 0; |
10565 | 3604 |
#endif |
3605 |
} |
|
3606 |
||
3607 |
jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { |
|
3608 |
#ifdef __APPLE__ |
|
3609 |
struct thread_basic_info tinfo; |
|
3610 |
mach_msg_type_number_t tcount = THREAD_INFO_MAX; |
|
3611 |
kern_return_t kr; |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
3612 |
thread_t mach_thread; |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
3613 |
|
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
11880
diff
changeset
|
3614 |
mach_thread = thread->osthread()->thread_id(); |
10565 | 3615 |
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount); |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3616 |
if (kr != KERN_SUCCESS) { |
10565 | 3617 |
return -1; |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3618 |
} |
10565 | 3619 |
|
3620 |
if (user_sys_cpu_time) { |
|
3621 |
jlong nanos; |
|
3622 |
nanos = ((jlong) tinfo.system_time.seconds + tinfo.user_time.seconds) * (jlong)1000000000; |
|
3623 |
nanos += ((jlong) tinfo.system_time.microseconds + (jlong) tinfo.user_time.microseconds) * (jlong)1000; |
|
3624 |
return nanos; |
|
3625 |
} else { |
|
3626 |
return ((jlong)tinfo.user_time.seconds * 1000000000) + ((jlong)tinfo.user_time.microseconds * (jlong)1000); |
|
3627 |
} |
|
15869
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3628 |
#else |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3629 |
Unimplemented(); |
6336b792f928
8008559: [parfait] Path through non-void function '_ZN2os15thread_cpu_timeEP6Thread' returns an undefined value
morris
parents:
15743
diff
changeset
|
3630 |
return 0; |
10565 | 3631 |
#endif |
3632 |
} |
|
3633 |
||
3634 |
||
3635 |
void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { |
|
3636 |
info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits |
|
3637 |
info_ptr->may_skip_backward = false; // elapsed time not wall time |
|
3638 |
info_ptr->may_skip_forward = false; // elapsed time not wall time |
|
3639 |
info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned |
|
3640 |
} |
|
3641 |
||
3642 |
void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { |
|
3643 |
info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits |
|
3644 |
info_ptr->may_skip_backward = false; // elapsed time not wall time |
|
3645 |
info_ptr->may_skip_forward = false; // elapsed time not wall time |
|
3646 |
info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned |
|
3647 |
} |
|
3648 |
||
3649 |
bool os::is_thread_cpu_time_supported() { |
|
3650 |
#ifdef __APPLE__ |
|
3651 |
return true; |
|
14286 | 3652 |
#else |
10565 | 3653 |
return false; |
3654 |
#endif |
|
3655 |
} |
|
3656 |
||
3657 |
// System loadavg support. Returns -1 if load average cannot be obtained. |
|
3658 |
// Bsd doesn't yet have a (official) notion of processor sets, |
|
3659 |
// so just return the system wide load average. |
|
3660 |
int os::loadavg(double loadavg[], int nelem) { |
|
3661 |
return ::getloadavg(loadavg, nelem); |
|
3662 |
} |
|
3663 |
||
3664 |
void os::pause() { |
|
3665 |
char filename[MAX_PATH]; |
|
3666 |
if (PauseAtStartupFile && PauseAtStartupFile[0]) { |
|
58548
430b9a492a05
8232052: use string literal for format string when handling PauseAtStartupFile
mbaesken
parents:
58280
diff
changeset
|
3667 |
jio_snprintf(filename, MAX_PATH, "%s", PauseAtStartupFile); |
10565 | 3668 |
} else { |
3669 |
jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id()); |
|
3670 |
} |
|
3671 |
||
3672 |
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
|
3673 |
if (fd != -1) { |
|
3674 |
struct stat buf; |
|
3675 |
::close(fd); |
|
3676 |
while (::stat(filename, &buf) == 0) { |
|
3677 |
(void)::poll(NULL, 0, 100); |
|
3678 |
} |
|
3679 |
} else { |
|
3680 |
jio_fprintf(stderr, |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3681 |
"Could not open pause file '%s', continuing immediately.\n", filename); |
10565 | 3682 |
} |
3683 |
} |
|
3684 |
||
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3685 |
// Darwin has no "environ" in a dynamic library. |
10565 | 3686 |
#ifdef __APPLE__ |
26684
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3687 |
#include <crt_externs.h> |
d1221849ea3d
8057109: manual cleanup of white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
26683
diff
changeset
|
3688 |
#define environ (*_NSGetEnviron()) |
10565 | 3689 |
#else |
3690 |
extern char** environ; |
|
3691 |
#endif |
|
3692 |
||
3693 |
// Run the specified command in a separate process. Return its exit value, |
|
3694 |
// or -1 on failure (e.g. can't fork a new process). |
|
3695 |
// Unlike system(), this function can be called from signal handler. It |
|
3696 |
// doesn't block SIGINT et al. |
|
52109
101c2b6eacbe
8027434: "-XX:OnOutOfMemoryError" uses fork instead of vfork
mchinnathamb
parents:
52026
diff
changeset
|
3697 |
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) { |
10565 | 3698 |
const char * argv[4] = {"sh", "-c", cmd, NULL}; |
3699 |
||
3700 |
// fork() in BsdThreads/NPTL is not async-safe. It needs to run |
|
3701 |
// pthread_atfork handlers and reset pthread library. All we need is a |
|
3702 |
// separate process to execve. Make a direct syscall to fork process. |
|
3703 |
// On IA64 there's no fork syscall, we have to use fork() and hope for |
|
3704 |
// the best... |
|
3705 |
pid_t pid = fork(); |
|
3706 |
||
3707 |
if (pid < 0) { |
|
3708 |
// fork failed |
|
3709 |
return -1; |
|
3710 |
||
3711 |
} else if (pid == 0) { |
|
3712 |
// child process |
|
3713 |
||
3714 |
// execve() in BsdThreads will call pthread_kill_other_threads_np() |
|
3715 |
// first to kill every thread on the thread list. Because this list is |
|
3716 |
// not reset by fork() (see notes above), execve() will instead kill |
|
3717 |
// every thread in the parent process. We know this is the only thread |
|
3718 |
// in the new process, so make a system call directly. |
|
3719 |
// IA64 should use normal execve() from glibc to match the glibc fork() |
|
3720 |
// above. |
|
3721 |
execve("/bin/sh", (char* const*)argv, environ); |
|
3722 |
||
3723 |
// execve failed |
|
3724 |
_exit(-1); |
|
3725 |
||
3726 |
} else { |
|
3727 |
// copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't |
|
3728 |
// care about the actual exit code, for now. |
|
3729 |
||
3730 |
int status; |
|
3731 |
||
3732 |
// Wait for the child process to exit. This returns immediately if |
|
3733 |
// the child has already exited. */ |
|
3734 |
while (waitpid(pid, &status, 0) < 0) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3735 |
switch (errno) { |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3736 |
case ECHILD: return 0; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3737 |
case EINTR: break; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3738 |
default: return -1; |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3739 |
} |
10565 | 3740 |
} |
3741 |
||
3742 |
if (WIFEXITED(status)) { |
|
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3743 |
// The child exited normally; get its exit code. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3744 |
return WEXITSTATUS(status); |
10565 | 3745 |
} else if (WIFSIGNALED(status)) { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3746 |
// The child exited because of a signal |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3747 |
// The best value to return is 0x80 + signal number, |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3748 |
// because that is what all Unix shells do, and because |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3749 |
// it allows callers to distinguish between process exit and |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3750 |
// process death by signal. |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3751 |
return 0x80 + WTERMSIG(status); |
10565 | 3752 |
} else { |
26683
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3753 |
// Unknown exit code; pass it through |
a02753d5a0b2
8057107: cleanup indent white space issues prior to Contended Locking reorder and cache line bucket
dcubed
parents:
25946
diff
changeset
|
3754 |
return status; |
10565 | 3755 |
} |
3756 |
} |
|
3757 |
} |
|
3758 |
||
13198
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3759 |
// Get the default path to the core file |
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3760 |
// Returns the length of the string |
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3761 |
int os::get_core_path(char* buffer, size_t bufferSize) { |
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
27926
diff
changeset
|
3762 |
int n = jio_snprintf(buffer, bufferSize, "/cores/core.%d", current_process_id()); |
13198
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3763 |
|
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3764 |
// Truncate if theoretical string was longer than bufferSize |
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3765 |
n = MIN2(n, (int)bufferSize); |
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3766 |
|
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3767 |
return n; |
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
3768 |
} |
18025 | 3769 |
|
57804 | 3770 |
bool os::supports_map_sync() { |
3771 |
return false; |
|
3772 |
} |
|
3773 |
||
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
3774 |
#ifndef PRODUCT |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
3775 |
void TestReserveMemorySpecial_test() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
3776 |
// No tests available for this platform |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
3777 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19532
diff
changeset
|
3778 |
#endif |
34305
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3779 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3780 |
bool os::start_debugging(char *buf, int buflen) { |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3781 |
int len = (int)strlen(buf); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3782 |
char *p = &buf[len]; |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3783 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3784 |
jio_snprintf(p, buflen-len, |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3785 |
"\n\n" |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3786 |
"Do you want to debug the problem?\n\n" |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3787 |
"To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " INTX_FORMAT " (" INTPTR_FORMAT ")\n" |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3788 |
"Enter 'yes' to launch gdb automatically (PATH must include gdb)\n" |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3789 |
"Otherwise, press RETURN to abort...", |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3790 |
os::current_process_id(), os::current_process_id(), |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3791 |
os::current_thread_id(), os::current_thread_id()); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3792 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3793 |
bool yes = os::message_box("Unexpected Error", buf); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3794 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3795 |
if (yes) { |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3796 |
// yes, user asked VM to launch debugger |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3797 |
jio_snprintf(buf, sizeof(buf), "gdb /proc/%d/exe %d", |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3798 |
os::current_process_id(), os::current_process_id()); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3799 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3800 |
os::fork_and_exec(buf); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3801 |
yes = false; |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3802 |
} |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3803 |
return yes; |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34145
diff
changeset
|
3804 |
} |