author | alanb |
Thu, 21 Mar 2019 08:41:10 +0000 | |
branch | niosocketimpl-branch |
changeset 57275 | 222fa5ed1c91 |
parent 53849 | 46ef4dea49e5 |
child 57738 | 807d192fb7dd |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52894
diff
changeset
|
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:
1623
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
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:
1623
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52894
diff
changeset
|
25 |
#ifndef OS_WINDOWS_OS_WINDOWS_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52894
diff
changeset
|
26 |
#define OS_WINDOWS_OS_WINDOWS_HPP |
1 | 27 |
// Win32_OS defines the interface to windows operating systems |
28 |
||
52894 | 29 |
// strtok_s is the Windows thread-safe equivalent of POSIX strtok_r |
30 |
#define strtok_r strtok_s |
|
31 |
||
53369
55cee96fefec
8215699: -Xlog::file cannot be used with named pipe
hseigel
parents:
53244
diff
changeset
|
32 |
#define S_ISCHR(mode) (((mode) & _S_IFCHR) == _S_IFCHR) |
55cee96fefec
8215699: -Xlog::file cannot be used with named pipe
hseigel
parents:
53244
diff
changeset
|
33 |
#define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO) |
55cee96fefec
8215699: -Xlog::file cannot be used with named pipe
hseigel
parents:
53244
diff
changeset
|
34 |
|
22852
1063026e8cee
8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization.
goetz
parents:
18943
diff
changeset
|
35 |
// Information about the protection of the page at address '0' on this os. |
1063026e8cee
8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization.
goetz
parents:
18943
diff
changeset
|
36 |
static bool zero_page_read_protected() { return true; } |
1063026e8cee
8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization.
goetz
parents:
18943
diff
changeset
|
37 |
|
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
23527
diff
changeset
|
38 |
// File conventions |
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
23527
diff
changeset
|
39 |
static const char* file_separator() { return "\\"; } |
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
23527
diff
changeset
|
40 |
static const char* line_separator() { return "\r\n"; } |
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
23527
diff
changeset
|
41 |
static const char* path_separator() { return ";"; } |
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
23527
diff
changeset
|
42 |
|
1 | 43 |
class win32 { |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
10494
diff
changeset
|
44 |
friend class os; |
38290
6b194cfc1557
8154715: Missing destructor and/or TLS clearing calls for terminating threads
dholmes
parents:
35212
diff
changeset
|
45 |
friend unsigned __stdcall thread_native_entry(class Thread*); |
1 | 46 |
|
47 |
protected: |
|
48 |
static int _vm_page_size; |
|
49 |
static int _vm_allocation_granularity; |
|
50 |
static int _processor_type; |
|
51 |
static int _processor_level; |
|
52 |
static julong _physical_memory; |
|
53 |
static size_t _default_stack_size; |
|
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7397
diff
changeset
|
54 |
static bool _is_windows_server; |
26682
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
55 |
static bool _has_exit_bug; |
1 | 56 |
|
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
10494
diff
changeset
|
57 |
static void print_windows_version(outputStream* st); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
10494
diff
changeset
|
58 |
|
1 | 59 |
public: |
60 |
// Windows-specific interface: |
|
61 |
static void initialize_system_info(); |
|
62 |
static void setmode_streams(); |
|
63 |
||
64 |
// Processor info as provided by NT |
|
65 |
static int processor_type() { return _processor_type; } |
|
66 |
static int processor_level() { |
|
67 |
return _processor_level; |
|
68 |
} |
|
69 |
static julong available_memory(); |
|
70 |
static julong physical_memory() { return _physical_memory; } |
|
71 |
||
10246
adee0cf4c981
7016797: Hotspot: securely/restrictive load dlls and new API for loading system dlls
zgu
parents:
8119
diff
changeset
|
72 |
// load dll from Windows system directory or Windows directory |
adee0cf4c981
7016797: Hotspot: securely/restrictive load dlls and new API for loading system dlls
zgu
parents:
8119
diff
changeset
|
73 |
static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen); |
adee0cf4c981
7016797: Hotspot: securely/restrictive load dlls and new API for loading system dlls
zgu
parents:
8119
diff
changeset
|
74 |
|
26682
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
75 |
private: |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
76 |
enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE }; |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
77 |
// Wrapper around _endthreadex(), exit() and _exit() |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
78 |
static int exit_process_or_thread(Ept what, int exit_code); |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
79 |
|
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
80 |
static void initialize_performance_counter(); |
22891
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
18943
diff
changeset
|
81 |
|
1 | 82 |
public: |
83 |
// Generic interface: |
|
84 |
||
85 |
// Trace number of created threads |
|
86 |
static intx _os_thread_limit; |
|
87 |
static volatile intx _os_thread_count; |
|
88 |
||
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7397
diff
changeset
|
89 |
// Tells whether this is a server version of Windows |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7397
diff
changeset
|
90 |
static bool is_windows_server() { return _is_windows_server; } |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
7397
diff
changeset
|
91 |
|
26682
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
92 |
// Tells whether there can be the race bug during process exit on this platform |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
93 |
static bool has_exit_bug() { return _has_exit_bug; } |
f339669ba825
8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents:
25468
diff
changeset
|
94 |
|
1 | 95 |
// Returns the byte size of a virtual memory page |
96 |
static int vm_page_size() { return _vm_page_size; } |
|
97 |
||
98 |
// Returns the size in bytes of memory blocks which can be allocated. |
|
99 |
static int vm_allocation_granularity() { return _vm_allocation_granularity; } |
|
100 |
||
101 |
// Read the headers for the executable that started the current process into |
|
102 |
// the structure passed in (see winnt.h). |
|
103 |
static void read_executable_headers(PIMAGE_NT_HEADERS); |
|
104 |
||
105 |
// Default stack size for the current process. |
|
106 |
static size_t default_stack_size() { return _default_stack_size; } |
|
107 |
||
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
35056
diff
changeset
|
108 |
static bool get_frame_at_stack_banging_point(JavaThread* thread, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
35056
diff
changeset
|
109 |
struct _EXCEPTION_POINTERS* exceptionInfo, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
35056
diff
changeset
|
110 |
address pc, frame* fr); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
35056
diff
changeset
|
111 |
|
1 | 112 |
#ifndef _WIN64 |
113 |
// A wrapper to install a structured exception handler for fast JNI accesors. |
|
114 |
static address fast_jni_accessor_wrapper(BasicType); |
|
115 |
#endif |
|
116 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
117 |
// Fast access to current thread |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
118 |
protected: |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
119 |
static int _thread_ptr_offset; |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
120 |
private: |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
121 |
static void initialize_thread_ptr_offset(); |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
122 |
public: |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
123 |
static inline void set_thread_ptr_offset(int offset) { |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
124 |
_thread_ptr_offset = offset; |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
125 |
} |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
30143
diff
changeset
|
126 |
static inline int get_thread_ptr_offset() { return _thread_ptr_offset; } |
1 | 127 |
}; |
128 |
||
18943 | 129 |
/* |
130 |
* Crash protection for the watcher thread. Wrap the callback |
|
131 |
* with a __try { call() } |
|
132 |
* To be able to use this - don't take locks, don't rely on destructors, |
|
133 |
* don't make OS library calls, don't allocate memory, don't print, |
|
134 |
* don't call code that could leave the heap / memory in an inconsistent state, |
|
135 |
* or anything else where we are not in control if we suddenly jump out. |
|
136 |
*/ |
|
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
137 |
class ThreadCrashProtection : public StackObj { |
18943 | 138 |
public: |
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
139 |
static bool is_crash_protected(Thread* thr) { |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
140 |
return _crash_protection != NULL && _protected_thread == thr; |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
141 |
} |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
142 |
|
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
143 |
ThreadCrashProtection(); |
18943 | 144 |
bool call(os::CrashProtectionCallback& cb); |
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
145 |
private: |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
146 |
static Thread* _protected_thread; |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
147 |
static ThreadCrashProtection* _crash_protection; |
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46604
diff
changeset
|
148 |
static volatile intptr_t _crash_mux; |
18943 | 149 |
}; |
150 |
||
53849
46ef4dea49e5
8219370: NMT: Move synchronization primitives from mtInternal to mtSynchronizer
zgu
parents:
53646
diff
changeset
|
151 |
class PlatformEvent : public CHeapObj<mtSynchronizer> { |
1 | 152 |
private: |
153 |
double CachePad [4] ; // increase odds that _Event is sole occupant of cache line |
|
154 |
volatile int _Event ; |
|
155 |
HANDLE _ParkHandle ; |
|
156 |
||
157 |
public: // TODO-FIXME: make dtor private |
|
158 |
~PlatformEvent() { guarantee (0, "invariant") ; } |
|
159 |
||
160 |
public: |
|
161 |
PlatformEvent() { |
|
162 |
_Event = 0 ; |
|
163 |
_ParkHandle = CreateEvent (NULL, false, false, NULL) ; |
|
164 |
guarantee (_ParkHandle != NULL, "invariant") ; |
|
165 |
} |
|
166 |
||
167 |
// Exercise caution using reset() and fired() - they may require MEMBARs |
|
168 |
void reset() { _Event = 0 ; } |
|
169 |
int fired() { return _Event; } |
|
170 |
void park () ; |
|
171 |
void unpark () ; |
|
172 |
int park (jlong millis) ; |
|
173 |
} ; |
|
174 |
||
175 |
||
176 |
||
53849
46ef4dea49e5
8219370: NMT: Move synchronization primitives from mtInternal to mtSynchronizer
zgu
parents:
53646
diff
changeset
|
177 |
class PlatformParker : public CHeapObj<mtSynchronizer> { |
1 | 178 |
protected: |
179 |
HANDLE _ParkEvent ; |
|
180 |
||
181 |
public: |
|
182 |
~PlatformParker () { guarantee (0, "invariant") ; } |
|
183 |
PlatformParker () { |
|
184 |
_ParkEvent = CreateEvent (NULL, true, false, NULL) ; |
|
185 |
guarantee (_ParkEvent != NULL, "invariant") ; |
|
186 |
} |
|
187 |
||
188 |
} ; |
|
7397 | 189 |
|
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
190 |
// Platform specific implementation that underpins VM Monitor/Mutex class |
53849
46ef4dea49e5
8219370: NMT: Move synchronization primitives from mtInternal to mtSynchronizer
zgu
parents:
53646
diff
changeset
|
191 |
class PlatformMonitor : public CHeapObj<mtSynchronizer> { |
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
192 |
private: |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
193 |
CRITICAL_SECTION _mutex; // Native mutex for locking |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
194 |
CONDITION_VARIABLE _cond; // Native condition variable for blocking |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
195 |
|
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
196 |
public: |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
197 |
PlatformMonitor(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
198 |
~PlatformMonitor(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
199 |
void lock(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
200 |
void unlock(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
201 |
bool try_lock(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
202 |
int wait(jlong millis); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
203 |
void notify(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
204 |
void notify_all(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
205 |
}; |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53369
diff
changeset
|
206 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52894
diff
changeset
|
207 |
#endif // OS_WINDOWS_OS_WINDOWS_HPP |