hotspot/src/os/windows/vm/os_windows.hpp
author ctornqvi
Tue, 22 Dec 2015 05:26:55 -0800
changeset 35212 7a6d0993a080
parent 35071 a0910b1d3e0d
child 38290 6b194cfc1557
permissions -rw-r--r--
8048521: Remove obsolete code from os_windows.cpp/hpp Reviewed-by: coleenp, rdurbin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30143
7e99f2b4bae5 8074860: Structured Exception Catcher missing around CreateJavaVM on Windows
stuefe
parents: 27467
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef OS_WINDOWS_VM_OS_WINDOWS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define OS_WINDOWS_VM_OS_WINDOWS_HPP
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// Win32_OS defines the interface to windows operating systems
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
22852
1063026e8cee 8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization.
goetz
parents: 18943
diff changeset
    29
// 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
    30
static bool zero_page_read_protected() { return true; }
1063026e8cee 8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization.
goetz
parents: 18943
diff changeset
    31
25468
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 23527
diff changeset
    32
// File conventions
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 23527
diff changeset
    33
static const char* file_separator() { return "\\"; }
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 23527
diff changeset
    34
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
    35
static const char* path_separator() { return ";"; }
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 23527
diff changeset
    36
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class win32 {
12735
3e2e491f4f69 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 10494
diff changeset
    38
  friend class os;
26682
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    39
  friend unsigned __stdcall java_start(class Thread*);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  static int    _vm_page_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  static int    _vm_allocation_granularity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  static int    _processor_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  static int    _processor_level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  static julong _physical_memory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  static size_t _default_stack_size;
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7397
diff changeset
    48
  static bool   _is_windows_server;
26682
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    49
  static bool   _has_exit_bug;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
12735
3e2e491f4f69 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 10494
diff changeset
    51
  static void print_windows_version(outputStream* st);
3e2e491f4f69 7165755: OS Information much longer on linux than other platforms
nloodin
parents: 10494
diff changeset
    52
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Windows-specific interface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  static void   initialize_system_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  static void   setmode_streams();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Processor info as provided by NT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static int processor_type()  { return _processor_type;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static int processor_level() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    return _processor_level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  static julong available_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  static julong physical_memory() { return _physical_memory; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
10246
adee0cf4c981 7016797: Hotspot: securely/restrictive load dlls and new API for loading system dlls
zgu
parents: 8119
diff changeset
    66
  // 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
    67
  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
    68
26682
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    69
 private:
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    70
  enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE };
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    71
  // Wrapper around _endthreadex(), exit() and _exit()
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    72
  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
    73
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    74
  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
    75
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Generic interface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Trace number of created threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  static          intx  _os_thread_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static volatile intx  _os_thread_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7397
diff changeset
    83
  // Tells whether this is a server version of Windows
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7397
diff changeset
    84
  static bool is_windows_server() { return _is_windows_server; }
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7397
diff changeset
    85
26682
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    86
  // 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
    87
  static bool has_exit_bug() { return _has_exit_bug; }
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
    88
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Returns the byte size of a virtual memory page
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  static int vm_page_size() { return _vm_page_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Returns the size in bytes of memory blocks which can be allocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  static int vm_allocation_granularity() { return _vm_allocation_granularity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Read the headers for the executable that started the current process into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // the structure passed in (see winnt.h).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  static void read_executable_headers(PIMAGE_NT_HEADERS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Default stack size for the current process.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static size_t default_stack_size() { return _default_stack_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 35056
diff changeset
   102
  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
   103
                          struct _EXCEPTION_POINTERS* exceptionInfo,
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 35056
diff changeset
   104
                          address pc, frame* fr);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 35056
diff changeset
   105
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#ifndef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // A wrapper to install a structured exception handler for fast JNI accesors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static address fast_jni_accessor_wrapper(BasicType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // filter function to ignore faults on serializations page
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   113
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   114
  // Fast access to current thread
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   115
protected:
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   116
  static int _thread_ptr_offset;
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   117
private:
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   118
  static void initialize_thread_ptr_offset();
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   119
public:
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   120
  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
   121
    _thread_ptr_offset = offset;
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   122
  }
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 30143
diff changeset
   123
  static inline int get_thread_ptr_offset() { return _thread_ptr_offset; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
18943
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   126
/*
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   127
 * Crash protection for the watcher thread. Wrap the callback
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   128
 * with a __try { call() }
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   129
 * To be able to use this - don't take locks, don't rely on destructors,
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   130
 * don't make OS library calls, don't allocate memory, don't print,
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   131
 * don't call code that could leave the heap / memory in an inconsistent state,
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   132
 * or anything else where we are not in control if we suddenly jump out.
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   133
 */
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   134
class WatcherThreadCrashProtection : public StackObj {
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   135
public:
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   136
  WatcherThreadCrashProtection();
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   137
  bool call(os::CrashProtectionCallback& cb);
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   138
};
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 18683
diff changeset
   139
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12735
diff changeset
   140
class PlatformEvent : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    double CachePad [4] ;   // increase odds that _Event is sole occupant of cache line
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    volatile int _Event ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    HANDLE _ParkHandle ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  public:       // TODO-FIXME: make dtor private
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    ~PlatformEvent() { guarantee (0, "invariant") ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    PlatformEvent() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      _Event   = 0 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
      _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      guarantee (_ParkHandle != NULL, "invariant") ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    // Exercise caution using reset() and fired() - they may require MEMBARs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    void reset() { _Event = 0 ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    int  fired() { return _Event; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    void park () ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    void unpark () ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    int  park (jlong millis) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
} ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12735
diff changeset
   166
class PlatformParker : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    HANDLE _ParkEvent ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    ~PlatformParker () { guarantee (0, "invariant") ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    PlatformParker  () {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      _ParkEvent = CreateEvent (NULL, true, false, NULL) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      guarantee (_ParkEvent != NULL, "invariant") ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
} ;
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   178
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   179
#endif // OS_WINDOWS_VM_OS_WINDOWS_HPP