annotate src/share/vm/runtime/hpi.hpp @ 94:0834225a7916

6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction Summary: The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future. Reviewed-by: jmasa
author ysr
date Sun, 16 Mar 2008 21:57:25 -0700
parents a61af66fc99e
children 2a1a77d3458f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 //
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // C++ wrapper to HPI.
a61af66fc99e Initial load
duke
parents:
diff changeset
27 //
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class hpi : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 static GetInterfaceFunc _get_interface;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 static HPI_FileInterface* _file;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 static HPI_SocketInterface* _socket;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static HPI_LibraryInterface* _library;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static HPI_SystemInterface* _system;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 static void initialize_get_interface(vm_calls_t *callbacks);
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Load and initialize everything except sockets.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static jint initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Socket library needs to be lazy intialized because eagerly
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // loading Winsock is known to cause "connect to your ISP"
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // dialog to show up. Or so goes the legend.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 static jint initialize_socket_library();
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // HPI_FileInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
51 static inline char* native_path(char *path);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static inline int file_type(const char *path);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 static inline int open(const char *name, int mode, int perm);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 static inline int close(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static inline jlong lseek(int fd, jlong off, int whence);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static inline int ftruncate(int fd, jlong length);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 static inline int fsync(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static inline int available(int fd, jlong *bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 static inline size_t read(int fd, void *buf, unsigned int nBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static inline size_t write(int fd, const void *buf, unsigned int nBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static inline int fsize(int fd, jlong *size);
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // HPI_SocketInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static inline int socket(int domain, int type, int protocol);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static inline int socket_close(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static inline int socket_shutdown(int fd, int howto);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static inline int recv(int fd, char *buf, int nBytes, int flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static inline int send(int fd, char *buf, int nBytes, int flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 static inline int timeout(int fd, long timeout);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static inline int listen(int fd, int count);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 static inline int connect(int fd, struct sockaddr *him, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 static inline int bind(int fd, struct sockaddr *him, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 static inline int accept(int fd, struct sockaddr *him, int *len);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 static inline int recvfrom(int fd, char *buf, int nbytes, int flags,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 struct sockaddr *from, int *fromlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static inline int get_sock_name(int fd, struct sockaddr *him, int *len);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static inline int sendto(int fd, char *buf, int len, int flags,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 struct sockaddr *to, int tolen);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static inline int socket_available(int fd, jint *pbytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 static inline int get_sock_opt(int fd, int level, int optname,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 char *optval, int* optlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static inline int set_sock_opt(int fd, int level, int optname,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 const char *optval, int optlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 static inline int get_host_name(char* name, int namelen);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static inline struct hostent* get_host_by_addr(const char* name, int len, int type);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 static inline struct hostent* get_host_by_name(char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static inline struct protoent* get_proto_by_name(char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // HPI_LibraryInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
91 static inline void dll_build_name(char *buf, int buf_len, char* path,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 static inline void* dll_load(const char *name, char *ebuf, int ebuflen);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static inline void dll_unload(void *lib);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 static inline void* dll_lookup(void *lib, const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // HPI_SystemInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
98 static inline int lasterror(char *buf, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 };
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Macros that provide inline bodies for the functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 //
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 #define HPIDECL(name, names, intf, func, ret_type, ret_fmt, arg_type, arg_print, arg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
106 inline ret_type hpi::name arg_type { \
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (TraceHPI) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
108 tty->print("hpi::" names "("); \
a61af66fc99e Initial load
duke
parents:
diff changeset
109 tty->print arg_print ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
110 tty->print(") = "); \
a61af66fc99e Initial load
duke
parents:
diff changeset
111 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ret_type result = (*intf->func) arg ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (TraceHPI) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
114 tty->print_cr(ret_fmt, result); \
a61af66fc99e Initial load
duke
parents:
diff changeset
115 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return result; \
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Macro to facilitate moving HPI functionality into the vm.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // See bug 6348631. The only difference between this macro and
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // HPIDECL is that we call a vm method rather than use the HPI
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // transfer vector. Ultimately, we'll replace HPIDECL with
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // VM_HPIDECL for all hpi methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #define VM_HPIDECL(name, names, func, ret_type, ret_fmt, arg_type,arg_print, arg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
125 inline ret_type hpi::name arg_type { \
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (TraceHPI) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
127 tty->print("hpi::" names "("); \
a61af66fc99e Initial load
duke
parents:
diff changeset
128 tty->print arg_print ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
129 tty->print(") = "); \
a61af66fc99e Initial load
duke
parents:
diff changeset
130 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
131 ret_type result = func arg ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (TraceHPI) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
133 tty->print_cr(ret_fmt, result); \
a61af66fc99e Initial load
duke
parents:
diff changeset
134 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return result; \
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 #define HPIDECL_VOID(name, names, intf, func, arg_type, arg_print, arg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
141 inline void hpi::name arg_type { \
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (TraceHPI) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
143 tty->print("hpi::" names "("); \
a61af66fc99e Initial load
duke
parents:
diff changeset
144 tty->print arg_print ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
145 tty->print_cr(") = void"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
147 (*intf->func) arg ; \
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // The macro calls below realize into
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // inline char * hpi::native_path(...) { inlined_body; }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // HPI_FileInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 HPIDECL(native_path, "native_path", _file, NativePath, char *, "%s",
a61af66fc99e Initial load
duke
parents:
diff changeset
158 (char *path),
a61af66fc99e Initial load
duke
parents:
diff changeset
159 ("path = %s", path),
a61af66fc99e Initial load
duke
parents:
diff changeset
160 (path));
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 HPIDECL(file_type, "file_type", _file, FileType, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
163 (const char *path),
a61af66fc99e Initial load
duke
parents:
diff changeset
164 ("path = %s", path),
a61af66fc99e Initial load
duke
parents:
diff changeset
165 (path));
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 HPIDECL(open, "open", _file, Open, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
168 (const char *name, int mode, int perm),
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ("name = %s, mode = %d, perm = %d", name, mode, perm),
a61af66fc99e Initial load
duke
parents:
diff changeset
170 (name, mode, perm));
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 HPIDECL(lseek, "seek", _file, Seek, jlong, "(a jlong)",
a61af66fc99e Initial load
duke
parents:
diff changeset
173 (int fd, jlong off, int whence),
a61af66fc99e Initial load
duke
parents:
diff changeset
174 ("fd = %d, off = (a jlong), whence = %d", fd, /* off, */ whence),
a61af66fc99e Initial load
duke
parents:
diff changeset
175 (fd, off, whence));
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 HPIDECL(ftruncate, "ftruncate", _file, SetLength, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
178 (int fd, jlong length),
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ("fd = %d, length = (a jlong)", fd /*, length */),
a61af66fc99e Initial load
duke
parents:
diff changeset
180 (fd, length));
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 HPIDECL(fsync, "fsync", _file, Sync, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
183 (int fd),
a61af66fc99e Initial load
duke
parents:
diff changeset
184 ("fd = %d", fd),
a61af66fc99e Initial load
duke
parents:
diff changeset
185 (fd));
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 HPIDECL(available, "available", _file, Available, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
188 (int fd, jlong *bytes),
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ("fd = %d, bytes = %p", fd, bytes),
a61af66fc99e Initial load
duke
parents:
diff changeset
190 (fd, bytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 HPIDECL(fsize, "fsize", _file, FileSizeFD, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
193 (int fd, jlong *size),
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ("fd = %d, size = %p", fd, size),
a61af66fc99e Initial load
duke
parents:
diff changeset
195 (fd, size));
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // HPI_LibraryInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
198 HPIDECL_VOID(dll_build_name, "dll_build_name", _library, BuildLibName,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 (char *buf, int buf_len, char *path, const char *name),
a61af66fc99e Initial load
duke
parents:
diff changeset
200 ("buf = %p, buflen = %d, path = %s, name = %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
201 buf, buf_len, path, name),
a61af66fc99e Initial load
duke
parents:
diff changeset
202 (buf, buf_len, path, name));
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 VM_HPIDECL(dll_load, "dll_load", os::dll_load,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 void *, "(void *)%p",
a61af66fc99e Initial load
duke
parents:
diff changeset
206 (const char *name, char *ebuf, int ebuflen),
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ("name = %s, ebuf = %p, ebuflen = %d", name, ebuf, ebuflen),
a61af66fc99e Initial load
duke
parents:
diff changeset
208 (name, ebuf, ebuflen));
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 HPIDECL_VOID(dll_unload, "dll_unload", _library, UnloadLibrary,
a61af66fc99e Initial load
duke
parents:
diff changeset
211 (void *lib),
a61af66fc99e Initial load
duke
parents:
diff changeset
212 ("lib = %p", lib),
a61af66fc99e Initial load
duke
parents:
diff changeset
213 (lib));
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 HPIDECL(dll_lookup, "dll_lookup", _library, FindLibraryEntry, void *, "%p",
a61af66fc99e Initial load
duke
parents:
diff changeset
216 (void *lib, const char *name),
a61af66fc99e Initial load
duke
parents:
diff changeset
217 ("lib = %p, name = %s", lib, name),
a61af66fc99e Initial load
duke
parents:
diff changeset
218 (lib, name));
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // HPI_SystemInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
221 HPIDECL(lasterror, "lasterror", _system, GetLastErrorString, int, "%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
222 (char *buf, int len),
a61af66fc99e Initial load
duke
parents:
diff changeset
223 ("buf = %p, len = %d", buf, len),
a61af66fc99e Initial load
duke
parents:
diff changeset
224 (buf, len));