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