1 #ifdef USE_PRAGMA_IDENT_HDR 2 #pragma ident "@(#)os_windows.hpp 1.55 07/05/05 17:04:46 JVM" 3 #endif 4 /* 5 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23 * CA 95054 USA or visit www.sun.com if you need additional information or 24 * have any questions. 25 * 26 */ 27 28 // Win32_OS defines the interface to windows operating systems 29 30 class win32 { 31 32 protected: 33 static int _vm_page_size; 34 static int _vm_allocation_granularity; 35 static int _processor_type; 36 static int _processor_level; 37 static julong _physical_memory; 38 static size_t _default_stack_size; 39 static bool _is_nt; 40 41 public: 42 // Windows-specific interface: 43 static void initialize_system_info(); 44 static void setmode_streams(); 45 46 // Processor info as provided by NT 47 static int processor_type() { return _processor_type; } 48 // Processor level may not be accurate on non-NT systems 49 static int processor_level() { 50 assert(is_nt(), "use vm_version instead"); 51 return _processor_level; 52 } 53 static julong available_memory(); 54 static julong physical_memory() { return _physical_memory; } 55 56 public: 57 // Generic interface: 58 59 // Trace number of created threads 60 static intx _os_thread_limit; 61 static volatile intx _os_thread_count; 62 63 // Tells whether the platform is NT or Windown95 64 static bool is_nt() { return _is_nt; } 65 66 // Returns the byte size of a virtual memory page 67 static int vm_page_size() { return _vm_page_size; } 68 69 // Returns the size in bytes of memory blocks which can be allocated. 70 static int vm_allocation_granularity() { return _vm_allocation_granularity; } 71 72 // Read the headers for the executable that started the current process into 73 // the structure passed in (see winnt.h). 74 static void read_executable_headers(PIMAGE_NT_HEADERS); 75 76 // Default stack size for the current process. 77 static size_t default_stack_size() { return _default_stack_size; } 78 79 #ifndef _WIN64 80 // A wrapper to install a structured exception handler for fast JNI accesors. 81 static address fast_jni_accessor_wrapper(BasicType); 82 #endif 83 84 // filter function to ignore faults on serializations page 85 static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e); 86 }; 87 88 class PlatformEvent : public CHeapObj { 89 private: 90 double CachePad [4] ; // increase odds that _Event is sole occupant of cache line 91 volatile int _Event ; 92 HANDLE _ParkHandle ; 93 94 public: // TODO-FIXME: make dtor private 95 ~PlatformEvent() { guarantee (0, "invariant") ; } 96 97 public: 98 PlatformEvent() { 99 _Event = 0 ; 100 _ParkHandle = CreateEvent (NULL, false, false, NULL) ; 101 guarantee (_ParkHandle != NULL, "invariant") ; 102 } 103 104 // Exercise caution using reset() and fired() - they may require MEMBARs 105 void reset() { _Event = 0 ; } 106 int fired() { return _Event; } 107 void park () ; 108 void unpark () ; 109 int park (jlong millis) ; 110 } ; 111 112 113 114 class PlatformParker : public CHeapObj { 115 protected: 116 HANDLE _ParkEvent ; 117 118 public: 119 ~PlatformParker () { guarantee (0, "invariant") ; } 120 PlatformParker () { 121 _ParkEvent = CreateEvent (NULL, true, false, NULL) ; 122 guarantee (_ParkEvent != NULL, "invariant") ; 123 } 124 125 } ; 126 127 128 129