src/os/windows/vm/os_windows.hpp

Thu, 02 Oct 2008 12:01:08 -0700

author
jmasa
date
Thu, 02 Oct 2008 12:01:08 -0700
changeset 824
ee21eaa8ffe1
parent 435
a61af66fc99e
child 905
ad8c8ca4ab0f
permissions
-rw-r--r--

6660681: Incrementally reserve pages on win server 2003 for better large page affinity
Summary: For windows server 2003 added option to reserve large pages individually.
Reviewed-by: alanb, jcoomes, tonyp, apetrusenko

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

mercurial