author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 58481 | 48a73ec3a817 |
child 58679 | 9c3209ff7550 |
child 58927 | d8aced36e872 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53402 | 2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
26 |
#include "jvm.h" |
7397 | 27 |
#include "classfile/classLoader.hpp" |
28 |
#include "classfile/javaClasses.hpp" |
|
43451
7706e5ac9f32
8170827: Correct errant "java.base" string to macro
rprotacio
parents:
42066
diff
changeset
|
29 |
#include "classfile/moduleEntry.hpp" |
7397 | 30 |
#include "classfile/systemDictionary.hpp" |
31 |
#include "classfile/vmSymbols.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
25469
diff
changeset
|
32 |
#include "code/codeCache.hpp" |
7397 | 33 |
#include "code/icBuffer.hpp" |
34 |
#include "code/vtableStubs.hpp" |
|
52876
2d17750d41e7
8214791: Consistently name gc files containing VM operations
tschatzl
parents:
52581
diff
changeset
|
35 |
#include "gc/shared/gcVMOperations.hpp" |
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
36 |
#include "logging/log.hpp" |
7397 | 37 |
#include "interpreter/interpreter.hpp" |
33763
cec2333f839c
8140348: Convert TraceSafepoint to Unified Logging
rprotacio
parents:
33604
diff
changeset
|
38 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46644
diff
changeset
|
39 |
#include "logging/logStream.hpp" |
7397 | 40 |
#include "memory/allocation.inline.hpp" |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
41 |
#include "memory/guardedMemory.hpp" |
37248 | 42 |
#include "memory/resourceArea.hpp" |
54786 | 43 |
#include "memory/universe.hpp" |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
44 |
#include "oops/compressedOops.inline.hpp" |
7397 | 45 |
#include "oops/oop.inline.hpp" |
46 |
#include "prims/jvm_misc.hpp" |
|
47 |
#include "runtime/arguments.hpp" |
|
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
40013
diff
changeset
|
48 |
#include "runtime/atomic.hpp" |
7397 | 49 |
#include "runtime/frame.inline.hpp" |
53582 | 50 |
#include "runtime/handles.inline.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49349
diff
changeset
|
51 |
#include "runtime/interfaceSupport.inline.hpp" |
7397 | 52 |
#include "runtime/java.hpp" |
53 |
#include "runtime/javaCalls.hpp" |
|
54 |
#include "runtime/mutexLocker.hpp" |
|
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
25355
diff
changeset
|
55 |
#include "runtime/os.inline.hpp" |
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
49449
diff
changeset
|
56 |
#include "runtime/sharedRuntime.hpp" |
7397 | 57 |
#include "runtime/stubRoutines.hpp" |
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14490
diff
changeset
|
58 |
#include "runtime/thread.inline.hpp" |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
47765
diff
changeset
|
59 |
#include "runtime/threadSMR.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
25469
diff
changeset
|
60 |
#include "runtime/vm_version.hpp" |
7397 | 61 |
#include "services/attachListener.hpp" |
26561
e104c9397ca1
8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
25962
diff
changeset
|
62 |
#include "services/mallocTracker.hpp" |
13195 | 63 |
#include "services/memTracker.hpp" |
30764 | 64 |
#include "services/nmtCommon.hpp" |
7397 | 65 |
#include "services/threadService.hpp" |
46625 | 66 |
#include "utilities/align.hpp" |
7397 | 67 |
#include "utilities/defaultStream.hpp" |
68 |
#include "utilities/events.hpp" |
|
1 | 69 |
|
70 |
# include <signal.h> |
|
37113 | 71 |
# include <errno.h> |
1 | 72 |
|
73 |
OSThread* os::_starting_thread = NULL; |
|
74 |
address os::_polling_page = NULL; |
|
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
75 |
volatile unsigned int os::_rand_seed = 1; |
1 | 76 |
int os::_processor_count = 0; |
40011 | 77 |
int os::_initial_active_processor_count = 0; |
1 | 78 |
size_t os::_page_sizes[os::page_sizes_max]; |
79 |
||
80 |
#ifndef PRODUCT |
|
8320 | 81 |
julong os::num_mallocs = 0; // # of calls to malloc/realloc |
82 |
julong os::alloc_bytes = 0; // # of bytes allocated |
|
83 |
julong os::num_frees = 0; // # of calls to free |
|
84 |
julong os::free_bytes = 0; // # of bytes freed |
|
1 | 85 |
#endif |
86 |
||
48955
e22914003cf0
8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents:
48865
diff
changeset
|
87 |
static size_t cur_malloc_words = 0; // current size for MallocMaxTestWords |
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
88 |
|
52581
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52460
diff
changeset
|
89 |
DEBUG_ONLY(bool os::_mutex_init_done = false;) |
d402a406bbc3
8213723: More Monitor/mutex initialization management
dholmes
parents:
52460
diff
changeset
|
90 |
|
49042
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
91 |
static time_t get_timezone(const struct tm* time_struct) { |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
92 |
#if defined(_ALLBSD_SOURCE) |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
93 |
return time_struct->tm_gmtoff; |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
94 |
#elif defined(_WINDOWS) |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
95 |
long zone; |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
96 |
_get_timezone(&zone); |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
97 |
return static_cast<time_t>(zone); |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
98 |
#else |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
99 |
return timezone; |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
100 |
#endif |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
101 |
} |
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
102 |
|
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
103 |
int os::snprintf(char* buf, size_t len, const char* fmt, ...) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
104 |
va_list args; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
105 |
va_start(args, fmt); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
106 |
int result = os::vsnprintf(buf, len, fmt, args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
107 |
va_end(args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
108 |
return result; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
109 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
49042
diff
changeset
|
110 |
|
1 | 111 |
// Fill in buffer with current local time as an ISO-8601 string. |
112 |
// E.g., yyyy-mm-ddThh:mm:ss-zzzz. |
|
113 |
// Returns buffer, or NULL if it failed. |
|
114 |
// This would mostly be a call to |
|
115 |
// strftime(...., "%Y-%m-%d" "T" "%H:%M:%S" "%z", ....) |
|
116 |
// except that on Windows the %z behaves badly, so we do it ourselves. |
|
117 |
// Also, people wanted milliseconds on there, |
|
118 |
// and strftime doesn't do milliseconds. |
|
42066 | 119 |
char* os::iso8601_time(char* buffer, size_t buffer_length, bool utc) { |
1 | 120 |
// Output will be of the form "YYYY-MM-DDThh:mm:ss.mmm+zzzz\0" |
121 |
// 1 2 |
|
122 |
// 12345678901234567890123456789 |
|
33604
ad1cd9269bd4
8139116: Fixes for warning "format not a string literal"
goetz
parents:
33593
diff
changeset
|
123 |
// format string: "%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d%02d" |
1 | 124 |
static const size_t needed_buffer = 29; |
125 |
||
126 |
// Sanity check the arguments |
|
127 |
if (buffer == NULL) { |
|
128 |
assert(false, "NULL buffer"); |
|
129 |
return NULL; |
|
130 |
} |
|
131 |
if (buffer_length < needed_buffer) { |
|
132 |
assert(false, "buffer_length too small"); |
|
133 |
return NULL; |
|
134 |
} |
|
135 |
// Get the current time |
|
234 | 136 |
jlong milliseconds_since_19700101 = javaTimeMillis(); |
1 | 137 |
const int milliseconds_per_microsecond = 1000; |
138 |
const time_t seconds_since_19700101 = |
|
139 |
milliseconds_since_19700101 / milliseconds_per_microsecond; |
|
140 |
const int milliseconds_after_second = |
|
141 |
milliseconds_since_19700101 % milliseconds_per_microsecond; |
|
142 |
// Convert the time value to a tm and timezone variable |
|
2012
041fbc6030dd
6800586: -XX:+PrintGCDateStamps is using mt-unsafe localtime function
ysr
parents:
1664
diff
changeset
|
143 |
struct tm time_struct; |
42066 | 144 |
if (utc) { |
145 |
if (gmtime_pd(&seconds_since_19700101, &time_struct) == NULL) { |
|
146 |
assert(false, "Failed gmtime_pd"); |
|
147 |
return NULL; |
|
148 |
} |
|
149 |
} else { |
|
150 |
if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) { |
|
151 |
assert(false, "Failed localtime_pd"); |
|
152 |
return NULL; |
|
153 |
} |
|
1 | 154 |
} |
49042
a04a9bee2431
8197868: VS2017 (C2065) 'timezone': Undeclared Identifier in share/runtime/os.cpp
lfoltan
parents:
49034
diff
changeset
|
155 |
const time_t zone = get_timezone(&time_struct); |
1 | 156 |
|
157 |
// If daylight savings time is in effect, |
|
158 |
// we are 1 hour East of our time zone |
|
159 |
const time_t seconds_per_minute = 60; |
|
160 |
const time_t minutes_per_hour = 60; |
|
161 |
const time_t seconds_per_hour = seconds_per_minute * minutes_per_hour; |
|
162 |
time_t UTC_to_local = zone; |
|
163 |
if (time_struct.tm_isdst > 0) { |
|
164 |
UTC_to_local = UTC_to_local - seconds_per_hour; |
|
165 |
} |
|
42066 | 166 |
|
167 |
// No offset when dealing with UTC |
|
168 |
if (utc) { |
|
169 |
UTC_to_local = 0; |
|
170 |
} |
|
171 |
||
1 | 172 |
// Compute the time zone offset. |
2012
041fbc6030dd
6800586: -XX:+PrintGCDateStamps is using mt-unsafe localtime function
ysr
parents:
1664
diff
changeset
|
173 |
// localtime_pd() sets timezone to the difference (in seconds) |
1 | 174 |
// between UTC and and local time. |
175 |
// ISO 8601 says we need the difference between local time and UTC, |
|
2012
041fbc6030dd
6800586: -XX:+PrintGCDateStamps is using mt-unsafe localtime function
ysr
parents:
1664
diff
changeset
|
176 |
// we change the sign of the localtime_pd() result. |
1 | 177 |
const time_t local_to_UTC = -(UTC_to_local); |
178 |
// Then we have to figure out if if we are ahead (+) or behind (-) UTC. |
|
179 |
char sign_local_to_UTC = '+'; |
|
180 |
time_t abs_local_to_UTC = local_to_UTC; |
|
181 |
if (local_to_UTC < 0) { |
|
182 |
sign_local_to_UTC = '-'; |
|
183 |
abs_local_to_UTC = -(abs_local_to_UTC); |
|
184 |
} |
|
185 |
// Convert time zone offset seconds to hours and minutes. |
|
186 |
const time_t zone_hours = (abs_local_to_UTC / seconds_per_hour); |
|
187 |
const time_t zone_min = |
|
188 |
((abs_local_to_UTC % seconds_per_hour) / seconds_per_minute); |
|
189 |
||
190 |
// Print an ISO 8601 date and time stamp into the buffer |
|
191 |
const int year = 1900 + time_struct.tm_year; |
|
192 |
const int month = 1 + time_struct.tm_mon; |
|
33604
ad1cd9269bd4
8139116: Fixes for warning "format not a string literal"
goetz
parents:
33593
diff
changeset
|
193 |
const int printed = jio_snprintf(buffer, buffer_length, |
ad1cd9269bd4
8139116: Fixes for warning "format not a string literal"
goetz
parents:
33593
diff
changeset
|
194 |
"%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d%02d", |
1 | 195 |
year, |
196 |
month, |
|
197 |
time_struct.tm_mday, |
|
198 |
time_struct.tm_hour, |
|
199 |
time_struct.tm_min, |
|
200 |
time_struct.tm_sec, |
|
201 |
milliseconds_after_second, |
|
202 |
sign_local_to_UTC, |
|
203 |
zone_hours, |
|
204 |
zone_min); |
|
205 |
if (printed == 0) { |
|
206 |
assert(false, "Failed jio_printf"); |
|
207 |
return NULL; |
|
208 |
} |
|
209 |
return buffer; |
|
210 |
} |
|
211 |
||
212 |
OSReturn os::set_priority(Thread* thread, ThreadPriority p) { |
|
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
47765
diff
changeset
|
213 |
debug_only(Thread::check_for_dangling_thread_pointer(thread);) |
1 | 214 |
|
53402 | 215 |
if ((p >= MinPriority && p <= MaxPriority) || |
216 |
(p == CriticalPriority && thread->is_ConcurrentGC_thread())) { |
|
1 | 217 |
int priority = java_to_os_priority[p]; |
218 |
return set_native_priority(thread, priority); |
|
219 |
} else { |
|
220 |
assert(false, "Should not happen"); |
|
221 |
return OS_ERR; |
|
222 |
} |
|
223 |
} |
|
224 |
||
13857 | 225 |
// The mapping from OS priority back to Java priority may be inexact because |
226 |
// Java priorities can map M:1 with native priorities. If you want the definite |
|
227 |
// Java priority then use JavaThread::java_priority() |
|
1 | 228 |
OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) { |
229 |
int p; |
|
230 |
int os_prio; |
|
231 |
OSReturn ret = get_native_priority(thread, &os_prio); |
|
232 |
if (ret != OS_OK) return ret; |
|
233 |
||
13857 | 234 |
if (java_to_os_priority[MaxPriority] > java_to_os_priority[MinPriority]) { |
235 |
for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ; |
|
236 |
} else { |
|
237 |
// niceness values are in reverse order |
|
238 |
for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] < os_prio; p--) ; |
|
239 |
} |
|
1 | 240 |
priority = (ThreadPriority)p; |
241 |
return OS_OK; |
|
242 |
} |
|
243 |
||
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
244 |
bool os::dll_build_name(char* buffer, size_t size, const char* fname) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
245 |
int n = jio_snprintf(buffer, size, "%s%s%s", JNI_LIB_PREFIX, fname, JNI_LIB_SUFFIX); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
246 |
return (n != -1); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
247 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
248 |
|
49968 | 249 |
#if !defined(LINUX) && !defined(_WINDOWS) |
250 |
bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) { |
|
251 |
committed_start = start; |
|
252 |
committed_size = size; |
|
253 |
return true; |
|
254 |
} |
|
255 |
#endif |
|
256 |
||
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
257 |
// Helper for dll_locate_lib. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
258 |
// Pass buffer and printbuffer as we already printed the path to buffer |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
259 |
// when we called get_current_directory. This way we avoid another buffer |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
260 |
// of size MAX_PATH. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
261 |
static bool conc_path_file_and_check(char *buffer, char *printbuffer, size_t printbuflen, |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
262 |
const char* pname, char lastchar, const char* fname) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
263 |
|
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
264 |
// Concatenate path and file name, but don't print double path separators. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
265 |
const char *filesep = (WINDOWS_ONLY(lastchar == ':' ||) lastchar == os::file_separator()[0]) ? |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
266 |
"" : os::file_separator(); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
267 |
int ret = jio_snprintf(printbuffer, printbuflen, "%s%s%s", pname, filesep, fname); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
268 |
// Check whether file exists. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
269 |
if (ret != -1) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
270 |
struct stat statbuf; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
271 |
return os::stat(buffer, &statbuf) == 0; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
272 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
273 |
return false; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
274 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
275 |
|
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
276 |
// Frees all memory allocated on the heap for the |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
277 |
// supplied array of arrays of chars (a), where n |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
278 |
// is the number of elements in the array. |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
279 |
static void free_array_of_char_arrays(char** a, size_t n) { |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
280 |
while (n > 0) { |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
281 |
n--; |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
282 |
if (a[n] != NULL) { |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
283 |
FREE_C_HEAP_ARRAY(char, a[n]); |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
284 |
} |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
285 |
} |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
286 |
FREE_C_HEAP_ARRAY(char*, a); |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
287 |
} |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
288 |
|
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
289 |
bool os::dll_locate_lib(char *buffer, size_t buflen, |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
290 |
const char* pname, const char* fname) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
291 |
bool retval = false; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
292 |
|
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
293 |
size_t fullfnamelen = strlen(JNI_LIB_PREFIX) + strlen(fname) + strlen(JNI_LIB_SUFFIX); |
58083 | 294 |
char* fullfname = NEW_C_HEAP_ARRAY(char, fullfnamelen + 1, mtInternal); |
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
295 |
if (dll_build_name(fullfname, fullfnamelen + 1, fname)) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
296 |
const size_t pnamelen = pname ? strlen(pname) : 0; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
297 |
|
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
298 |
if (pnamelen == 0) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
299 |
// If no path given, use current working directory. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
300 |
const char* p = get_current_directory(buffer, buflen); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
301 |
if (p != NULL) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
302 |
const size_t plen = strlen(buffer); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
303 |
const char lastchar = buffer[plen - 1]; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
304 |
retval = conc_path_file_and_check(buffer, &buffer[plen], buflen - plen, |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
305 |
"", lastchar, fullfname); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
306 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
307 |
} else if (strchr(pname, *os::path_separator()) != NULL) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
308 |
// A list of paths. Search for the path that contains the library. |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
309 |
size_t n; |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
310 |
char** pelements = split_path(pname, &n, fullfnamelen); |
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
311 |
if (pelements != NULL) { |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
312 |
for (size_t i = 0; i < n; i++) { |
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
313 |
char* path = pelements[i]; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
314 |
// Really shouldn't be NULL, but check can't hurt. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
315 |
size_t plen = (path == NULL) ? 0 : strlen(path); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
316 |
if (plen == 0) { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
317 |
continue; // Skip the empty path values. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
318 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
319 |
const char lastchar = path[plen - 1]; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
320 |
retval = conc_path_file_and_check(buffer, buffer, buflen, path, lastchar, fullfname); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
321 |
if (retval) break; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
322 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
323 |
// Release the storage allocated by split_path. |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
324 |
free_array_of_char_arrays(pelements, n); |
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
325 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
326 |
} else { |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
327 |
// A definite path. |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
328 |
const char lastchar = pname[pnamelen-1]; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
329 |
retval = conc_path_file_and_check(buffer, buffer, buflen, pname, lastchar, fullfname); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
330 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
331 |
} |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
332 |
|
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
333 |
FREE_C_HEAP_ARRAY(char*, fullfname); |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
334 |
return retval; |
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
335 |
} |
1 | 336 |
|
337 |
// --------------------- sun.misc.Signal (optional) --------------------- |
|
338 |
||
339 |
||
340 |
// SIGBREAK is sent by the keyboard to query the VM state |
|
341 |
#ifndef SIGBREAK |
|
342 |
#define SIGBREAK SIGQUIT |
|
343 |
#endif |
|
344 |
||
345 |
// sigexitnum_pd is a platform-specific special signal used for terminating the Signal thread. |
|
346 |
||
347 |
||
348 |
static void signal_thread_entry(JavaThread* thread, TRAPS) { |
|
349 |
os::set_priority(thread, NearMaxPriority); |
|
350 |
while (true) { |
|
351 |
int sig; |
|
352 |
{ |
|
22551 | 353 |
// FIXME : Currently we have not decided what should be the status |
1 | 354 |
// for this java thread blocked here. Once we decide about |
355 |
// that we should fix this. |
|
356 |
sig = os::signal_wait(); |
|
357 |
} |
|
358 |
if (sig == os::sigexitnum_pd()) { |
|
359 |
// Terminate the signal thread |
|
360 |
return; |
|
361 |
} |
|
362 |
||
363 |
switch (sig) { |
|
364 |
case SIGBREAK: { |
|
55736
2660d47140da
8227815: Minimal VM: set_state is not a member of AttachListener
ysuenaga
parents:
55719
diff
changeset
|
365 |
#if INCLUDE_SERVICES |
1 | 366 |
// Check if the signal is a trigger to start the Attach Listener - in that |
367 |
// case don't print stack traces. |
|
55682
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
368 |
if (!DisableAttachMechanism) { |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
369 |
// Attempt to transit state to AL_INITIALIZING. |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
370 |
AttachListenerState cur_state = AttachListener::transit_state(AL_INITIALIZING, AL_NOT_INITIALIZED); |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
371 |
if (cur_state == AL_INITIALIZING) { |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
372 |
// Attach Listener has been started to initialize. Ignore this signal. |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
373 |
continue; |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
374 |
} else if (cur_state == AL_NOT_INITIALIZED) { |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
375 |
// Start to initialize. |
55719
4888ccfc234e
8227738: jvmti/DataDumpRequest/datadumpreq001 failed due to "exit code is 134"
ysuenaga
parents:
55682
diff
changeset
|
376 |
if (AttachListener::is_init_trigger()) { |
4888ccfc234e
8227738: jvmti/DataDumpRequest/datadumpreq001 failed due to "exit code is 134"
ysuenaga
parents:
55682
diff
changeset
|
377 |
// Attach Listener has been initialized. |
4888ccfc234e
8227738: jvmti/DataDumpRequest/datadumpreq001 failed due to "exit code is 134"
ysuenaga
parents:
55682
diff
changeset
|
378 |
// Accept subsequent request. |
4888ccfc234e
8227738: jvmti/DataDumpRequest/datadumpreq001 failed due to "exit code is 134"
ysuenaga
parents:
55682
diff
changeset
|
379 |
continue; |
4888ccfc234e
8227738: jvmti/DataDumpRequest/datadumpreq001 failed due to "exit code is 134"
ysuenaga
parents:
55682
diff
changeset
|
380 |
} else { |
55682
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
381 |
// Attach Listener could not be started. |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
382 |
// So we need to transit the state to AL_NOT_INITIALIZED. |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
383 |
AttachListener::set_state(AL_NOT_INITIALIZED); |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
384 |
} |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
385 |
} else if (AttachListener::check_socket_file()) { |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
386 |
// Attach Listener has been started, but unix domain socket file |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
387 |
// does not exist. So restart Attach Listener. |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
388 |
continue; |
70fab3a8ff02
8225690: Multiple AttachListener threads can be created
ysuenaga
parents:
54786
diff
changeset
|
389 |
} |
1 | 390 |
} |
55736
2660d47140da
8227815: Minimal VM: set_state is not a member of AttachListener
ysuenaga
parents:
55719
diff
changeset
|
391 |
#endif |
1 | 392 |
// Print stack traces |
393 |
// Any SIGBREAK operations added here should make sure to flush |
|
394 |
// the output stream (e.g. tty->flush()) after output. See 4803766. |
|
395 |
// Each module also prints an extra carriage return after its output. |
|
396 |
VM_PrintThreads op; |
|
397 |
VMThread::execute(&op); |
|
398 |
VM_PrintJNI jni_op; |
|
399 |
VMThread::execute(&jni_op); |
|
400 |
VM_FindDeadlocks op1(tty); |
|
401 |
VMThread::execute(&op1); |
|
402 |
Universe::print_heap_at_SIGBREAK(); |
|
403 |
if (PrintClassHistogram) { |
|
35061 | 404 |
VM_GC_HeapInspection op1(tty, true /* force full GC before heap inspection */); |
1 | 405 |
VMThread::execute(&op1); |
406 |
} |
|
407 |
if (JvmtiExport::should_post_data_dump()) { |
|
408 |
JvmtiExport::post_data_dump(); |
|
409 |
} |
|
410 |
break; |
|
411 |
} |
|
412 |
default: { |
|
413 |
// Dispatch the signal to java |
|
414 |
HandleMark hm(THREAD); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46295
diff
changeset
|
415 |
Klass* klass = SystemDictionary::resolve_or_null(vmSymbols::jdk_internal_misc_Signal(), THREAD); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46295
diff
changeset
|
416 |
if (klass != NULL) { |
1 | 417 |
JavaValue result(T_VOID); |
418 |
JavaCallArguments args; |
|
419 |
args.push_int(sig); |
|
420 |
JavaCalls::call_static( |
|
421 |
&result, |
|
422 |
klass, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
423 |
vmSymbols::dispatch_name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
424 |
vmSymbols::int_void_signature(), |
1 | 425 |
&args, |
426 |
THREAD |
|
427 |
); |
|
428 |
} |
|
429 |
if (HAS_PENDING_EXCEPTION) { |
|
430 |
// tty is initialized early so we don't expect it to be null, but |
|
431 |
// if it is we can't risk doing an initialization that might |
|
432 |
// trigger additional out-of-memory conditions |
|
433 |
if (tty != NULL) { |
|
434 |
char klass_name[256]; |
|
435 |
char tmp_sig_name[16]; |
|
436 |
const char* sig_name = "UNKNOWN"; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
437 |
InstanceKlass::cast(PENDING_EXCEPTION->klass())-> |
1 | 438 |
name()->as_klass_external_name(klass_name, 256); |
439 |
if (os::exception_name(sig, tmp_sig_name, 16) != NULL) |
|
440 |
sig_name = tmp_sig_name; |
|
441 |
warning("Exception %s occurred dispatching signal %s to handler" |
|
442 |
"- the VM may need to be forcibly terminated", |
|
443 |
klass_name, sig_name ); |
|
444 |
} |
|
445 |
CLEAR_PENDING_EXCEPTION; |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
} |
|
450 |
} |
|
451 |
||
19986
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19697
diff
changeset
|
452 |
void os::init_before_ergo() { |
40011 | 453 |
initialize_initial_active_processor_count(); |
19986
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19697
diff
changeset
|
454 |
// We need to initialize large page support here because ergonomics takes some |
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19697
diff
changeset
|
455 |
// decisions depending on large page support and the calculated large page size. |
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19697
diff
changeset
|
456 |
large_page_init(); |
35043
30543d2a0a20
8133023: ParallelGCThreads is not calculated correctly
jmasa
parents:
34633
diff
changeset
|
457 |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
458 |
// We need to adapt the configured number of stack protection pages given |
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
459 |
// in 4K pages to the actual os page size. We must do this before setting |
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
460 |
// up minimal stack sizes etc. in os::init_2(). |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46587
diff
changeset
|
461 |
JavaThread::set_stack_red_zone_size (align_up(StackRedPages * 4 * K, vm_page_size())); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46587
diff
changeset
|
462 |
JavaThread::set_stack_yellow_zone_size (align_up(StackYellowPages * 4 * K, vm_page_size())); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46587
diff
changeset
|
463 |
JavaThread::set_stack_reserved_zone_size(align_up(StackReservedPages * 4 * K, vm_page_size())); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46587
diff
changeset
|
464 |
JavaThread::set_stack_shadow_zone_size (align_up(StackShadowPages * 4 * K, vm_page_size())); |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
465 |
|
35043
30543d2a0a20
8133023: ParallelGCThreads is not calculated correctly
jmasa
parents:
34633
diff
changeset
|
466 |
// VM version initialization identifies some characteristics of the |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
467 |
// platform that are used during ergonomic decisions. |
35043
30543d2a0a20
8133023: ParallelGCThreads is not calculated correctly
jmasa
parents:
34633
diff
changeset
|
468 |
VM_Version::init_before_ergo(); |
19986
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19697
diff
changeset
|
469 |
} |
1 | 470 |
|
50184
1a4101ebec92
8202014: Possible to receive signal before signal semaphore created
coleenp
parents:
49984
diff
changeset
|
471 |
void os::initialize_jdk_signal_support(TRAPS) { |
1 | 472 |
if (!ReduceSignalUsage) { |
473 |
// Setup JavaThread for processing signals |
|
474 |
const char thread_name[] = "Signal Dispatcher"; |
|
475 |
Handle string = java_lang_String::create_from_str(thread_name, CHECK); |
|
476 |
||
477 |
// Initialize thread_oop to put it into the system threadGroup |
|
478 |
Handle thread_group (THREAD, Universe::system_thread_group()); |
|
50217
843fc56f4686
8203381: Replace InstanceKlass::allocate_instance_handle with JavaCalls::construct_new_instance
iklam
parents:
50184
diff
changeset
|
479 |
Handle thread_oop = JavaCalls::construct_new_instance(SystemDictionary::Thread_klass(), |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
480 |
vmSymbols::threadgroup_string_void_signature(), |
1 | 481 |
thread_group, |
482 |
string, |
|
483 |
CHECK); |
|
484 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46295
diff
changeset
|
485 |
Klass* group = SystemDictionary::ThreadGroup_klass(); |
50217
843fc56f4686
8203381: Replace InstanceKlass::allocate_instance_handle with JavaCalls::construct_new_instance
iklam
parents:
50184
diff
changeset
|
486 |
JavaValue result(T_VOID); |
1 | 487 |
JavaCalls::call_special(&result, |
488 |
thread_group, |
|
489 |
group, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
490 |
vmSymbols::add_method_name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
491 |
vmSymbols::thread_void_signature(), |
50217
843fc56f4686
8203381: Replace InstanceKlass::allocate_instance_handle with JavaCalls::construct_new_instance
iklam
parents:
50184
diff
changeset
|
492 |
thread_oop, |
1 | 493 |
CHECK); |
494 |
||
495 |
{ MutexLocker mu(Threads_lock); |
|
496 |
JavaThread* signal_thread = new JavaThread(&signal_thread_entry); |
|
497 |
||
498 |
// At this point it may be possible that no osthread was created for the |
|
499 |
// JavaThread due to lack of memory. We would have to throw an exception |
|
500 |
// in that case. However, since this must work and we do not allow |
|
501 |
// exceptions anyway, check and abort if this fails. |
|
502 |
if (signal_thread == NULL || signal_thread->osthread() == NULL) { |
|
503 |
vm_exit_during_initialization("java.lang.OutOfMemoryError", |
|
22758
c6b6abb73544
7182040: volano29 limited by os resource on Linux - need better diagnostic message
iklam
parents:
22556
diff
changeset
|
504 |
os::native_thread_creation_failed_msg()); |
1 | 505 |
} |
506 |
||
507 |
java_lang_Thread::set_thread(thread_oop(), signal_thread); |
|
508 |
java_lang_Thread::set_priority(thread_oop(), NearMaxPriority); |
|
509 |
java_lang_Thread::set_daemon(thread_oop()); |
|
510 |
||
511 |
signal_thread->set_threadObj(thread_oop()); |
|
512 |
Threads::add(signal_thread); |
|
513 |
Thread::start(signal_thread); |
|
514 |
} |
|
515 |
// Handle ^BREAK |
|
516 |
os::signal(SIGBREAK, os::user_handler()); |
|
517 |
} |
|
518 |
} |
|
519 |
||
520 |
||
521 |
void os::terminate_signal_thread() { |
|
522 |
if (!ReduceSignalUsage) |
|
523 |
signal_notify(sigexitnum_pd()); |
|
524 |
} |
|
525 |
||
526 |
||
527 |
// --------------------- loading libraries --------------------- |
|
528 |
||
529 |
typedef jint (JNICALL *JNI_OnLoad_t)(JavaVM *, void *); |
|
530 |
extern struct JavaVM_ main_vm; |
|
531 |
||
532 |
static void* _native_java_library = NULL; |
|
533 |
||
534 |
void* os::native_java_library() { |
|
535 |
if (_native_java_library == NULL) { |
|
536 |
char buffer[JVM_MAXPATHLEN]; |
|
537 |
char ebuf[1024]; |
|
538 |
||
539 |
// Load java dll |
|
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
540 |
if (dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), |
14471
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
541 |
"java")) { |
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
542 |
_native_java_library = dll_load(buffer, ebuf, sizeof(ebuf)); |
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
543 |
} |
1 | 544 |
if (_native_java_library == NULL) { |
545 |
vm_exit_during_initialization("Unable to load native library", ebuf); |
|
546 |
} |
|
10565 | 547 |
|
548 |
#if defined(__OpenBSD__) |
|
549 |
// Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so |
|
550 |
// ignore errors |
|
47089
27050b653624
8186072: dll_build_name returns true even if file is missing.
goetz
parents:
46969
diff
changeset
|
551 |
if (dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), |
14471
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
552 |
"net")) { |
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
553 |
dll_load(buffer, ebuf, sizeof(ebuf)); |
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
554 |
} |
10565 | 555 |
#endif |
950 | 556 |
} |
1 | 557 |
return _native_java_library; |
558 |
} |
|
559 |
||
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
560 |
/* |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
561 |
* Support for finding Agent_On(Un)Load/Attach<_lib_name> if it exists. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
562 |
* If check_lib == true then we are looking for an |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
563 |
* Agent_OnLoad_lib_name or Agent_OnAttach_lib_name function to determine if |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
564 |
* this library is statically linked into the image. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
565 |
* If check_lib == false then we will look for the appropriate symbol in the |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
566 |
* executable if agent_lib->is_static_lib() == true or in the shared library |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
567 |
* referenced by 'handle'. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
568 |
*/ |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
569 |
void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
570 |
const char *syms[], size_t syms_len) { |
19973 | 571 |
assert(agent_lib != NULL, "sanity check"); |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
572 |
const char *lib_name; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
573 |
void *handle = agent_lib->os_lib(); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
574 |
void *entryName = NULL; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
575 |
char *agent_function_name; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
576 |
size_t i; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
577 |
|
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
578 |
// If checking then use the agent name otherwise test is_static_lib() to |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
579 |
// see how to process this lookup |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
580 |
lib_name = ((check_lib || agent_lib->is_static_lib()) ? agent_lib->name() : NULL); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
581 |
for (i = 0; i < syms_len; i++) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
582 |
agent_function_name = build_agent_function_name(syms[i], lib_name, agent_lib->is_absolute_path()); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
583 |
if (agent_function_name == NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
584 |
break; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
585 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
586 |
entryName = dll_lookup(handle, agent_function_name); |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27469
diff
changeset
|
587 |
FREE_C_HEAP_ARRAY(char, agent_function_name); |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
588 |
if (entryName != NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
589 |
break; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
590 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
591 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
592 |
return entryName; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
593 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
594 |
|
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
595 |
// See if the passed in agent is statically linked into the VM image. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
596 |
bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[], |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
597 |
size_t syms_len) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
598 |
void *ret; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
599 |
void *proc_handle; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
600 |
void *save_handle; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
601 |
|
19973 | 602 |
assert(agent_lib != NULL, "sanity check"); |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
603 |
if (agent_lib->name() == NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
604 |
return false; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
605 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
606 |
proc_handle = get_default_process_handle(); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
607 |
// Check for Agent_OnLoad/Attach_lib_name function |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
608 |
save_handle = agent_lib->os_lib(); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
609 |
// We want to look in this process' symbol table. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
610 |
agent_lib->set_os_lib(proc_handle); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
611 |
ret = find_agent_function(agent_lib, true, syms, syms_len); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
612 |
if (ret != NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
613 |
// Found an entry point like Agent_OnLoad_lib_name so we have a static agent |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
614 |
agent_lib->set_valid(); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
615 |
agent_lib->set_static_lib(true); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
616 |
return true; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
617 |
} |
19973 | 618 |
agent_lib->set_os_lib(save_handle); |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
619 |
return false; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
620 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
621 |
|
1 | 622 |
// --------------------- heap allocation utilities --------------------- |
623 |
||
13195 | 624 |
char *os::strdup(const char *str, MEMFLAGS flags) { |
1 | 625 |
size_t size = strlen(str); |
13195 | 626 |
char *dup_str = (char *)malloc(size + 1, flags); |
1 | 627 |
if (dup_str == NULL) return NULL; |
628 |
strcpy(dup_str, str); |
|
629 |
return dup_str; |
|
630 |
} |
|
631 |
||
25949 | 632 |
char* os::strdup_check_oom(const char* str, MEMFLAGS flags) { |
633 |
char* p = os::strdup(str, flags); |
|
634 |
if (p == NULL) { |
|
635 |
vm_exit_out_of_memory(strlen(str) + 1, OOM_MALLOC_ERROR, "os::strdup_check_oom"); |
|
636 |
} |
|
637 |
return p; |
|
638 |
} |
|
639 |
||
1 | 640 |
|
641 |
#define paranoid 0 /* only set to 1 if you suspect checking code has bug */ |
|
642 |
||
643 |
#ifdef ASSERT |
|
644 |
||
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
645 |
static void verify_memory(void* ptr) { |
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
646 |
GuardedMemory guarded(ptr); |
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
647 |
if (!guarded.verify_guards()) { |
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
648 |
LogTarget(Warning, malloc, free) lt; |
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
649 |
ResourceMark rm; |
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
650 |
LogStream ls(lt); |
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
651 |
ls.print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees); |
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
652 |
ls.print_cr("## memory stomp:"); |
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
653 |
guarded.print_on(&ls); |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
654 |
fatal("memory stomping error"); |
1 | 655 |
} |
656 |
} |
|
657 |
||
658 |
#endif |
|
659 |
||
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
660 |
// |
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
661 |
// This function supports testing of the malloc out of memory |
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
662 |
// condition without really running the system out of memory. |
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
663 |
// |
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
664 |
static bool has_reached_max_malloc_test_peak(size_t alloc_size) { |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
665 |
if (MallocMaxTestWords > 0) { |
48955
e22914003cf0
8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents:
48865
diff
changeset
|
666 |
size_t words = (alloc_size / BytesPerWord); |
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
667 |
|
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
668 |
if ((cur_malloc_words + words) > MallocMaxTestWords) { |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
669 |
return true; |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
670 |
} |
48955
e22914003cf0
8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents:
48865
diff
changeset
|
671 |
Atomic::add(words, &cur_malloc_words); |
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
672 |
} |
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
673 |
return false; |
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
674 |
} |
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
675 |
|
25946 | 676 |
void* os::malloc(size_t size, MEMFLAGS flags) { |
677 |
return os::malloc(size, flags, CALLER_PC); |
|
678 |
} |
|
679 |
||
680 |
void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { |
|
8320 | 681 |
NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); |
682 |
NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); |
|
1 | 683 |
|
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46625
diff
changeset
|
684 |
// Since os::malloc can be called when the libjvm.{dll,so} is |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46625
diff
changeset
|
685 |
// first loaded and we don't have a thread yet we must accept NULL also here. |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46625
diff
changeset
|
686 |
assert(!os::ThreadCrashProtection::is_crash_protected(Thread::current_or_null()), |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46625
diff
changeset
|
687 |
"malloc() not allowed when crash protection is set"); |
18943 | 688 |
|
1 | 689 |
if (size == 0) { |
690 |
// return a valid pointer if size is zero |
|
691 |
// if NULL is returned the calling functions assume out of memory. |
|
692 |
size = 1; |
|
693 |
} |
|
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
694 |
|
25946 | 695 |
// NMT support |
696 |
NMT_TrackingLevel level = MemTracker::tracking_level(); |
|
697 |
size_t nmt_header_size = MemTracker::malloc_header_size(level); |
|
698 |
||
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
699 |
#ifndef ASSERT |
25946 | 700 |
const size_t alloc_size = size + nmt_header_size; |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
701 |
#else |
25946 | 702 |
const size_t alloc_size = GuardedMemory::get_total_size(size + nmt_header_size); |
703 |
if (size + nmt_header_size > alloc_size) { // Check for rollover. |
|
14487
9a40ad461ee9
7122219: Passed StringTableSize value not verified
hseigel
parents:
14120
diff
changeset
|
704 |
return NULL; |
9a40ad461ee9
7122219: Passed StringTableSize value not verified
hseigel
parents:
14120
diff
changeset
|
705 |
} |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
706 |
#endif |
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
707 |
|
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
708 |
// For the test flag -XX:MallocMaxTestWords |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
709 |
if (has_reached_max_malloc_test_peak(size)) { |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
710 |
return NULL; |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
711 |
} |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
712 |
|
16428
1b55a8d558b8
7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
rdurbin
parents:
15475
diff
changeset
|
713 |
u_char* ptr; |
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
714 |
ptr = (u_char*)::malloc(alloc_size); |
13195 | 715 |
|
1 | 716 |
#ifdef ASSERT |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
717 |
if (ptr == NULL) { |
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
718 |
return NULL; |
1 | 719 |
} |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
720 |
// Wrap memory with guard |
25946 | 721 |
GuardedMemory guarded(ptr, size + nmt_header_size); |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
722 |
ptr = guarded.get_user_ptr(); |
54363
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
723 |
|
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
724 |
if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { |
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
725 |
log_warning(malloc, free)("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, p2i(ptr)); |
1 | 726 |
breakpoint(); |
727 |
} |
|
54363
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
728 |
if (paranoid) { |
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
729 |
verify_memory(ptr); |
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
730 |
} |
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
731 |
#endif |
13195 | 732 |
|
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
733 |
// we do not track guard memory |
25946 | 734 |
return MemTracker::record_malloc((address)ptr, size, memflags, stack, level); |
1 | 735 |
} |
736 |
||
25946 | 737 |
void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) { |
738 |
return os::realloc(memblock, size, flags, CALLER_PC); |
|
739 |
} |
|
1 | 740 |
|
25946 | 741 |
void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { |
26561
e104c9397ca1
8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
25962
diff
changeset
|
742 |
|
28470
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
743 |
// For the test flag -XX:MallocMaxTestWords |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
744 |
if (has_reached_max_malloc_test_peak(size)) { |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
745 |
return NULL; |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
746 |
} |
bf674dd8644e
8058897: Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting
ctornqvi
parents:
28208
diff
changeset
|
747 |
|
46295
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
748 |
if (size == 0) { |
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
749 |
// return a valid pointer if size is zero |
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
750 |
// if NULL is returned the calling functions assume out of memory. |
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
751 |
size = 1; |
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
752 |
} |
6092ca55b77b
8168542: os::realloc should return a valid pointer for input size=0
stuefe
parents:
46289
diff
changeset
|
753 |
|
1 | 754 |
#ifndef ASSERT |
8320 | 755 |
NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); |
756 |
NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); |
|
25946 | 757 |
// NMT support |
758 |
void* membase = MemTracker::record_free(memblock); |
|
759 |
NMT_TrackingLevel level = MemTracker::tracking_level(); |
|
760 |
size_t nmt_header_size = MemTracker::malloc_header_size(level); |
|
761 |
void* ptr = ::realloc(membase, size + nmt_header_size); |
|
762 |
return MemTracker::record_malloc(ptr, size, memflags, stack, level); |
|
1 | 763 |
#else |
764 |
if (memblock == NULL) { |
|
25946 | 765 |
return os::malloc(size, memflags, stack); |
1 | 766 |
} |
767 |
if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { |
|
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
768 |
log_warning(malloc, free)("os::realloc caught " PTR_FORMAT, p2i(memblock)); |
1 | 769 |
breakpoint(); |
770 |
} |
|
25946 | 771 |
// NMT support |
772 |
void* membase = MemTracker::malloc_base(memblock); |
|
773 |
verify_memory(membase); |
|
1 | 774 |
// always move the block |
25946 | 775 |
void* ptr = os::malloc(size, memflags, stack); |
1 | 776 |
// Copy to new memory if malloc didn't fail |
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
777 |
if (ptr != NULL ) { |
25946 | 778 |
GuardedMemory guarded(MemTracker::malloc_base(memblock)); |
779 |
// Guard's user data contains NMT header |
|
780 |
size_t memblock_size = guarded.get_user_size() - MemTracker::malloc_header_size(memblock); |
|
781 |
memcpy(ptr, memblock, MIN2(size, memblock_size)); |
|
54363
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
782 |
if (paranoid) { |
f60c52198a42
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
stefank
parents:
54011
diff
changeset
|
783 |
verify_memory(MemTracker::malloc_base(ptr)); |
1 | 784 |
} |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
785 |
os::free(memblock); |
1 | 786 |
} |
787 |
return ptr; |
|
788 |
#endif |
|
789 |
} |
|
790 |
||
58084
cddef3bde924
8230398: Remove NULL checks before FREE_C_HEAP_ARRAY
lkorinth
parents:
58083
diff
changeset
|
791 |
// handles NULL pointers |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27469
diff
changeset
|
792 |
void os::free(void *memblock) { |
8320 | 793 |
NOT_PRODUCT(inc_stat_counter(&num_frees, 1)); |
1 | 794 |
#ifdef ASSERT |
795 |
if (memblock == NULL) return; |
|
796 |
if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { |
|
48859
5a4d08efbad9
6909265: assert(_OnDeck != Self->_MutexEvent,"invariant") with -XX:+PrintMallocFree
coleenp
parents:
48808
diff
changeset
|
797 |
log_warning(malloc, free)("os::free caught " PTR_FORMAT, p2i(memblock)); |
1 | 798 |
breakpoint(); |
799 |
} |
|
25946 | 800 |
void* membase = MemTracker::record_free(memblock); |
801 |
verify_memory(membase); |
|
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
802 |
|
25946 | 803 |
GuardedMemory guarded(membase); |
25056
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
804 |
size_t size = guarded.get_user_size(); |
5ad92b0d1beb
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
24457
diff
changeset
|
805 |
inc_stat_counter(&free_bytes, size); |
25946 | 806 |
membase = guarded.release_for_freeing(); |
807 |
::free(membase); |
|
808 |
#else |
|
809 |
void* membase = MemTracker::record_free(memblock); |
|
810 |
::free(membase); |
|
1 | 811 |
#endif |
812 |
} |
|
813 |
||
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
814 |
void os::init_random(unsigned int initval) { |
1 | 815 |
_rand_seed = initval; |
816 |
} |
|
817 |
||
818 |
||
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
819 |
static int random_helper(unsigned int rand_seed) { |
1 | 820 |
/* standard, well-known linear congruential random generator with |
821 |
* next_rand = (16807*seed) mod (2**31-1) |
|
822 |
* see |
|
823 |
* (1) "Random Number Generators: Good Ones Are Hard to Find", |
|
824 |
* S.K. Park and K.W. Miller, Communications of the ACM 31:10 (Oct 1988), |
|
825 |
* (2) "Two Fast Implementations of the 'Minimal Standard' Random |
|
826 |
* Number Generator", David G. Carta, Comm. ACM 33, 1 (Jan 1990), pp. 87-88. |
|
827 |
*/ |
|
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
828 |
const unsigned int a = 16807; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
829 |
const unsigned int m = 2147483647; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
830 |
const int q = m / a; assert(q == 127773, "weird math"); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
831 |
const int r = m % a; assert(r == 2836, "weird math"); |
1 | 832 |
|
833 |
// compute az=2^31p+q |
|
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
834 |
unsigned int lo = a * (rand_seed & 0xFFFF); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
835 |
unsigned int hi = a * (rand_seed >> 16); |
1 | 836 |
lo += (hi & 0x7FFF) << 16; |
837 |
||
838 |
// if q overflowed, ignore the overflow and increment q |
|
839 |
if (lo > m) { |
|
840 |
lo &= m; |
|
841 |
++lo; |
|
842 |
} |
|
843 |
lo += hi >> 15; |
|
844 |
||
845 |
// if (p+q) overflowed, ignore the overflow and increment (p+q) |
|
846 |
if (lo > m) { |
|
847 |
lo &= m; |
|
848 |
++lo; |
|
849 |
} |
|
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
850 |
return lo; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
851 |
} |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
852 |
|
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
853 |
int os::random() { |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
854 |
// Make updating the random seed thread safe. |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
855 |
while (true) { |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
856 |
unsigned int seed = _rand_seed; |
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46701
diff
changeset
|
857 |
unsigned int rand = random_helper(seed); |
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
858 |
if (Atomic::cmpxchg(rand, &_rand_seed, seed) == seed) { |
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46701
diff
changeset
|
859 |
return static_cast<int>(rand); |
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
860 |
} |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
46329
diff
changeset
|
861 |
} |
1 | 862 |
} |
863 |
||
864 |
// The INITIALIZED state is distinguished from the SUSPENDED state because the |
|
865 |
// conditions in which a thread is first started are different from those in which |
|
866 |
// a suspension is resumed. These differences make it hard for us to apply the |
|
867 |
// tougher checks when starting threads that we want to do when resuming them. |
|
868 |
// However, when start_thread is called as a result of Thread.start, on a Java |
|
869 |
// thread, the operation is synchronized on the Java Thread object. So there |
|
870 |
// cannot be a race to start the thread and hence for the thread to exit while |
|
871 |
// we are working on it. Non-Java threads that start Java threads either have |
|
872 |
// to do so in a context in which races are impossible, or should do appropriate |
|
873 |
// locking. |
|
874 |
||
875 |
void os::start_thread(Thread* thread) { |
|
876 |
// guard suspend/resume |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54436
diff
changeset
|
877 |
MutexLocker ml(thread->SR_lock(), Mutex::_no_safepoint_check_flag); |
1 | 878 |
OSThread* osthread = thread->osthread(); |
879 |
osthread->set_state(RUNNABLE); |
|
880 |
pd_start_thread(thread); |
|
881 |
} |
|
882 |
||
31026
b87ccf34b54c
8080718: Make -XX:CreateCoredumpOnCrash control core dumping in all cases
ctornqvi
parents:
30764
diff
changeset
|
883 |
void os::abort(bool dump_core) { |
b87ccf34b54c
8080718: Make -XX:CreateCoredumpOnCrash control core dumping in all cases
ctornqvi
parents:
30764
diff
changeset
|
884 |
abort(dump_core && CreateCoredumpOnCrash, NULL, NULL); |
b87ccf34b54c
8080718: Make -XX:CreateCoredumpOnCrash control core dumping in all cases
ctornqvi
parents:
30764
diff
changeset
|
885 |
} |
b87ccf34b54c
8080718: Make -XX:CreateCoredumpOnCrash control core dumping in all cases
ctornqvi
parents:
30764
diff
changeset
|
886 |
|
1 | 887 |
//--------------------------------------------------------------------------- |
888 |
// Helper functions for fatal error handler |
|
889 |
||
890 |
void os::print_hex_dump(outputStream* st, address start, address end, int unitsize) { |
|
891 |
assert(unitsize == 1 || unitsize == 2 || unitsize == 4 || unitsize == 8, "just checking"); |
|
892 |
||
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53605
diff
changeset
|
893 |
start = align_down(start, unitsize); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53605
diff
changeset
|
894 |
|
1 | 895 |
int cols = 0; |
896 |
int cols_per_line = 0; |
|
897 |
switch (unitsize) { |
|
898 |
case 1: cols_per_line = 16; break; |
|
899 |
case 2: cols_per_line = 8; break; |
|
900 |
case 4: cols_per_line = 4; break; |
|
901 |
case 8: cols_per_line = 2; break; |
|
902 |
default: return; |
|
903 |
} |
|
904 |
||
905 |
address p = start; |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
906 |
st->print(PTR_FORMAT ": ", p2i(start)); |
1 | 907 |
while (p < end) { |
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
908 |
if (is_readable_pointer(p)) { |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
909 |
switch (unitsize) { |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
910 |
case 1: st->print("%02x", *(u1*)p); break; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
911 |
case 2: st->print("%04x", *(u2*)p); break; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
912 |
case 4: st->print("%08x", *(u4*)p); break; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
913 |
case 8: st->print("%016" FORMAT64_MODIFIER "x", *(u8*)p); break; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
914 |
} |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
915 |
} else { |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
53402
diff
changeset
|
916 |
st->print("%*.*s", 2*unitsize, 2*unitsize, "????????????????"); |
1 | 917 |
} |
918 |
p += unitsize; |
|
919 |
cols++; |
|
920 |
if (cols >= cols_per_line && p < end) { |
|
921 |
cols = 0; |
|
922 |
st->cr(); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
923 |
st->print(PTR_FORMAT ": ", p2i(p)); |
1 | 924 |
} else { |
925 |
st->print(" "); |
|
926 |
} |
|
927 |
} |
|
928 |
st->cr(); |
|
929 |
} |
|
930 |
||
53605
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53582
diff
changeset
|
931 |
void os::print_instructions(outputStream* st, address pc, int unitsize) { |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53582
diff
changeset
|
932 |
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53582
diff
changeset
|
933 |
print_hex_dump(st, pc - 256, pc + 256, unitsize); |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53582
diff
changeset
|
934 |
} |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53582
diff
changeset
|
935 |
|
30125 | 936 |
void os::print_environment_variables(outputStream* st, const char** env_list) { |
1 | 937 |
if (env_list) { |
938 |
st->print_cr("Environment Variables:"); |
|
939 |
||
940 |
for (int i = 0; env_list[i] != NULL; i++) { |
|
30125 | 941 |
char *envvar = ::getenv(env_list[i]); |
942 |
if (envvar != NULL) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23863
diff
changeset
|
943 |
st->print("%s", env_list[i]); |
1 | 944 |
st->print("="); |
30125 | 945 |
st->print_cr("%s", envvar); |
1 | 946 |
} |
947 |
} |
|
948 |
} |
|
949 |
} |
|
950 |
||
31356
55ee785c49c5
8085865: hs_err improvement: Printing /proc/cpuinfo makes too long hs_err files
coleenp
parents:
31347
diff
changeset
|
951 |
void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) { |
1 | 952 |
// cpu |
953 |
st->print("CPU:"); |
|
954 |
st->print("total %d", os::processor_count()); |
|
955 |
// It's not safe to query number of active processors after crash |
|
40011 | 956 |
// st->print("(active %d)", os::active_processor_count()); but we can |
957 |
// print the initial number of active processors. |
|
958 |
// We access the raw value here because the assert in the accessor will |
|
959 |
// fail if the crash occurs before initialization of this value. |
|
960 |
st->print(" (initial active %d)", _initial_active_processor_count); |
|
35148 | 961 |
st->print(" %s", VM_Version::features_string()); |
1 | 962 |
st->cr(); |
31356
55ee785c49c5
8085865: hs_err improvement: Printing /proc/cpuinfo makes too long hs_err files
coleenp
parents:
31347
diff
changeset
|
963 |
pd_print_cpu_info(st, buf, buflen); |
1 | 964 |
} |
965 |
||
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
966 |
// Print a one line string summarizing the cpu, number of cores, memory, and operating system version |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
967 |
void os::print_summary_info(outputStream* st, char* buf, size_t buflen) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
968 |
st->print("Host: "); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
969 |
#ifndef PRODUCT |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
970 |
if (get_host_name(buf, buflen)) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
971 |
st->print("%s, ", buf); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
972 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
973 |
#endif // PRODUCT |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
974 |
get_summary_cpu_info(buf, buflen); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
975 |
st->print("%s, ", buf); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
976 |
size_t mem = physical_memory()/G; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
977 |
if (mem == 0) { // for low memory systems |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
978 |
mem = physical_memory()/M; |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
979 |
st->print("%d cores, " SIZE_FORMAT "M, ", processor_count(), mem); |
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
980 |
} else { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
981 |
st->print("%d cores, " SIZE_FORMAT "G, ", processor_count(), mem); |
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
982 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
983 |
get_summary_os_info(buf, buflen); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
984 |
st->print_raw(buf); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
985 |
st->cr(); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
986 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
987 |
|
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
988 |
void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) { |
23863
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
989 |
const int secs_per_day = 86400; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
990 |
const int secs_per_hour = 3600; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
991 |
const int secs_per_min = 60; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
992 |
|
1 | 993 |
time_t tloc; |
994 |
(void)time(&tloc); |
|
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
995 |
char* timestring = ctime(&tloc); // ctime adds newline. |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
996 |
// edit out the newline |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
997 |
char* nl = strchr(timestring, '\n'); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
998 |
if (nl != NULL) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
999 |
*nl = '\0'; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
1000 |
} |
1 | 1001 |
|
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
1002 |
struct tm tz; |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
1003 |
if (localtime_pd(&tloc, &tz) != NULL) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
1004 |
::strftime(buf, buflen, "%Z", &tz); |
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
1005 |
st->print("Time: %s %s", timestring, buf); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
1006 |
} else { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
1007 |
st->print("Time: %s", timestring); |
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
1008 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31026
diff
changeset
|
1009 |
|
1 | 1010 |
double t = os::elapsedTime(); |
1011 |
// NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in |
|
1012 |
// Linux. Must be a bug in glibc ? Workaround is to round "t" to int |
|
1013 |
// before printf. We lost some precision, but who cares? |
|
23863
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1014 |
int eltime = (int)t; // elapsed time in seconds |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1015 |
|
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1016 |
// print elapsed time in a human-readable format: |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1017 |
int eldays = eltime / secs_per_day; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1018 |
int day_secs = eldays * secs_per_day; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1019 |
int elhours = (eltime - day_secs) / secs_per_hour; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1020 |
int hour_secs = elhours * secs_per_hour; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1021 |
int elmins = (eltime - day_secs - hour_secs) / secs_per_min; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1022 |
int minute_secs = elmins * secs_per_min; |
76fc8456723d
8026334: hs_err improvement: Print elapsed time in a humanly readable format
kevinw
parents:
22876
diff
changeset
|
1023 |
int elsecs = (eltime - day_secs - hour_secs - minute_secs); |
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31608
diff
changeset
|
1024 |
st->print_cr(" elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs); |
1 | 1025 |
} |
1026 |
||
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1027 |
|
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1028 |
// Check if pointer can be read from (4-byte read access). |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1029 |
// Helps to prove validity of a not-NULL pointer. |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1030 |
// Returns true in very early stages of VM life when stub is not yet generated. |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1031 |
#define SAFEFETCH_DEFAULT true |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1032 |
bool os::is_readable_pointer(const void* p) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1033 |
if (!CanUseSafeFetch32()) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1034 |
return SAFEFETCH_DEFAULT; |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1035 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1036 |
int* const aligned = (int*) align_down((intptr_t)p, 4); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1037 |
int cafebabe = 0xcafebabe; // tester value 1 |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1038 |
int deadbeef = 0xdeadbeef; // tester value 2 |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1039 |
return (SafeFetch32(aligned, cafebabe) != cafebabe) || (SafeFetch32(aligned, deadbeef) != deadbeef); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1040 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1041 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1042 |
bool os::is_readable_range(const void* from, const void* to) { |
54436
d5fb27646df4
8221833: Readability check in Symbol::is_valid not performed for some addresses
mdoerr
parents:
54363
diff
changeset
|
1043 |
if ((uintptr_t)from >= (uintptr_t)to) return false; |
d5fb27646df4
8221833: Readability check in Symbol::is_valid not performed for some addresses
mdoerr
parents:
54363
diff
changeset
|
1044 |
for (uintptr_t p = align_down((uintptr_t)from, min_page_size()); p < (uintptr_t)to; p += min_page_size()) { |
d5fb27646df4
8221833: Readability check in Symbol::is_valid not performed for some addresses
mdoerr
parents:
54363
diff
changeset
|
1045 |
if (!is_readable_pointer((const void*)p)) { |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1046 |
return false; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1047 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1048 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1049 |
return true; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1050 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1051 |
|
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1052 |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1053 |
// moved from debug.cpp (used to be find()) but still called from there |
7108 | 1054 |
// The verbose parameter is only set by the debug code in one case |
1055 |
void os::print_location(outputStream* st, intptr_t x, bool verbose) { |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1056 |
address addr = (address)x; |
48808
2b0b7f222800
8195690: JNI GetObjectRefType doesn't handle NULL
kbarrett
parents:
48787
diff
changeset
|
1057 |
// Handle NULL first, so later checks don't need to protect against it. |
2b0b7f222800
8195690: JNI GetObjectRefType doesn't handle NULL
kbarrett
parents:
48787
diff
changeset
|
1058 |
if (addr == NULL) { |
2b0b7f222800
8195690: JNI GetObjectRefType doesn't handle NULL
kbarrett
parents:
48787
diff
changeset
|
1059 |
st->print_cr("0x0 is NULL"); |
2b0b7f222800
8195690: JNI GetObjectRefType doesn't handle NULL
kbarrett
parents:
48787
diff
changeset
|
1060 |
return; |
2b0b7f222800
8195690: JNI GetObjectRefType doesn't handle NULL
kbarrett
parents:
48787
diff
changeset
|
1061 |
} |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1062 |
|
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1063 |
// Check if addr points into a code blob. |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1064 |
CodeBlob* b = CodeCache::find_blob_unsafe(addr); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1065 |
if (b != NULL) { |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1066 |
b->dump_for_addr(addr, st, verbose); |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1067 |
return; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1068 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1069 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1070 |
// Check if addr points into Java heap. |
57903
5e2576c303a2
8229278: Improve hs_err location printing to assume less about GC internals
eosterlund
parents:
57855
diff
changeset
|
1071 |
if (Universe::heap()->print_location(st, addr)) { |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1072 |
return; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1073 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1074 |
|
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1075 |
bool accessible = is_readable_pointer(addr); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1076 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1077 |
// Check if addr is a JNI handle. |
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1078 |
if (align_down((intptr_t)addr, sizeof(intptr_t)) != 0 && accessible) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1079 |
if (JNIHandles::is_global_handle((jobject) addr)) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1080 |
st->print_cr(INTPTR_FORMAT " is a global jni handle", p2i(addr)); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1081 |
return; |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1082 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1083 |
if (JNIHandles::is_weak_global_handle((jobject) addr)) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1084 |
st->print_cr(INTPTR_FORMAT " is a weak global jni handle", p2i(addr)); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1085 |
return; |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1086 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1087 |
#ifndef PRODUCT |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1088 |
// we don't keep the block list in product mode |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1089 |
if (JNIHandles::is_local_handle((jobject) addr)) { |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1090 |
st->print_cr(INTPTR_FORMAT " is a local jni handle", p2i(addr)); |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1091 |
return; |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1092 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1093 |
#endif |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1094 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1095 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1096 |
// Check if addr belongs to a Java thread. |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
47765
diff
changeset
|
1097 |
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1098 |
// If the addr is a java thread print information about that. |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1099 |
if (addr == (address)thread) { |
7108 | 1100 |
if (verbose) { |
1101 |
thread->print_on(st); |
|
1102 |
} else { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1103 |
st->print_cr(INTPTR_FORMAT " is a thread", p2i(addr)); |
7108 | 1104 |
} |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1105 |
return; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1106 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1107 |
// If the addr is in the stack region for this thread then report that |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1108 |
// and print thread info |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
1109 |
if (thread->on_local_stack(addr)) { |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1110 |
st->print_cr(INTPTR_FORMAT " is pointing into the stack for thread: " |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1111 |
INTPTR_FORMAT, p2i(addr), p2i(thread)); |
7108 | 1112 |
if (verbose) thread->print_on(st); |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1113 |
return; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1114 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1115 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1116 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1117 |
// Check if in metaspace and print types that have vptrs |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1118 |
if (Metaspace::contains(addr)) { |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1119 |
if (Klass::is_valid((Klass*)addr)) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1120 |
st->print_cr(INTPTR_FORMAT " is a pointer to class: ", p2i(addr)); |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1121 |
((Klass*)addr)->print_on(st); |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1122 |
} else if (Method::is_valid_method((const Method*)addr)) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1123 |
((Method*)addr)->print_value_on(st); |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1124 |
st->cr(); |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1125 |
} else { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1126 |
// Use addr->print() from the debugger instead (not here) |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1127 |
st->print_cr(INTPTR_FORMAT " is pointing into metadata", p2i(addr)); |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1128 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1129 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1130 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1131 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1132 |
// Compressed klass needs to be decoded first. |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1133 |
#ifdef _LP64 |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1134 |
if (UseCompressedClassPointers && ((uintptr_t)addr &~ (uintptr_t)max_juint) == 0) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1135 |
narrowKlass narrow_klass = (narrowKlass)(uintptr_t)addr; |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
1136 |
Klass* k = CompressedKlassPointers::decode_raw(narrow_klass); |
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1137 |
|
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1138 |
if (Klass::is_valid(k)) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1139 |
st->print_cr(UINT32_FORMAT " is a compressed pointer to class: " INTPTR_FORMAT, narrow_klass, p2i((HeapWord*)k)); |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1140 |
k->print_on(st); |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1141 |
return; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1142 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1143 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1144 |
#endif |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51139
diff
changeset
|
1145 |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1146 |
// Try an OS specific find |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1147 |
if (os::find(addr, st)) { |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1148 |
return; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1149 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1150 |
|
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1151 |
if (accessible) { |
52115 | 1152 |
st->print(INTPTR_FORMAT " points into unknown readable memory:", p2i(addr)); |
1153 |
for (address p = addr; p < align_up(addr + 1, sizeof(intptr_t)); ++p) { |
|
1154 |
st->print(" %02x", *(u1*)p); |
|
1155 |
} |
|
1156 |
st->cr(); |
|
51139
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1157 |
return; |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1158 |
} |
c95334202a14
8207342: error occurred during error reporting (printing register info)
mdoerr
parents:
50217
diff
changeset
|
1159 |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1160 |
st->print_cr(INTPTR_FORMAT " is an unknown value", p2i(addr)); |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5922
diff
changeset
|
1161 |
} |
1 | 1162 |
|
49626
db98e571f393
8200245: Zero fails to build on linux-ia64 due to ia64-specific cruft
glaubitz
parents:
49593
diff
changeset
|
1163 |
// Looks like all platforms can use the same function to check if C |
db98e571f393
8200245: Zero fails to build on linux-ia64 due to ia64-specific cruft
glaubitz
parents:
49593
diff
changeset
|
1164 |
// stack is walkable beyond current frame. The check for fp() is not |
1 | 1165 |
// necessary on Sparc, but it's harmless. |
1166 |
bool os::is_first_C_frame(frame* fr) { |
|
1167 |
// Load up sp, fp, sender sp and sender fp, check for reasonable values. |
|
1168 |
// Check usp first, because if that's bad the other accessors may fault |
|
1169 |
// on some architectures. Ditto ufp second, etc. |
|
1170 |
uintptr_t fp_align_mask = (uintptr_t)(sizeof(address)-1); |
|
1171 |
// sp on amd can be 32 bit aligned. |
|
1172 |
uintptr_t sp_align_mask = (uintptr_t)(sizeof(int)-1); |
|
1173 |
||
1174 |
uintptr_t usp = (uintptr_t)fr->sp(); |
|
1175 |
if ((usp & sp_align_mask) != 0) return true; |
|
1176 |
||
1177 |
uintptr_t ufp = (uintptr_t)fr->fp(); |
|
1178 |
if ((ufp & fp_align_mask) != 0) return true; |
|
1179 |
||
1180 |
uintptr_t old_sp = (uintptr_t)fr->sender_sp(); |
|
1181 |
if ((old_sp & sp_align_mask) != 0) return true; |
|
1182 |
if (old_sp == 0 || old_sp == (uintptr_t)-1) return true; |
|
1183 |
||
1184 |
uintptr_t old_fp = (uintptr_t)fr->link(); |
|
1185 |
if ((old_fp & fp_align_mask) != 0) return true; |
|
1186 |
if (old_fp == 0 || old_fp == (uintptr_t)-1 || old_fp == ufp) return true; |
|
1187 |
||
1188 |
// stack grows downwards; if old_fp is below current fp or if the stack |
|
1189 |
// frame is too large, either the stack is corrupted or fp is not saved |
|
1190 |
// on stack (i.e. on x86, ebp may be used as general register). The stack |
|
1191 |
// is not walkable beyond current frame. |
|
1192 |
if (old_fp < ufp) return true; |
|
1193 |
if (old_fp - ufp > 64 * K) return true; |
|
1194 |
||
1195 |
return false; |
|
1196 |
} |
|
1197 |
||
1198 |
||
1199 |
// Set up the boot classpath. |
|
1200 |
||
1201 |
char* os::format_boot_path(const char* format_string, |
|
1202 |
const char* home, |
|
1203 |
int home_len, |
|
1204 |
char fileSep, |
|
1205 |
char pathSep) { |
|
1206 |
assert((fileSep == '/' && pathSep == ':') || |
|
22775 | 1207 |
(fileSep == '\\' && pathSep == ';'), "unexpected separator chars"); |
1 | 1208 |
|
1209 |
// Scan the format string to determine the length of the actual |
|
1210 |
// boot classpath, and handle platform dependencies as well. |
|
1211 |
int formatted_path_len = 0; |
|
1212 |
const char* p; |
|
1213 |
for (p = format_string; *p != 0; ++p) { |
|
1214 |
if (*p == '%') formatted_path_len += home_len - 1; |
|
1215 |
++formatted_path_len; |
|
1216 |
} |
|
1217 |
||
13195 | 1218 |
char* formatted_path = NEW_C_HEAP_ARRAY(char, formatted_path_len + 1, mtInternal); |
1 | 1219 |
|
1220 |
// Create boot classpath from format, substituting separator chars and |
|
1221 |
// java home directory. |
|
1222 |
char* q = formatted_path; |
|
1223 |
for (p = format_string; *p != 0; ++p) { |
|
1224 |
switch (*p) { |
|
1225 |
case '%': |
|
1226 |
strcpy(q, home); |
|
1227 |
q += home_len; |
|
1228 |
break; |
|
1229 |
case '/': |
|
1230 |
*q++ = fileSep; |
|
1231 |
break; |
|
1232 |
case ':': |
|
1233 |
*q++ = pathSep; |
|
1234 |
break; |
|
1235 |
default: |
|
1236 |
*q++ = *p; |
|
1237 |
} |
|
1238 |
} |
|
1239 |
*q = '\0'; |
|
1240 |
||
1241 |
assert((q - formatted_path) == formatted_path_len, "formatted_path size botched"); |
|
1242 |
return formatted_path; |
|
1243 |
} |
|
1244 |
||
49984
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1245 |
// This function is a proxy to fopen, it tries to add a non standard flag ('e' or 'N') |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1246 |
// that ensures automatic closing of the file on exec. If it can not find support in |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1247 |
// the underlying c library, it will make an extra system call (fcntl) to ensure automatic |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1248 |
// closing of the file on exec. |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1249 |
FILE* os::fopen(const char* path, const char* mode) { |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1250 |
char modified_mode[20]; |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1251 |
assert(strlen(mode) + 1 < sizeof(modified_mode), "mode chars plus one extra must fit in buffer"); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1252 |
sprintf(modified_mode, "%s" LINUX_ONLY("e") BSD_ONLY("e") WINDOWS_ONLY("N"), mode); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1253 |
FILE* file = ::fopen(path, modified_mode); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1254 |
|
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1255 |
#if !(defined LINUX || defined BSD || defined _WINDOWS) |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1256 |
// assume fcntl FD_CLOEXEC support as a backup solution when 'e' or 'N' |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1257 |
// is not supported as mode in fopen |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1258 |
if (file != NULL) { |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1259 |
int fd = fileno(file); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1260 |
if (fd != -1) { |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1261 |
int fd_flags = fcntl(fd, F_GETFD); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1262 |
if (fd_flags != -1) { |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1263 |
fcntl(fd, F_SETFD, fd_flags | FD_CLOEXEC); |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1264 |
} |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1265 |
} |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1266 |
} |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1267 |
#endif |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1268 |
|
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1269 |
return file; |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1270 |
} |
aa3afd9bda87
8176717: GC log file handle leaked to child processes
lkorinth
parents:
49968
diff
changeset
|
1271 |
|
1 | 1272 |
bool os::set_boot_path(char fileSep, char pathSep) { |
25856 | 1273 |
const char* home = Arguments::get_java_home(); |
1274 |
int home_len = (int)strlen(home); |
|
1275 |
||
27562 | 1276 |
struct stat st; |
1277 |
||
36508 | 1278 |
// modular image if "modules" jimage exists |
1279 |
char* jimage = format_boot_path("%/lib/" MODULES_IMAGE_NAME, home, home_len, fileSep, pathSep); |
|
27562 | 1280 |
if (jimage == NULL) return false; |
1281 |
bool has_jimage = (os::stat(jimage, &st) == 0); |
|
1282 |
if (has_jimage) { |
|
40013 | 1283 |
Arguments::set_sysclasspath(jimage, true); |
32198
be9ac7dad761
8132892: Memory must be freed after calling Arguments::set_sysclasspath function
ddmitriev
parents:
31963
diff
changeset
|
1284 |
FREE_C_HEAP_ARRAY(char, jimage); |
27562 | 1285 |
return true; |
1286 |
} |
|
27926 | 1287 |
FREE_C_HEAP_ARRAY(char, jimage); |
1 | 1288 |
|
29076
4a5f7c1e6ed7
8068687: Remove meta-index support and cleanup hotspot code for rt.jar etc in non-modular jdk image
hseigel
parents:
28636
diff
changeset
|
1289 |
// check if developer build with exploded modules |
43451
7706e5ac9f32
8170827: Correct errant "java.base" string to macro
rprotacio
parents:
42066
diff
changeset
|
1290 |
char* base_classes = format_boot_path("%/modules/" JAVA_BASE_NAME, home, home_len, fileSep, pathSep); |
36508 | 1291 |
if (base_classes == NULL) return false; |
1292 |
if (os::stat(base_classes, &st) == 0) { |
|
40013 | 1293 |
Arguments::set_sysclasspath(base_classes, false); |
36508 | 1294 |
FREE_C_HEAP_ARRAY(char, base_classes); |
1295 |
return true; |
|
29076
4a5f7c1e6ed7
8068687: Remove meta-index support and cleanup hotspot code for rt.jar etc in non-modular jdk image
hseigel
parents:
28636
diff
changeset
|
1296 |
} |
36508 | 1297 |
FREE_C_HEAP_ARRAY(char, base_classes); |
25856 | 1298 |
|
36508 | 1299 |
return false; |
1 | 1300 |
} |
1301 |
||
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1302 |
// Splits a path, based on its separator, the number of |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1303 |
// elements is returned back in "elements". |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1304 |
// file_name_length is used as a modifier for each path's |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1305 |
// length when compared to JVM_MAXPATHLEN. So if you know |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1306 |
// each returned path will have something appended when |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1307 |
// in use, you can pass the length of that in |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1308 |
// file_name_length, to ensure we detect if any path |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1309 |
// exceeds the maximum path length once prepended onto |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1310 |
// the sub-path/file name. |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1311 |
// It is the callers responsibility to: |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1312 |
// a> check the value of "elements", which may be 0. |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1313 |
// b> ignore any empty path elements |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1314 |
// c> free up the data. |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1315 |
char** os::split_path(const char* path, size_t* elements, size_t file_name_length) { |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1316 |
*elements = (size_t)0; |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1317 |
if (path == NULL || strlen(path) == 0 || file_name_length == (size_t)NULL) { |
2358 | 1318 |
return NULL; |
1319 |
} |
|
1320 |
const char psepchar = *os::path_separator(); |
|
58083 | 1321 |
char* inpath = NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal); |
14471
f3a6b82e25cf
8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken
bpittore
parents:
14120
diff
changeset
|
1322 |
strcpy(inpath, path); |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1323 |
size_t count = 1; |
2358 | 1324 |
char* p = strchr(inpath, psepchar); |
1325 |
// Get a count of elements to allocate memory |
|
1326 |
while (p != NULL) { |
|
1327 |
count++; |
|
1328 |
p++; |
|
1329 |
p = strchr(p, psepchar); |
|
1330 |
} |
|
58083 | 1331 |
|
1332 |
char** opath = NEW_C_HEAP_ARRAY(char*, count, mtInternal); |
|
2358 | 1333 |
|
1334 |
// do the actual splitting |
|
1335 |
p = inpath; |
|
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1336 |
for (size_t i = 0 ; i < count ; i++) { |
2358 | 1337 |
size_t len = strcspn(p, os::path_separator()); |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1338 |
if (len + file_name_length > JVM_MAXPATHLEN) { |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1339 |
// release allocated storage before exiting the vm |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1340 |
free_array_of_char_arrays(opath, i++); |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1341 |
vm_exit_during_initialization("The VM tried to use a path that exceeds the maximum path length for " |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1342 |
"this system. Review path-containing parameters and properties, such as " |
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1343 |
"sun.boot.library.path, to identify potential sources for this path."); |
2358 | 1344 |
} |
1345 |
// allocate the string and add terminator storage |
|
58282
03fce7b04b42
8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents:
58095
diff
changeset
|
1346 |
char* s = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal); |
2358 | 1347 |
strncpy(s, p, len); |
1348 |
s[len] = '\0'; |
|
1349 |
opath[i] = s; |
|
1350 |
p += len + 1; |
|
1351 |
} |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27469
diff
changeset
|
1352 |
FREE_C_HEAP_ARRAY(char, inpath); |
57855
00bf1e66de11
8227021: VM fails if any sun.boot.library.path paths are longer than JVM_MAXPATHLEN
afarley
parents:
57745
diff
changeset
|
1353 |
*elements = count; |
2358 | 1354 |
return opath; |
1355 |
} |
|
1356 |
||
1 | 1357 |
// Returns true if the current stack pointer is above the stack shadow |
1358 |
// pages, false otherwise. |
|
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38734
diff
changeset
|
1359 |
bool os::stack_shadow_pages_available(Thread *thread, const methodHandle& method, address sp) { |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
1360 |
if (!thread->is_Java_thread()) return false; |
1 | 1361 |
// Check if we have StackShadowPages above the yellow zone. This parameter |
2131 | 1362 |
// is dependent on the depth of the maximum VM call stack possible from |
1 | 1363 |
// the handler for stack overflow. 'instanceof' in the stack overflow |
1364 |
// handler or a println uses at least 8k stack of VM and native code |
|
1365 |
// respectively. |
|
1366 |
const int framesize_in_bytes = |
|
1367 |
Interpreter::size_top_interpreter_activation(method()) * wordSize; |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
1368 |
|
38734
69ced2325f58
8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents:
37462
diff
changeset
|
1369 |
address limit = ((JavaThread*)thread)->stack_end() + |
69ced2325f58
8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents:
37462
diff
changeset
|
1370 |
(JavaThread::stack_guard_zone_size() + JavaThread::stack_shadow_zone_size()); |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
1371 |
|
38734
69ced2325f58
8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents:
37462
diff
changeset
|
1372 |
return sp > (limit + framesize_in_bytes); |
1 | 1373 |
} |
1374 |
||
28631 | 1375 |
size_t os::page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned) { |
1 | 1376 |
assert(min_pages > 0, "sanity"); |
1377 |
if (UseLargePages) { |
|
26700
8107d0778244
8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents:
26561
diff
changeset
|
1378 |
const size_t max_page_size = region_size / min_pages; |
1 | 1379 |
|
26700
8107d0778244
8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents:
26561
diff
changeset
|
1380 |
for (size_t i = 0; _page_sizes[i] != 0; ++i) { |
8107d0778244
8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents:
26561
diff
changeset
|
1381 |
const size_t page_size = _page_sizes[i]; |
28631 | 1382 |
if (page_size <= max_page_size) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46587
diff
changeset
|
1383 |
if (!must_be_aligned || is_aligned(region_size, page_size)) { |
28631 | 1384 |
return page_size; |
1385 |
} |
|
1 | 1386 |
} |
1387 |
} |
|
1388 |
} |
|
1389 |
||
1390 |
return vm_page_size(); |
|
1391 |
} |
|
1392 |
||
28631 | 1393 |
size_t os::page_size_for_region_aligned(size_t region_size, size_t min_pages) { |
1394 |
return page_size_for_region(region_size, min_pages, true); |
|
1395 |
} |
|
1396 |
||
1397 |
size_t os::page_size_for_region_unaligned(size_t region_size, size_t min_pages) { |
|
1398 |
return page_size_for_region(region_size, min_pages, false); |
|
1399 |
} |
|
1400 |
||
37113 | 1401 |
static const char* errno_to_string (int e, bool short_text) { |
1402 |
#define ALL_SHARED_ENUMS(X) \ |
|
1403 |
X(E2BIG, "Argument list too long") \ |
|
1404 |
X(EACCES, "Permission denied") \ |
|
1405 |
X(EADDRINUSE, "Address in use") \ |
|
1406 |
X(EADDRNOTAVAIL, "Address not available") \ |
|
1407 |
X(EAFNOSUPPORT, "Address family not supported") \ |
|
1408 |
X(EAGAIN, "Resource unavailable, try again") \ |
|
1409 |
X(EALREADY, "Connection already in progress") \ |
|
1410 |
X(EBADF, "Bad file descriptor") \ |
|
1411 |
X(EBADMSG, "Bad message") \ |
|
1412 |
X(EBUSY, "Device or resource busy") \ |
|
1413 |
X(ECANCELED, "Operation canceled") \ |
|
1414 |
X(ECHILD, "No child processes") \ |
|
1415 |
X(ECONNABORTED, "Connection aborted") \ |
|
1416 |
X(ECONNREFUSED, "Connection refused") \ |
|
1417 |
X(ECONNRESET, "Connection reset") \ |
|
1418 |
X(EDEADLK, "Resource deadlock would occur") \ |
|
1419 |
X(EDESTADDRREQ, "Destination address required") \ |
|
1420 |
X(EDOM, "Mathematics argument out of domain of function") \ |
|
1421 |
X(EEXIST, "File exists") \ |
|
1422 |
X(EFAULT, "Bad address") \ |
|
1423 |
X(EFBIG, "File too large") \ |
|
1424 |
X(EHOSTUNREACH, "Host is unreachable") \ |
|
1425 |
X(EIDRM, "Identifier removed") \ |
|
1426 |
X(EILSEQ, "Illegal byte sequence") \ |
|
1427 |
X(EINPROGRESS, "Operation in progress") \ |
|
1428 |
X(EINTR, "Interrupted function") \ |
|
1429 |
X(EINVAL, "Invalid argument") \ |
|
1430 |
X(EIO, "I/O error") \ |
|
1431 |
X(EISCONN, "Socket is connected") \ |
|
1432 |
X(EISDIR, "Is a directory") \ |
|
1433 |
X(ELOOP, "Too many levels of symbolic links") \ |
|
1434 |
X(EMFILE, "Too many open files") \ |
|
1435 |
X(EMLINK, "Too many links") \ |
|
1436 |
X(EMSGSIZE, "Message too large") \ |
|
1437 |
X(ENAMETOOLONG, "Filename too long") \ |
|
1438 |
X(ENETDOWN, "Network is down") \ |
|
1439 |
X(ENETRESET, "Connection aborted by network") \ |
|
1440 |
X(ENETUNREACH, "Network unreachable") \ |
|
1441 |
X(ENFILE, "Too many files open in system") \ |
|
1442 |
X(ENOBUFS, "No buffer space available") \ |
|
1443 |
X(ENODATA, "No message is available on the STREAM head read queue") \ |
|
1444 |
X(ENODEV, "No such device") \ |
|
1445 |
X(ENOENT, "No such file or directory") \ |
|
1446 |
X(ENOEXEC, "Executable file format error") \ |
|
1447 |
X(ENOLCK, "No locks available") \ |
|
1448 |
X(ENOLINK, "Reserved") \ |
|
1449 |
X(ENOMEM, "Not enough space") \ |
|
1450 |
X(ENOMSG, "No message of the desired type") \ |
|
1451 |
X(ENOPROTOOPT, "Protocol not available") \ |
|
1452 |
X(ENOSPC, "No space left on device") \ |
|
1453 |
X(ENOSR, "No STREAM resources") \ |
|
1454 |
X(ENOSTR, "Not a STREAM") \ |
|
1455 |
X(ENOSYS, "Function not supported") \ |
|
1456 |
X(ENOTCONN, "The socket is not connected") \ |
|
1457 |
X(ENOTDIR, "Not a directory") \ |
|
1458 |
X(ENOTEMPTY, "Directory not empty") \ |
|
1459 |
X(ENOTSOCK, "Not a socket") \ |
|
1460 |
X(ENOTSUP, "Not supported") \ |
|
1461 |
X(ENOTTY, "Inappropriate I/O control operation") \ |
|
1462 |
X(ENXIO, "No such device or address") \ |
|
1463 |
X(EOPNOTSUPP, "Operation not supported on socket") \ |
|
1464 |
X(EOVERFLOW, "Value too large to be stored in data type") \ |
|
1465 |
X(EPERM, "Operation not permitted") \ |
|
1466 |
X(EPIPE, "Broken pipe") \ |
|
1467 |
X(EPROTO, "Protocol error") \ |
|
1468 |
X(EPROTONOSUPPORT, "Protocol not supported") \ |
|
1469 |
X(EPROTOTYPE, "Protocol wrong type for socket") \ |
|
1470 |
X(ERANGE, "Result too large") \ |
|
1471 |
X(EROFS, "Read-only file system") \ |
|
1472 |
X(ESPIPE, "Invalid seek") \ |
|
1473 |
X(ESRCH, "No such process") \ |
|
1474 |
X(ETIME, "Stream ioctl() timeout") \ |
|
1475 |
X(ETIMEDOUT, "Connection timed out") \ |
|
1476 |
X(ETXTBSY, "Text file busy") \ |
|
1477 |
X(EWOULDBLOCK, "Operation would block") \ |
|
1478 |
X(EXDEV, "Cross-device link") |
|
1479 |
||
1480 |
#define DEFINE_ENTRY(e, text) { e, #e, text }, |
|
1481 |
||
1482 |
static const struct { |
|
1483 |
int v; |
|
1484 |
const char* short_text; |
|
1485 |
const char* long_text; |
|
1486 |
} table [] = { |
|
1487 |
||
1488 |
ALL_SHARED_ENUMS(DEFINE_ENTRY) |
|
1489 |
||
1490 |
// The following enums are not defined on all platforms. |
|
1491 |
#ifdef ESTALE |
|
1492 |
DEFINE_ENTRY(ESTALE, "Reserved") |
|
1493 |
#endif |
|
1494 |
#ifdef EDQUOT |
|
1495 |
DEFINE_ENTRY(EDQUOT, "Reserved") |
|
1496 |
#endif |
|
1497 |
#ifdef EMULTIHOP |
|
1498 |
DEFINE_ENTRY(EMULTIHOP, "Reserved") |
|
1499 |
#endif |
|
1500 |
||
1501 |
// End marker. |
|
1502 |
{ -1, "Unknown errno", "Unknown error" } |
|
1503 |
||
1504 |
}; |
|
1505 |
||
1506 |
#undef DEFINE_ENTRY |
|
1507 |
#undef ALL_FLAGS |
|
1508 |
||
1509 |
int i = 0; |
|
1510 |
while (table[i].v != -1 && table[i].v != e) { |
|
1511 |
i ++; |
|
1512 |
} |
|
1513 |
||
1514 |
return short_text ? table[i].short_text : table[i].long_text; |
|
1515 |
||
1516 |
} |
|
1517 |
||
1518 |
const char* os::strerror(int e) { |
|
1519 |
return errno_to_string(e, false); |
|
1520 |
} |
|
1521 |
||
1522 |
const char* os::errno_name(int e) { |
|
1523 |
return errno_to_string(e, true); |
|
1524 |
} |
|
1525 |
||
37462 | 1526 |
void os::trace_page_sizes(const char* str, const size_t* page_sizes, int count) { |
1527 |
LogTarget(Info, pagesize) log; |
|
1528 |
if (log.is_enabled()) { |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46644
diff
changeset
|
1529 |
LogStream out(log); |
37462 | 1530 |
|
1531 |
out.print("%s: ", str); |
|
10272 | 1532 |
for (int i = 0; i < count; ++i) { |
37462 | 1533 |
out.print(" " SIZE_FORMAT, page_sizes[i]); |
10272 | 1534 |
} |
37462 | 1535 |
out.cr(); |
10272 | 1536 |
} |
1537 |
} |
|
1538 |
||
37462 | 1539 |
#define trace_page_size_params(size) byte_size_in_exact_unit(size), exact_unit_for_byte_size(size) |
1540 |
||
1541 |
void os::trace_page_sizes(const char* str, |
|
1542 |
const size_t region_min_size, |
|
1543 |
const size_t region_max_size, |
|
1544 |
const size_t page_size, |
|
1545 |
const char* base, |
|
1546 |
const size_t size) { |
|
1547 |
||
1548 |
log_info(pagesize)("%s: " |
|
1549 |
" min=" SIZE_FORMAT "%s" |
|
1550 |
" max=" SIZE_FORMAT "%s" |
|
1551 |
" base=" PTR_FORMAT |
|
1552 |
" page_size=" SIZE_FORMAT "%s" |
|
1553 |
" size=" SIZE_FORMAT "%s", |
|
1554 |
str, |
|
1555 |
trace_page_size_params(region_min_size), |
|
1556 |
trace_page_size_params(region_max_size), |
|
1557 |
p2i(base), |
|
1558 |
trace_page_size_params(page_size), |
|
1559 |
trace_page_size_params(size)); |
|
1 | 1560 |
} |
37462 | 1561 |
|
1562 |
void os::trace_page_sizes_for_requested_size(const char* str, |
|
1563 |
const size_t requested_size, |
|
1564 |
const size_t page_size, |
|
1565 |
const size_t alignment, |
|
1566 |
const char* base, |
|
1567 |
const size_t size) { |
|
1568 |
||
1569 |
log_info(pagesize)("%s:" |
|
1570 |
" req_size=" SIZE_FORMAT "%s" |
|
1571 |
" base=" PTR_FORMAT |
|
1572 |
" page_size=" SIZE_FORMAT "%s" |
|
1573 |
" alignment=" SIZE_FORMAT "%s" |
|
1574 |
" size=" SIZE_FORMAT "%s", |
|
1575 |
str, |
|
1576 |
trace_page_size_params(requested_size), |
|
1577 |
p2i(base), |
|
1578 |
trace_page_size_params(page_size), |
|
1579 |
trace_page_size_params(alignment), |
|
1580 |
trace_page_size_params(size)); |
|
1581 |
} |
|
1582 |
||
1 | 1583 |
|
1584 |
// This is the working definition of a server class machine: |
|
1585 |
// >= 2 physical CPU's and >=2GB of memory, with some fuzz |
|
1586 |
// because the graphics memory (?) sometimes masks physical memory. |
|
1587 |
// If you want to change the definition of a server class machine |
|
22551 | 1588 |
// on some OS or platform, e.g., >=4GB on Windows platforms, |
1 | 1589 |
// then you'll have to parameterize this method based on that state, |
1590 |
// as was done for logical processors here, or replicate and |
|
1591 |
// specialize this method for each platform. (Or fix os to have |
|
1592 |
// some inheritance structure and use subclassing. Sigh.) |
|
1593 |
// If you want some platform to always or never behave as a server |
|
1594 |
// class machine, change the setting of AlwaysActAsServerClassMachine |
|
1595 |
// and NeverActAsServerClassMachine in globals*.hpp. |
|
1596 |
bool os::is_server_class_machine() { |
|
1597 |
// First check for the early returns |
|
1598 |
if (NeverActAsServerClassMachine) { |
|
1599 |
return false; |
|
1600 |
} |
|
1601 |
if (AlwaysActAsServerClassMachine) { |
|
1602 |
return true; |
|
1603 |
} |
|
1604 |
// Then actually look at the machine |
|
1605 |
bool result = false; |
|
1606 |
const unsigned int server_processors = 2; |
|
1607 |
const julong server_memory = 2UL * G; |
|
1608 |
// We seem not to get our full complement of memory. |
|
1609 |
// We allow some part (1/8?) of the memory to be "missing", |
|
1610 |
// based on the sizes of DIMMs, and maybe graphics cards. |
|
1611 |
const julong missing_memory = 256UL * M; |
|
1612 |
||
1613 |
/* Is this a server class machine? */ |
|
1614 |
if ((os::active_processor_count() >= (int)server_processors) && |
|
1615 |
(os::physical_memory() >= (server_memory - missing_memory))) { |
|
1616 |
const unsigned int logical_processors = |
|
1617 |
VM_Version::logical_processors_per_package(); |
|
1618 |
if (logical_processors > 1) { |
|
1619 |
const unsigned int physical_packages = |
|
1620 |
os::active_processor_count() / logical_processors; |
|
35949
02676622ca27
8149184: os::is_server_class_machine() could return incorrect result if a host's cpu have a few logical cores
kzhaldyb
parents:
35232
diff
changeset
|
1621 |
if (physical_packages >= server_processors) { |
1 | 1622 |
result = true; |
1623 |
} |
|
1624 |
} else { |
|
1625 |
result = true; |
|
1626 |
} |
|
1627 |
} |
|
1628 |
return result; |
|
1629 |
} |
|
9125
3b9a527cd492
7017193: Small memory leak in get_stack_bounds os::create_stack_guard_pages
dsamersoff
parents:
8736
diff
changeset
|
1630 |
|
40011 | 1631 |
void os::initialize_initial_active_processor_count() { |
1632 |
assert(_initial_active_processor_count == 0, "Initial active processor count already set."); |
|
1633 |
_initial_active_processor_count = active_processor_count(); |
|
1634 |
log_debug(os)("Initial active processor count set to %d" , _initial_active_processor_count); |
|
1635 |
} |
|
1636 |
||
18025 | 1637 |
void os::SuspendedThreadTask::run() { |
1638 |
internal_do_task(); |
|
1639 |
_done = true; |
|
1640 |
} |
|
1641 |
||
13195 | 1642 |
bool os::create_stack_guard_pages(char* addr, size_t bytes) { |
1643 |
return os::pd_create_stack_guard_pages(addr, bytes); |
|
1644 |
} |
|
1645 |
||
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1646 |
char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint, int file_desc) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1647 |
char* result = NULL; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1648 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1649 |
if (file_desc != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1650 |
// Could have called pd_reserve_memory() followed by replace_existing_mapping_with_file_mapping(), |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1651 |
// but AIX may use SHM in which case its more trouble to detach the segment and remap memory to the file. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1652 |
result = os::map_memory_to_file(addr, bytes, file_desc); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1653 |
if (result != NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1654 |
MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1655 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1656 |
} else { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1657 |
result = pd_reserve_memory(bytes, addr, alignment_hint); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1658 |
if (result != NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1659 |
MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1660 |
} |
13195 | 1661 |
} |
1662 |
||
1663 |
return result; |
|
1664 |
} |
|
17302
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1665 |
|
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1666 |
char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint, |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1667 |
MEMFLAGS flags) { |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1668 |
char* result = pd_reserve_memory(bytes, addr, alignment_hint); |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1669 |
if (result != NULL) { |
25946 | 1670 |
MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); |
17302
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1671 |
MemTracker::record_virtual_memory_type((address)result, flags); |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1672 |
} |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1673 |
|
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1674 |
return result; |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1675 |
} |
915323420691
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
16434
diff
changeset
|
1676 |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1677 |
char* os::attempt_reserve_memory_at(size_t bytes, char* addr, int file_desc) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1678 |
char* result = NULL; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1679 |
if (file_desc != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1680 |
result = pd_attempt_reserve_memory_at(bytes, addr, file_desc); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1681 |
if (result != NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1682 |
MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1683 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1684 |
} else { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1685 |
result = pd_attempt_reserve_memory_at(bytes, addr); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1686 |
if (result != NULL) { |
49034
57d0c33ad636
8198225: os::attempt_reserve_memory_at records memory as committed
stefank
parents:
48955
diff
changeset
|
1687 |
MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
48105
diff
changeset
|
1688 |
} |
13195 | 1689 |
} |
1690 |
return result; |
|
1691 |
} |
|
1692 |
||
1693 |
void os::split_reserved_memory(char *base, size_t size, |
|
1694 |
size_t split, bool realloc) { |
|
1695 |
pd_split_reserved_memory(base, size, split, realloc); |
|
1696 |
} |
|
1697 |
||
1698 |
bool os::commit_memory(char* addr, size_t bytes, bool executable) { |
|
1699 |
bool res = pd_commit_memory(addr, bytes, executable); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13923
diff
changeset
|
1700 |
if (res) { |
13195 | 1701 |
MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC); |
1702 |
} |
|
1703 |
return res; |
|
1704 |
} |
|
1705 |
||
1706 |
bool os::commit_memory(char* addr, size_t size, size_t alignment_hint, |
|
1707 |
bool executable) { |
|
1708 |
bool res = os::pd_commit_memory(addr, size, alignment_hint, executable); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13923
diff
changeset
|
1709 |
if (res) { |
13195 | 1710 |
MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); |
1711 |
} |
|
1712 |
return res; |
|
1713 |
} |
|
1714 |
||
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1715 |
void os::commit_memory_or_exit(char* addr, size_t bytes, bool executable, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1716 |
const char* mesg) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1717 |
pd_commit_memory_or_exit(addr, bytes, executable, mesg); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1718 |
MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1719 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1720 |
|
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1721 |
void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1722 |
bool executable, const char* mesg) { |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1723 |
os::pd_commit_memory_or_exit(addr, size, alignment_hint, executable, mesg); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1724 |
MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1725 |
} |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
18025
diff
changeset
|
1726 |
|
13195 | 1727 |
bool os::uncommit_memory(char* addr, size_t bytes) { |
25946 | 1728 |
bool res; |
1729 |
if (MemTracker::tracking_level() > NMT_minimal) { |
|
48865
53427ddce0a0
8194934: NMT: Remove MemTracker::get_virtual_memory_xxx_tracker(), create Tracker in place
zgu
parents:
48859
diff
changeset
|
1730 |
Tracker tkr(Tracker::uncommit); |
25946 | 1731 |
res = pd_uncommit_memory(addr, bytes); |
1732 |
if (res) { |
|
1733 |
tkr.record((address)addr, bytes); |
|
1734 |
} |
|
18086
f44cf213a775
8013651: NMT: reserve/release sequence id's in incorrect order due to race
zgu
parents:
18069
diff
changeset
|
1735 |
} else { |
25946 | 1736 |
res = pd_uncommit_memory(addr, bytes); |
13195 | 1737 |
} |
1738 |
return res; |
|
1739 |
} |
|
1740 |
||
1741 |
bool os::release_memory(char* addr, size_t bytes) { |
|
25946 | 1742 |
bool res; |
1743 |
if (MemTracker::tracking_level() > NMT_minimal) { |
|
48865
53427ddce0a0
8194934: NMT: Remove MemTracker::get_virtual_memory_xxx_tracker(), create Tracker in place
zgu
parents:
48859
diff
changeset
|
1744 |
Tracker tkr(Tracker::release); |
25946 | 1745 |
res = pd_release_memory(addr, bytes); |
1746 |
if (res) { |
|
1747 |
tkr.record((address)addr, bytes); |
|
1748 |
} |
|
18086
f44cf213a775
8013651: NMT: reserve/release sequence id's in incorrect order due to race
zgu
parents:
18069
diff
changeset
|
1749 |
} else { |
25946 | 1750 |
res = pd_release_memory(addr, bytes); |
13195 | 1751 |
} |
1752 |
return res; |
|
1753 |
} |
|
1754 |
||
41178 | 1755 |
void os::pretouch_memory(void* start, void* end, size_t page_size) { |
1756 |
for (volatile char *p = (char*)start; p < (char*)end; p += page_size) { |
|
28208 | 1757 |
*p = 0; |
1758 |
} |
|
1759 |
} |
|
13195 | 1760 |
|
1761 |
char* os::map_memory(int fd, const char* file_name, size_t file_offset, |
|
1762 |
char *addr, size_t bytes, bool read_only, |
|
1763 |
bool allow_exec) { |
|
1764 |
char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13923
diff
changeset
|
1765 |
if (result != NULL) { |
25946 | 1766 |
MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC); |
13195 | 1767 |
} |
1768 |
return result; |
|
1769 |
} |
|
1770 |
||
1771 |
char* os::remap_memory(int fd, const char* file_name, size_t file_offset, |
|
1772 |
char *addr, size_t bytes, bool read_only, |
|
1773 |
bool allow_exec) { |
|
1774 |
return pd_remap_memory(fd, file_name, file_offset, addr, bytes, |
|
1775 |
read_only, allow_exec); |
|
1776 |
} |
|
1777 |
||
1778 |
bool os::unmap_memory(char *addr, size_t bytes) { |
|
25946 | 1779 |
bool result; |
1780 |
if (MemTracker::tracking_level() > NMT_minimal) { |
|
48865
53427ddce0a0
8194934: NMT: Remove MemTracker::get_virtual_memory_xxx_tracker(), create Tracker in place
zgu
parents:
48859
diff
changeset
|
1781 |
Tracker tkr(Tracker::release); |
25946 | 1782 |
result = pd_unmap_memory(addr, bytes); |
1783 |
if (result) { |
|
1784 |
tkr.record((address)addr, bytes); |
|
1785 |
} |
|
18086
f44cf213a775
8013651: NMT: reserve/release sequence id's in incorrect order due to race
zgu
parents:
18069
diff
changeset
|
1786 |
} else { |
25946 | 1787 |
result = pd_unmap_memory(addr, bytes); |
13195 | 1788 |
} |
1789 |
return result; |
|
1790 |
} |
|
1791 |
||
1792 |
void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { |
|
1793 |
pd_free_memory(addr, bytes, alignment_hint); |
|
1794 |
} |
|
1795 |
||
1796 |
void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { |
|
1797 |
pd_realign_memory(addr, bytes, alignment_hint); |
|
1798 |
} |
|
1799 |
||
40010 | 1800 |
#ifndef _WINDOWS |
18025 | 1801 |
/* try to switch state from state "from" to state "to" |
1802 |
* returns the state set after the method is complete |
|
1803 |
*/ |
|
1804 |
os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from, |
|
1805 |
os::SuspendResume::State to) |
|
1806 |
{ |
|
48955
e22914003cf0
8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents:
48865
diff
changeset
|
1807 |
os::SuspendResume::State result = Atomic::cmpxchg(to, &_state, from); |
18025 | 1808 |
if (result == from) { |
1809 |
// success |
|
1810 |
return to; |
|
1811 |
} |
|
1812 |
return result; |
|
1813 |
} |
|
1814 |
#endif |
|
57998
849acc346a1d
6313903: Thread.sleep(3) might wake up immediately on windows
dholmes
parents:
57903
diff
changeset
|
1815 |
|
58041
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1816 |
// Convenience wrapper around naked_short_sleep to allow for longer sleep |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1817 |
// times. Only for use by non-JavaThreads. |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1818 |
void os::naked_sleep(jlong millis) { |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1819 |
assert(!Thread::current()->is_Java_thread(), "not for use by JavaThreads"); |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1820 |
const jlong limit = 999; |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1821 |
while (millis > limit) { |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1822 |
naked_short_sleep(limit); |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1823 |
millis -= limit; |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1824 |
} |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1825 |
naked_short_sleep(millis); |
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
57998
diff
changeset
|
1826 |
} |