src/os/windows/vm/os_windows.hpp

Thu, 20 Mar 2008 09:17:30 -0500

author
kamg
date
Thu, 20 Mar 2008 09:17:30 -0500
changeset 497
cd0742ba123c
parent 435
a61af66fc99e
child 824
ee21eaa8ffe1
permissions
-rw-r--r--

Merge

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;
duke@435 37
duke@435 38 public:
duke@435 39 // Windows-specific interface:
duke@435 40 static void initialize_system_info();
duke@435 41 static void setmode_streams();
duke@435 42
duke@435 43 // Processor info as provided by NT
duke@435 44 static int processor_type() { return _processor_type; }
duke@435 45 // Processor level may not be accurate on non-NT systems
duke@435 46 static int processor_level() {
duke@435 47 assert(is_nt(), "use vm_version instead");
duke@435 48 return _processor_level;
duke@435 49 }
duke@435 50 static julong available_memory();
duke@435 51 static julong physical_memory() { return _physical_memory; }
duke@435 52
duke@435 53 public:
duke@435 54 // Generic interface:
duke@435 55
duke@435 56 // Trace number of created threads
duke@435 57 static intx _os_thread_limit;
duke@435 58 static volatile intx _os_thread_count;
duke@435 59
duke@435 60 // Tells whether the platform is NT or Windown95
duke@435 61 static bool is_nt() { return _is_nt; }
duke@435 62
duke@435 63 // Returns the byte size of a virtual memory page
duke@435 64 static int vm_page_size() { return _vm_page_size; }
duke@435 65
duke@435 66 // Returns the size in bytes of memory blocks which can be allocated.
duke@435 67 static int vm_allocation_granularity() { return _vm_allocation_granularity; }
duke@435 68
duke@435 69 // Read the headers for the executable that started the current process into
duke@435 70 // the structure passed in (see winnt.h).
duke@435 71 static void read_executable_headers(PIMAGE_NT_HEADERS);
duke@435 72
duke@435 73 // Default stack size for the current process.
duke@435 74 static size_t default_stack_size() { return _default_stack_size; }
duke@435 75
duke@435 76 #ifndef _WIN64
duke@435 77 // A wrapper to install a structured exception handler for fast JNI accesors.
duke@435 78 static address fast_jni_accessor_wrapper(BasicType);
duke@435 79 #endif
duke@435 80
duke@435 81 // filter function to ignore faults on serializations page
duke@435 82 static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
duke@435 83 };
duke@435 84
duke@435 85 class PlatformEvent : public CHeapObj {
duke@435 86 private:
duke@435 87 double CachePad [4] ; // increase odds that _Event is sole occupant of cache line
duke@435 88 volatile int _Event ;
duke@435 89 HANDLE _ParkHandle ;
duke@435 90
duke@435 91 public: // TODO-FIXME: make dtor private
duke@435 92 ~PlatformEvent() { guarantee (0, "invariant") ; }
duke@435 93
duke@435 94 public:
duke@435 95 PlatformEvent() {
duke@435 96 _Event = 0 ;
duke@435 97 _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
duke@435 98 guarantee (_ParkHandle != NULL, "invariant") ;
duke@435 99 }
duke@435 100
duke@435 101 // Exercise caution using reset() and fired() - they may require MEMBARs
duke@435 102 void reset() { _Event = 0 ; }
duke@435 103 int fired() { return _Event; }
duke@435 104 void park () ;
duke@435 105 void unpark () ;
duke@435 106 int park (jlong millis) ;
duke@435 107 } ;
duke@435 108
duke@435 109
duke@435 110
duke@435 111 class PlatformParker : public CHeapObj {
duke@435 112 protected:
duke@435 113 HANDLE _ParkEvent ;
duke@435 114
duke@435 115 public:
duke@435 116 ~PlatformParker () { guarantee (0, "invariant") ; }
duke@435 117 PlatformParker () {
duke@435 118 _ParkEvent = CreateEvent (NULL, true, false, NULL) ;
duke@435 119 guarantee (_ParkEvent != NULL, "invariant") ;
duke@435 120 }
duke@435 121
duke@435 122 } ;

mercurial