duke@435: /* duke@435: * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // Win32_OS defines the interface to windows operating systems duke@435: duke@435: class win32 { duke@435: duke@435: protected: duke@435: static int _vm_page_size; duke@435: static int _vm_allocation_granularity; duke@435: static int _processor_type; duke@435: static int _processor_level; duke@435: static julong _physical_memory; duke@435: static size_t _default_stack_size; duke@435: static bool _is_nt; jmasa@824: static bool _is_windows_2003; duke@435: duke@435: public: duke@435: // Windows-specific interface: duke@435: static void initialize_system_info(); duke@435: static void setmode_streams(); duke@435: duke@435: // Processor info as provided by NT duke@435: static int processor_type() { return _processor_type; } duke@435: // Processor level may not be accurate on non-NT systems duke@435: static int processor_level() { duke@435: assert(is_nt(), "use vm_version instead"); duke@435: return _processor_level; duke@435: } duke@435: static julong available_memory(); duke@435: static julong physical_memory() { return _physical_memory; } duke@435: duke@435: public: duke@435: // Generic interface: duke@435: duke@435: // Trace number of created threads duke@435: static intx _os_thread_limit; duke@435: static volatile intx _os_thread_count; duke@435: duke@435: // Tells whether the platform is NT or Windown95 duke@435: static bool is_nt() { return _is_nt; } duke@435: jmasa@824: // Tells whether the platform is Windows 2003 jmasa@824: static bool is_windows_2003() { return _is_windows_2003; } jmasa@824: duke@435: // Returns the byte size of a virtual memory page duke@435: static int vm_page_size() { return _vm_page_size; } duke@435: duke@435: // Returns the size in bytes of memory blocks which can be allocated. duke@435: static int vm_allocation_granularity() { return _vm_allocation_granularity; } duke@435: duke@435: // Read the headers for the executable that started the current process into duke@435: // the structure passed in (see winnt.h). duke@435: static void read_executable_headers(PIMAGE_NT_HEADERS); duke@435: duke@435: // Default stack size for the current process. duke@435: static size_t default_stack_size() { return _default_stack_size; } duke@435: duke@435: #ifndef _WIN64 duke@435: // A wrapper to install a structured exception handler for fast JNI accesors. duke@435: static address fast_jni_accessor_wrapper(BasicType); duke@435: #endif duke@435: duke@435: // filter function to ignore faults on serializations page duke@435: static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e); duke@435: }; duke@435: duke@435: class PlatformEvent : public CHeapObj { duke@435: private: duke@435: double CachePad [4] ; // increase odds that _Event is sole occupant of cache line duke@435: volatile int _Event ; duke@435: HANDLE _ParkHandle ; duke@435: duke@435: public: // TODO-FIXME: make dtor private duke@435: ~PlatformEvent() { guarantee (0, "invariant") ; } duke@435: duke@435: public: duke@435: PlatformEvent() { duke@435: _Event = 0 ; duke@435: _ParkHandle = CreateEvent (NULL, false, false, NULL) ; duke@435: guarantee (_ParkHandle != NULL, "invariant") ; duke@435: } duke@435: duke@435: // Exercise caution using reset() and fired() - they may require MEMBARs duke@435: void reset() { _Event = 0 ; } duke@435: int fired() { return _Event; } duke@435: void park () ; duke@435: void unpark () ; duke@435: int park (jlong millis) ; duke@435: } ; duke@435: duke@435: duke@435: duke@435: class PlatformParker : public CHeapObj { duke@435: protected: duke@435: HANDLE _ParkEvent ; duke@435: duke@435: public: duke@435: ~PlatformParker () { guarantee (0, "invariant") ; } duke@435: PlatformParker () { duke@435: _ParkEvent = CreateEvent (NULL, true, false, NULL) ; duke@435: guarantee (_ParkEvent != NULL, "invariant") ; duke@435: } duke@435: duke@435: } ;