Mercurial > hg > graal-compiler
annotate src/os/aix/vm/os_aix.cpp @ 14415:666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
Reviewed-by: kvn
author | simonis |
---|---|
date | Fri, 06 Sep 2013 20:16:09 +0200 |
parents | |
children | 3068270ba476 |
rev | line source |
---|---|
14415
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1 /* |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3 * Copyright 2012, 2013 SAP AG. All rights reserved. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
6 * This code is free software; you can redistribute it and/or modify it |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
7 * under the terms of the GNU General Public License version 2 only, as |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
8 * published by the Free Software Foundation. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
9 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
14 * accompanied this code). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
15 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License version |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
19 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
21 * or visit www.oracle.com if you need additional information or have any |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
22 * questions. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
23 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
24 */ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
25 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
26 // According to the AIX OS doc #pragma alloca must be used |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
27 // with C++ compiler before referencing the function alloca() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
28 #pragma alloca |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
29 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
30 // no precompiled headers |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
31 #include "classfile/classLoader.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
32 #include "classfile/systemDictionary.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
33 #include "classfile/vmSymbols.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
34 #include "code/icBuffer.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
35 #include "code/vtableStubs.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
36 #include "compiler/compileBroker.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
37 #include "interpreter/interpreter.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
38 #include "jvm_aix.h" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
39 #include "libperfstat_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
40 #include "loadlib_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
41 #include "memory/allocation.inline.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
42 #include "memory/filemap.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
43 #include "mutex_aix.inline.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
44 #include "oops/oop.inline.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
45 #include "os_share_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
46 #include "porting_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
47 #include "prims/jniFastGetField.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
48 #include "prims/jvm.h" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
49 #include "prims/jvm_misc.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
50 #include "runtime/arguments.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
51 #include "runtime/extendedPC.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
52 #include "runtime/globals.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
53 #include "runtime/interfaceSupport.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
54 #include "runtime/java.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
55 #include "runtime/javaCalls.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
56 #include "runtime/mutexLocker.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
57 #include "runtime/objectMonitor.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
58 #include "runtime/osThread.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
59 #include "runtime/perfMemory.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
60 #include "runtime/sharedRuntime.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
61 #include "runtime/statSampler.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
62 #include "runtime/stubRoutines.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
63 #include "runtime/threadCritical.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
64 #include "runtime/timer.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
65 #include "services/attachListener.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
66 #include "services/runtimeService.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
67 #include "thread_aix.inline.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
68 #include "utilities/decoder.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
69 #include "utilities/defaultStream.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
70 #include "utilities/events.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
71 #include "utilities/growableArray.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
72 #include "utilities/vmError.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
73 #ifdef TARGET_ARCH_ppc |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
74 # include "assembler_ppc.inline.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
75 # include "nativeInst_ppc.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
76 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
77 #ifdef COMPILER1 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
78 #include "c1/c1_Runtime1.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
79 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
80 #ifdef COMPILER2 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
81 #include "opto/runtime.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
82 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
83 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
84 // put OS-includes here (sorted alphabetically) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
85 #include <errno.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
86 #include <fcntl.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
87 #include <inttypes.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
88 #include <poll.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
89 #include <procinfo.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
90 #include <pthread.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
91 #include <pwd.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
92 #include <semaphore.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
93 #include <signal.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
94 #include <stdint.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
95 #include <stdio.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
96 #include <string.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
97 #include <unistd.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
98 #include <sys/ioctl.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
99 #include <sys/ipc.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
100 #include <sys/mman.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
101 #include <sys/resource.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
102 #include <sys/select.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
103 #include <sys/shm.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
104 #include <sys/socket.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
105 #include <sys/stat.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
106 #include <sys/sysinfo.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
107 #include <sys/systemcfg.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
108 #include <sys/time.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
109 #include <sys/times.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
110 #include <sys/types.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
111 #include <sys/utsname.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
112 #include <sys/vminfo.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
113 #include <sys/wait.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
114 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
115 // Add missing declarations (should be in procinfo.h but isn't until AIX 6.1). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
116 #if !defined(_AIXVERSION_610) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
117 extern "C" { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
118 int getthrds64(pid_t ProcessIdentifier, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
119 struct thrdentry64* ThreadBuffer, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
120 int ThreadSize, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
121 tid64_t* IndexPointer, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
122 int Count); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
123 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
124 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
125 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
126 // Excerpts from systemcfg.h definitions newer than AIX 5.3 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
127 #ifndef PV_7 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
128 # define PV_7 0x200000 // Power PC 7 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
129 # define PV_7_Compat 0x208000 // Power PC 7 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
130 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
131 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
132 #define MAX_PATH (2 * K) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
133 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
134 // for timer info max values which include all bits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
135 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
136 // for multipage initialization error analysis (in 'g_multipage_error') |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
137 #define ERROR_MP_OS_TOO_OLD 100 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
138 #define ERROR_MP_EXTSHM_ACTIVE 101 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
139 #define ERROR_MP_VMGETINFO_FAILED 102 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
140 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
141 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
142 // the semantics in this file are thus that codeptr_t is a *real code ptr* |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
143 // This means that any function taking codeptr_t as arguments will assume |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
144 // a real codeptr and won't handle function descriptors (eg getFuncName), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
145 // whereas functions taking address as args will deal with function |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
146 // descriptors (eg os::dll_address_to_library_name) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
147 typedef unsigned int* codeptr_t; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
148 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
149 // typedefs for stackslots, stack pointers, pointers to op codes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
150 typedef unsigned long stackslot_t; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
151 typedef stackslot_t* stackptr_t; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
152 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
153 // query dimensions of the stack of the calling thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
154 static void query_stack_dimensions(address* p_stack_base, size_t* p_stack_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
155 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
156 // function to check a given stack pointer against given stack limits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
157 inline bool is_valid_stackpointer(stackptr_t sp, stackptr_t stack_base, size_t stack_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
158 if (((uintptr_t)sp) & 0x7) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
159 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
160 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
161 if (sp > stack_base) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
162 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
163 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
164 if (sp < (stackptr_t) ((address)stack_base - stack_size)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
165 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
166 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
167 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
168 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
169 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
170 // returns true if function is a valid codepointer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
171 inline bool is_valid_codepointer(codeptr_t p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
172 if (!p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
173 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
174 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
175 if (((uintptr_t)p) & 0x3) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
176 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
177 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
178 if (LoadedLibraries::find_for_text_address((address)p) == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
179 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
180 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
181 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
182 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
183 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
184 // macro to check a given stack pointer against given stack limits and to die if test fails |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
185 #define CHECK_STACK_PTR(sp, stack_base, stack_size) { \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
186 guarantee(is_valid_stackpointer((stackptr_t)(sp), (stackptr_t)(stack_base), stack_size), "Stack Pointer Invalid"); \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
187 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
188 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
189 // macro to check the current stack pointer against given stacklimits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
190 #define CHECK_CURRENT_STACK_PTR(stack_base, stack_size) { \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
191 address sp; \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
192 sp = os::current_stack_pointer(); \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
193 CHECK_STACK_PTR(sp, stack_base, stack_size); \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
194 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
195 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
196 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
197 // global variables (for a description see os_aix.hpp) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
198 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
199 julong os::Aix::_physical_memory = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
200 pthread_t os::Aix::_main_thread = ((pthread_t)0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
201 int os::Aix::_page_size = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
202 int os::Aix::_on_pase = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
203 int os::Aix::_os_version = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
204 int os::Aix::_stack_page_size = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
205 size_t os::Aix::_shm_default_page_size = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
206 int os::Aix::_can_use_64K_pages = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
207 int os::Aix::_can_use_16M_pages = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
208 int os::Aix::_xpg_sus_mode = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
209 int os::Aix::_extshm = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
210 int os::Aix::_logical_cpus = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
211 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
212 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
213 // local variables |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
214 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
215 static int g_multipage_error = -1; // error analysis for multipage initialization |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
216 static jlong initial_time_count = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
217 static int clock_tics_per_sec = 100; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
218 static sigset_t check_signal_done; // For diagnostics to print a message once (see run_periodic_checks) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
219 static bool check_signals = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
220 static pid_t _initial_pid = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
221 static int SR_signum = SIGUSR2; // Signal used to suspend/resume a thread (must be > SIGSEGV, see 4355769) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
222 static sigset_t SR_sigset; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
223 static pthread_mutex_t dl_mutex; // Used to protect dlsym() calls */ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
224 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
225 julong os::available_memory() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
226 return Aix::available_memory(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
227 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
228 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
229 julong os::Aix::available_memory() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
230 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
231 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
232 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
233 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
234 julong os::physical_memory() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
235 return Aix::physical_memory(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
236 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
237 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
238 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
239 // environment support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
240 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
241 bool os::getenv(const char* name, char* buf, int len) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
242 const char* val = ::getenv(name); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
243 if (val != NULL && strlen(val) < (size_t)len) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
244 strcpy(buf, val); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
245 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
246 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
247 if (len > 0) buf[0] = 0; // return a null string |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
248 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
249 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
250 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
251 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
252 // Return true if user is running as root. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
253 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
254 bool os::have_special_privileges() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
255 static bool init = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
256 static bool privileges = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
257 if (!init) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
258 privileges = (getuid() != geteuid()) || (getgid() != getegid()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
259 init = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
260 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
261 return privileges; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
262 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
263 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
264 // Helper function, emulates disclaim64 using multiple 32bit disclaims |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
265 // because we cannot use disclaim64() on AS/400 and old AIX releases. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
266 static bool my_disclaim64(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
267 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
268 if (size == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
269 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
270 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
271 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
272 // Maximum size 32bit disclaim() accepts. (Theoretically 4GB, but I just do not trust that.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
273 const unsigned int maxDisclaimSize = 0x80000000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
274 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
275 const unsigned int numFullDisclaimsNeeded = (size / maxDisclaimSize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
276 const unsigned int lastDisclaimSize = (size % maxDisclaimSize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
277 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
278 char* p = addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
279 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
280 for (int i = 0; i < numFullDisclaimsNeeded; i ++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
281 if (::disclaim(p, maxDisclaimSize, DISCLAIM_ZEROMEM) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
282 //if (Verbose) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
283 fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + maxDisclaimSize, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
284 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
285 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
286 p += maxDisclaimSize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
287 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
288 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
289 if (lastDisclaimSize > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
290 if (::disclaim(p, lastDisclaimSize, DISCLAIM_ZEROMEM) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
291 //if (Verbose) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
292 fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + lastDisclaimSize, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
293 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
294 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
295 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
296 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
297 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
298 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
299 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
300 // Cpu architecture string |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
301 #if defined(PPC32) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
302 static char cpu_arch[] = "ppc"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
303 #elif defined(PPC64) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
304 static char cpu_arch[] = "ppc64"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
305 #else |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
306 #error Add appropriate cpu_arch setting |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
307 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
308 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
309 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
310 // Given an address, returns the size of the page backing that address. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
311 size_t os::Aix::query_pagesize(void* addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
312 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
313 vm_page_info pi; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
314 pi.addr = (uint64_t)addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
315 if (::vmgetinfo(&pi, VM_PAGE_INFO, sizeof(pi)) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
316 return pi.pagesize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
317 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
318 fprintf(stderr, "vmgetinfo failed to retrieve page size for address %p (errno %d).\n", addr, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
319 assert(false, "vmgetinfo failed to retrieve page size"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
320 return SIZE_4K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
321 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
322 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
323 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
324 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
325 // Returns the kernel thread id of the currently running thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
326 pid_t os::Aix::gettid() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
327 return (pid_t) thread_self(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
328 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
329 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
330 void os::Aix::initialize_system_info() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
331 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
332 // get the number of online(logical) cpus instead of configured |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
333 os::_processor_count = sysconf(_SC_NPROCESSORS_ONLN); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
334 assert(_processor_count > 0, "_processor_count must be > 0"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
335 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
336 // retrieve total physical storage |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
337 os::Aix::meminfo_t mi; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
338 if (!os::Aix::get_meminfo(&mi)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
339 fprintf(stderr, "os::Aix::get_meminfo failed.\n"); fflush(stderr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
340 assert(false, "os::Aix::get_meminfo failed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
341 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
342 _physical_memory = (julong) mi.real_total; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
343 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
344 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
345 // Helper function for tracing page sizes. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
346 static const char* describe_pagesize(size_t pagesize) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
347 switch (pagesize) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
348 case SIZE_4K : return "4K"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
349 case SIZE_64K: return "64K"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
350 case SIZE_16M: return "16M"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
351 case SIZE_16G: return "16G"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
352 default: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
353 assert(false, "surprise"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
354 return "??"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
355 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
356 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
357 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
358 // Retrieve information about multipage size support. Will initialize |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
359 // Aix::_page_size, Aix::_stack_page_size, Aix::_can_use_64K_pages, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
360 // Aix::_can_use_16M_pages. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
361 // Must be called before calling os::large_page_init(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
362 void os::Aix::query_multipage_support() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
363 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
364 guarantee(_page_size == -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
365 _stack_page_size == -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
366 _can_use_64K_pages == -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
367 _can_use_16M_pages == -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
368 g_multipage_error == -1, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
369 "do not call twice"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
370 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
371 _page_size = ::sysconf(_SC_PAGESIZE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
372 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
373 // This really would surprise me. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
374 assert(_page_size == SIZE_4K, "surprise!"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
375 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
376 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
377 // query default data page size (default page size for C-Heap, pthread stacks and .bss). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
378 // Default data page size is influenced either by linker options (-bdatapsize) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
379 // or by environment variable LDR_CNTRL (suboption DATAPSIZE). If none is given, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
380 // default should be 4K. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
381 size_t data_page_size = SIZE_4K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
382 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
383 void* p = ::malloc(SIZE_16M); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
384 data_page_size = os::Aix::query_pagesize(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
385 ::free(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
386 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
387 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
388 // query default shm page size (LDR_CNTRL SHMPSIZE) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
389 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
390 const int shmid = ::shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR | S_IWUSR); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
391 guarantee(shmid != -1, "shmget failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
392 void* p = ::shmat(shmid, NULL, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
393 ::shmctl(shmid, IPC_RMID, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
394 guarantee(p != (void*) -1, "shmat failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
395 _shm_default_page_size = os::Aix::query_pagesize(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
396 ::shmdt(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
397 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
398 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
399 // before querying the stack page size, make sure we are not running as primordial |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
400 // thread (because primordial thread's stack may have different page size than |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
401 // pthread thread stacks). Running a VM on the primordial thread won't work for a |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
402 // number of reasons so we may just as well guarantee it here |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
403 guarantee(!os::Aix::is_primordial_thread(), "Must not be called for primordial thread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
404 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
405 // query stack page size |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
406 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
407 int dummy = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
408 _stack_page_size = os::Aix::query_pagesize(&dummy); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
409 // everything else would surprise me and should be looked into |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
410 guarantee(_stack_page_size == SIZE_4K || _stack_page_size == SIZE_64K, "Wrong page size"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
411 // also, just for completeness: pthread stacks are allocated from C heap, so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
412 // stack page size should be the same as data page size |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
413 guarantee(_stack_page_size == data_page_size, "stack page size should be the same as data page size"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
414 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
415 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
416 // EXTSHM is bad: among other things, it prevents setting pagesize dynamically |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
417 // for system V shm. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
418 if (Aix::extshm()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
419 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
420 fprintf(stderr, "EXTSHM is active - will disable large page support.\n" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
421 "Please make sure EXTSHM is OFF for large page support.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
422 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
423 g_multipage_error = ERROR_MP_EXTSHM_ACTIVE; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
424 _can_use_64K_pages = _can_use_16M_pages = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
425 goto query_multipage_support_end; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
426 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
427 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
428 // now check which page sizes the OS claims it supports, and of those, which actually can be used. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
429 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
430 const int MAX_PAGE_SIZES = 4; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
431 psize_t sizes[MAX_PAGE_SIZES]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
432 const int num_psizes = ::vmgetinfo(sizes, VMINFO_GETPSIZES, MAX_PAGE_SIZES); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
433 if (num_psizes == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
434 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
435 fprintf(stderr, "vmgetinfo(VMINFO_GETPSIZES) failed (errno: %d)\n", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
436 fprintf(stderr, "disabling multipage support.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
437 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
438 g_multipage_error = ERROR_MP_VMGETINFO_FAILED; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
439 _can_use_64K_pages = _can_use_16M_pages = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
440 goto query_multipage_support_end; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
441 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
442 guarantee(num_psizes > 0, "vmgetinfo(.., VMINFO_GETPSIZES, ...) failed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
443 assert(num_psizes <= MAX_PAGE_SIZES, "Surprise! more than 4 page sizes?"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
444 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
445 fprintf(stderr, "vmgetinfo(.., VMINFO_GETPSIZES, ...) returns %d supported page sizes: ", num_psizes); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
446 for (int i = 0; i < num_psizes; i ++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
447 fprintf(stderr, " %s ", describe_pagesize(sizes[i])); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
448 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
449 fprintf(stderr, " .\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
450 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
451 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
452 // Can we use 64K, 16M pages? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
453 _can_use_64K_pages = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
454 _can_use_16M_pages = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
455 for (int i = 0; i < num_psizes; i ++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
456 if (sizes[i] == SIZE_64K) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
457 _can_use_64K_pages = 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
458 } else if (sizes[i] == SIZE_16M) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
459 _can_use_16M_pages = 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
460 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
461 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
462 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
463 if (!_can_use_64K_pages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
464 g_multipage_error = ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
465 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
466 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
467 // Double-check for 16M pages: Even if AIX claims to be able to use 16M pages, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
468 // there must be an actual 16M page pool, and we must run with enough rights. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
469 if (_can_use_16M_pages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
470 const int shmid = ::shmget(IPC_PRIVATE, SIZE_16M, IPC_CREAT | S_IRUSR | S_IWUSR); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
471 guarantee(shmid != -1, "shmget failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
472 struct shmid_ds shm_buf = { 0 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
473 shm_buf.shm_pagesize = SIZE_16M; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
474 const bool can_set_pagesize = ::shmctl(shmid, SHM_PAGESIZE, &shm_buf) == 0 ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
475 const int en = errno; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
476 ::shmctl(shmid, IPC_RMID, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
477 if (!can_set_pagesize) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
478 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
479 fprintf(stderr, "Failed to allocate even one misely 16M page. shmctl failed with %d (%s).\n" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
480 "Will deactivate 16M support.\n", en, strerror(en)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
481 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
482 _can_use_16M_pages = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
483 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
484 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
485 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
486 } // end: check which pages can be used for shared memory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
487 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
488 query_multipage_support_end: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
489 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
490 guarantee(_page_size != -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
491 _stack_page_size != -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
492 _can_use_64K_pages != -1 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
493 _can_use_16M_pages != -1, "Page sizes not properly initialized"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
494 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
495 if (_can_use_64K_pages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
496 g_multipage_error = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
497 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
498 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
499 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
500 fprintf(stderr, "Data page size (C-Heap, bss, etc): %s\n", describe_pagesize(data_page_size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
501 fprintf(stderr, "Thread stack page size (pthread): %s\n", describe_pagesize(_stack_page_size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
502 fprintf(stderr, "Default shared memory page size: %s\n", describe_pagesize(_shm_default_page_size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
503 fprintf(stderr, "Can use 64K pages dynamically with shared meory: %s\n", (_can_use_64K_pages ? "yes" :"no")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
504 fprintf(stderr, "Can use 16M pages dynamically with shared memory: %s\n", (_can_use_16M_pages ? "yes" :"no")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
505 fprintf(stderr, "Multipage error details: %d\n", g_multipage_error); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
506 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
507 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
508 } // end os::Aix::query_multipage_support() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
509 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
510 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
511 // The code for this method was initially derived from the version in os_linux.cpp |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
512 void os::init_system_properties_values() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
513 // The next few definitions allow the code to be verbatim: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
514 #define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n), mtInternal) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
515 #define DEFAULT_LIBPATH "/usr/lib:/lib" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
516 #define EXTENSIONS_DIR "/lib/ext" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
517 #define ENDORSED_DIR "/lib/endorsed" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
518 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
519 // sysclasspath, java_home, dll_dir |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
520 char *home_path; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
521 char *dll_path; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
522 char *pslash; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
523 char buf[MAXPATHLEN]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
524 os::jvm_path(buf, sizeof(buf)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
525 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
526 // Found the full path to libjvm.so. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
527 // Now cut the path to <java_home>/jre if we can. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
528 *(strrchr(buf, '/')) = '\0'; // get rid of /libjvm.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
529 pslash = strrchr(buf, '/'); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
530 if (pslash != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
531 *pslash = '\0'; // get rid of /{client|server|hotspot} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
532 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
533 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
534 dll_path = malloc(strlen(buf) + 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
535 strcpy(dll_path, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
536 Arguments::set_dll_dir(dll_path); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
537 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
538 if (pslash != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
539 pslash = strrchr(buf, '/'); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
540 if (pslash != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
541 *pslash = '\0'; // get rid of /<arch> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
542 pslash = strrchr(buf, '/'); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
543 if (pslash != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
544 *pslash = '\0'; // get rid of /lib |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
545 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
546 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
547 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
548 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
549 home_path = malloc(strlen(buf) + 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
550 strcpy(home_path, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
551 Arguments::set_java_home(home_path); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
552 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
553 if (!set_boot_path('/', ':')) return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
554 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
555 // Where to look for native libraries |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
556 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
557 // On Aix we get the user setting of LIBPATH |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
558 // Eventually, all the library path setting will be done here. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
559 char *ld_library_path; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
560 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
561 // Construct the invariant part of ld_library_path. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
562 ld_library_path = (char *) malloc(sizeof(DEFAULT_LIBPATH)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
563 sprintf(ld_library_path, DEFAULT_LIBPATH); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
564 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
565 // Get the user setting of LIBPATH, and prepended it. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
566 char *v = ::getenv("LIBPATH"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
567 if (v == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
568 v = ""; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
569 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
570 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
571 char *t = ld_library_path; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
572 // That's +1 for the colon and +1 for the trailing '\0' |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
573 ld_library_path = (char *) malloc(strlen(v) + 1 + strlen(t) + 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
574 sprintf(ld_library_path, "%s:%s", v, t); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
575 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
576 Arguments::set_library_path(ld_library_path); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
577 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
578 // Extensions directories |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
579 char* cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(EXTENSIONS_DIR)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
580 sprintf(cbuf, "%s" EXTENSIONS_DIR, Arguments::get_java_home()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
581 Arguments::set_ext_dirs(cbuf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
582 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
583 // Endorsed standards default directory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
584 cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
585 sprintf(cbuf, "%s" ENDORSED_DIR, Arguments::get_java_home()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
586 Arguments::set_endorsed_dirs(cbuf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
587 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
588 #undef malloc |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
589 #undef DEFAULT_LIBPATH |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
590 #undef EXTENSIONS_DIR |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
591 #undef ENDORSED_DIR |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
592 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
593 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
594 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
595 // breakpoint support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
596 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
597 void os::breakpoint() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
598 BREAKPOINT; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
599 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
600 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
601 extern "C" void breakpoint() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
602 // use debugger to set breakpoint here |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
603 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
604 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
605 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
606 // signal support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
607 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
608 debug_only(static bool signal_sets_initialized = false); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
609 static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
610 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
611 bool os::Aix::is_sig_ignored(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
612 struct sigaction oact; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
613 sigaction(sig, (struct sigaction*)NULL, &oact); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
614 void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*, oact.sa_sigaction) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
615 : CAST_FROM_FN_PTR(void*, oact.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
616 if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
617 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
618 else |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
619 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
620 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
621 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
622 void os::Aix::signal_sets_init() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
623 // Should also have an assertion stating we are still single-threaded. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
624 assert(!signal_sets_initialized, "Already initialized"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
625 // Fill in signals that are necessarily unblocked for all threads in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
626 // the VM. Currently, we unblock the following signals: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
627 // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
628 // by -Xrs (=ReduceSignalUsage)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
629 // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
630 // other threads. The "ReduceSignalUsage" boolean tells us not to alter |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
631 // the dispositions or masks wrt these signals. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
632 // Programs embedding the VM that want to use the above signals for their |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
633 // own purposes must, at this time, use the "-Xrs" option to prevent |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
634 // interference with shutdown hooks and BREAK_SIGNAL thread dumping. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
635 // (See bug 4345157, and other related bugs). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
636 // In reality, though, unblocking these signals is really a nop, since |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
637 // these signals are not blocked by default. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
638 sigemptyset(&unblocked_sigs); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
639 sigemptyset(&allowdebug_blocked_sigs); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
640 sigaddset(&unblocked_sigs, SIGILL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
641 sigaddset(&unblocked_sigs, SIGSEGV); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
642 sigaddset(&unblocked_sigs, SIGBUS); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
643 sigaddset(&unblocked_sigs, SIGFPE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
644 sigaddset(&unblocked_sigs, SIGTRAP); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
645 sigaddset(&unblocked_sigs, SIGDANGER); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
646 sigaddset(&unblocked_sigs, SR_signum); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
647 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
648 if (!ReduceSignalUsage) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
649 if (!os::Aix::is_sig_ignored(SHUTDOWN1_SIGNAL)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
650 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
651 sigaddset(&allowdebug_blocked_sigs, SHUTDOWN1_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
652 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
653 if (!os::Aix::is_sig_ignored(SHUTDOWN2_SIGNAL)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
654 sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
655 sigaddset(&allowdebug_blocked_sigs, SHUTDOWN2_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
656 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
657 if (!os::Aix::is_sig_ignored(SHUTDOWN3_SIGNAL)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
658 sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
659 sigaddset(&allowdebug_blocked_sigs, SHUTDOWN3_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
660 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
661 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
662 // Fill in signals that are blocked by all but the VM thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
663 sigemptyset(&vm_sigs); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
664 if (!ReduceSignalUsage) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
665 sigaddset(&vm_sigs, BREAK_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
666 debug_only(signal_sets_initialized = true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
667 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
668 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
669 // These are signals that are unblocked while a thread is running Java. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
670 // (For some reason, they get blocked by default.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
671 sigset_t* os::Aix::unblocked_signals() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
672 assert(signal_sets_initialized, "Not initialized"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
673 return &unblocked_sigs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
674 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
675 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
676 // These are the signals that are blocked while a (non-VM) thread is |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
677 // running Java. Only the VM thread handles these signals. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
678 sigset_t* os::Aix::vm_signals() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
679 assert(signal_sets_initialized, "Not initialized"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
680 return &vm_sigs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
681 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
682 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
683 // These are signals that are blocked during cond_wait to allow debugger in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
684 sigset_t* os::Aix::allowdebug_blocked_signals() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
685 assert(signal_sets_initialized, "Not initialized"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
686 return &allowdebug_blocked_sigs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
687 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
688 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
689 void os::Aix::hotspot_sigmask(Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
690 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
691 //Save caller's signal mask before setting VM signal mask |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
692 sigset_t caller_sigmask; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
693 pthread_sigmask(SIG_BLOCK, NULL, &caller_sigmask); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
694 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
695 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
696 osthread->set_caller_sigmask(caller_sigmask); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
697 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
698 pthread_sigmask(SIG_UNBLOCK, os::Aix::unblocked_signals(), NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
699 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
700 if (!ReduceSignalUsage) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
701 if (thread->is_VM_thread()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
702 // Only the VM thread handles BREAK_SIGNAL ... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
703 pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
704 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
705 // ... all other threads block BREAK_SIGNAL |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
706 pthread_sigmask(SIG_BLOCK, vm_signals(), NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
707 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
708 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
709 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
710 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
711 // retrieve memory information. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
712 // Returns false if something went wrong; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
713 // content of pmi undefined in this case. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
714 bool os::Aix::get_meminfo(meminfo_t* pmi) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
715 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
716 assert(pmi, "get_meminfo: invalid parameter"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
717 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
718 memset(pmi, 0, sizeof(meminfo_t)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
719 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
720 if (os::Aix::on_pase()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
721 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
722 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
723 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
724 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
725 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
726 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
727 // On AIX, I use the (dynamically loaded) perfstat library to retrieve memory statistics |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
728 // See: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
729 // http://publib.boulder.ibm.com/infocenter/systems/index.jsp |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
730 // ?topic=/com.ibm.aix.basetechref/doc/basetrf1/perfstat_memtot.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
731 // http://publib.boulder.ibm.com/infocenter/systems/index.jsp |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
732 // ?topic=/com.ibm.aix.files/doc/aixfiles/libperfstat.h.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
733 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
734 perfstat_memory_total_t psmt; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
735 memset (&psmt, '\0', sizeof(psmt)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
736 const int rc = libperfstat::perfstat_memory_total(NULL, &psmt, sizeof(psmt), 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
737 if (rc == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
738 fprintf(stderr, "perfstat_memory_total() failed (errno=%d)\n", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
739 assert(0, "perfstat_memory_total() failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
740 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
741 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
742 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
743 assert(rc == 1, "perfstat_memory_total() - weird return code"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
744 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
745 // excerpt from |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
746 // http://publib.boulder.ibm.com/infocenter/systems/index.jsp |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
747 // ?topic=/com.ibm.aix.files/doc/aixfiles/libperfstat.h.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
748 // The fields of perfstat_memory_total_t: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
749 // u_longlong_t virt_total Total virtual memory (in 4 KB pages). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
750 // u_longlong_t real_total Total real memory (in 4 KB pages). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
751 // u_longlong_t real_free Free real memory (in 4 KB pages). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
752 // u_longlong_t pgsp_total Total paging space (in 4 KB pages). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
753 // u_longlong_t pgsp_free Free paging space (in 4 KB pages). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
754 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
755 pmi->virt_total = psmt.virt_total * 4096; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
756 pmi->real_total = psmt.real_total * 4096; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
757 pmi->real_free = psmt.real_free * 4096; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
758 pmi->pgsp_total = psmt.pgsp_total * 4096; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
759 pmi->pgsp_free = psmt.pgsp_free * 4096; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
760 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
761 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
762 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
763 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
764 } // end os::Aix::get_meminfo |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
765 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
766 // Retrieve global cpu information. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
767 // Returns false if something went wrong; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
768 // the content of pci is undefined in this case. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
769 bool os::Aix::get_cpuinfo(cpuinfo_t* pci) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
770 assert(pci, "get_cpuinfo: invalid parameter"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
771 memset(pci, 0, sizeof(cpuinfo_t)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
772 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
773 perfstat_cpu_total_t psct; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
774 memset (&psct, '\0', sizeof(psct)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
775 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
776 if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t), 1)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
777 fprintf(stderr, "perfstat_cpu_total() failed (errno=%d)\n", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
778 assert(0, "perfstat_cpu_total() failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
779 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
780 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
781 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
782 // global cpu information |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
783 strcpy (pci->description, psct.description); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
784 pci->processorHZ = psct.processorHZ; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
785 pci->ncpus = psct.ncpus; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
786 os::Aix::_logical_cpus = psct.ncpus; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
787 for (int i = 0; i < 3; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
788 pci->loadavg[i] = (double) psct.loadavg[i] / (1 << SBITS); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
789 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
790 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
791 // get the processor version from _system_configuration |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
792 switch (_system_configuration.version) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
793 case PV_7: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
794 strcpy(pci->version, "Power PC 7"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
795 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
796 case PV_6_1: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
797 strcpy(pci->version, "Power PC 6 DD1.x"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
798 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
799 case PV_6: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
800 strcpy(pci->version, "Power PC 6"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
801 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
802 case PV_5: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
803 strcpy(pci->version, "Power PC 5"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
804 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
805 case PV_5_2: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
806 strcpy(pci->version, "Power PC 5_2"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
807 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
808 case PV_5_3: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
809 strcpy(pci->version, "Power PC 5_3"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
810 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
811 case PV_5_Compat: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
812 strcpy(pci->version, "PV_5_Compat"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
813 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
814 case PV_6_Compat: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
815 strcpy(pci->version, "PV_6_Compat"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
816 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
817 case PV_7_Compat: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
818 strcpy(pci->version, "PV_7_Compat"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
819 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
820 default: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
821 strcpy(pci->version, "unknown"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
822 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
823 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
824 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
825 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
826 } //end os::Aix::get_cpuinfo |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
827 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
828 ////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
829 // detecting pthread library |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
830 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
831 void os::Aix::libpthread_init() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
832 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
833 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
834 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
835 ////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
836 // create new thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
837 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
838 // Thread start routine for all newly created threads |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
839 static void *java_start(Thread *thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
840 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
841 // find out my own stack dimensions |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
842 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
843 // actually, this should do exactly the same as thread->record_stack_base_and_size... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
844 address base = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
845 size_t size = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
846 query_stack_dimensions(&base, &size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
847 thread->set_stack_base(base); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
848 thread->set_stack_size(size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
849 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
850 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
851 // Do some sanity checks. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
852 CHECK_CURRENT_STACK_PTR(thread->stack_base(), thread->stack_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
853 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
854 // Try to randomize the cache line index of hot stack frames. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
855 // This helps when threads of the same stack traces evict each other's |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
856 // cache lines. The threads can be either from the same JVM instance, or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
857 // from different JVM instances. The benefit is especially true for |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
858 // processors with hyperthreading technology. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
859 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
860 static int counter = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
861 int pid = os::current_process_id(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
862 alloca(((pid ^ counter++) & 7) * 128); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
863 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
864 ThreadLocalStorage::set_thread(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
865 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
866 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
867 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
868 // thread_id is kernel thread id (similar to Solaris LWP id) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
869 osthread->set_thread_id(os::Aix::gettid()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
870 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
871 // initialize signal mask for this thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
872 os::Aix::hotspot_sigmask(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
873 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
874 // initialize floating point control register |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
875 os::Aix::init_thread_fpu_state(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
876 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
877 assert(osthread->get_state() == RUNNABLE, "invalid os thread state"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
878 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
879 // call one more level start routine |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
880 thread->run(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
881 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
882 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
883 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
884 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
885 bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
886 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
887 // We want the whole function to be synchronized. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
888 ThreadCritical cs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
889 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
890 assert(thread->osthread() == NULL, "caller responsible"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
891 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
892 // Allocate the OSThread object |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
893 OSThread* osthread = new OSThread(NULL, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
894 if (osthread == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
895 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
896 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
897 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
898 // set the correct thread state |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
899 osthread->set_thread_type(thr_type); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
900 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
901 // Initial state is ALLOCATED but not INITIALIZED |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
902 osthread->set_state(ALLOCATED); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
903 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
904 thread->set_osthread(osthread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
905 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
906 // init thread attributes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
907 pthread_attr_t attr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
908 pthread_attr_init(&attr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
909 guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
910 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
911 // Make sure we run in 1:1 kernel-user-thread mode. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
912 if (os::Aix::on_aix()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
913 guarantee(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0, "???"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
914 guarantee(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0, "???"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
915 } // end: aix |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
916 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
917 // Start in suspended state, and in os::thread_start, wake the thread up. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
918 guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
919 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
920 // calculate stack size if it's not specified by caller |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
921 if (os::Aix::supports_variable_stack_size()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
922 if (stack_size == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
923 stack_size = os::Aix::default_stack_size(thr_type); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
924 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
925 switch (thr_type) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
926 case os::java_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
927 // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
928 assert(JavaThread::stack_size_at_create() > 0, "this should be set"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
929 stack_size = JavaThread::stack_size_at_create(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
930 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
931 case os::compiler_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
932 if (CompilerThreadStackSize > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
933 stack_size = (size_t)(CompilerThreadStackSize * K); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
934 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
935 } // else fall through: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
936 // use VMThreadStackSize if CompilerThreadStackSize is not defined |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
937 case os::vm_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
938 case os::pgc_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
939 case os::cgc_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
940 case os::watcher_thread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
941 if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
942 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
943 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
944 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
945 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
946 stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
947 pthread_attr_setstacksize(&attr, stack_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
948 } //else let thread_create() pick the default value (96 K on AIX) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
949 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
950 pthread_t tid; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
951 int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
952 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
953 pthread_attr_destroy(&attr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
954 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
955 if (ret != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
956 if (PrintMiscellaneous && (Verbose || WizardMode)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
957 perror("pthread_create()"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
958 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
959 // Need to clean up stuff we've allocated so far |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
960 thread->set_osthread(NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
961 delete osthread; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
962 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
963 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
964 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
965 // Store pthread info into the OSThread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
966 osthread->set_pthread_id(tid); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
967 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
968 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
969 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
970 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
971 ///////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
972 // attach existing thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
973 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
974 // bootstrap the main thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
975 bool os::create_main_thread(JavaThread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
976 assert(os::Aix::_main_thread == pthread_self(), "should be called inside main thread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
977 return create_attached_thread(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
978 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
979 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
980 bool os::create_attached_thread(JavaThread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
981 #ifdef ASSERT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
982 thread->verify_not_published(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
983 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
984 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
985 // Allocate the OSThread object |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
986 OSThread* osthread = new OSThread(NULL, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
987 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
988 if (osthread == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
989 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
990 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
991 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
992 // Store pthread info into the OSThread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
993 osthread->set_thread_id(os::Aix::gettid()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
994 osthread->set_pthread_id(::pthread_self()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
995 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
996 // initialize floating point control register |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
997 os::Aix::init_thread_fpu_state(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
998 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
999 // some sanity checks |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1000 CHECK_CURRENT_STACK_PTR(thread->stack_base(), thread->stack_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1001 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1002 // Initial thread state is RUNNABLE |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1003 osthread->set_state(RUNNABLE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1004 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1005 thread->set_osthread(osthread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1006 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1007 if (UseNUMA) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1008 int lgrp_id = os::numa_get_group_id(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1009 if (lgrp_id != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1010 thread->set_lgrp_id(lgrp_id); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1011 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1012 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1013 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1014 // initialize signal mask for this thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1015 // and save the caller's signal mask |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1016 os::Aix::hotspot_sigmask(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1017 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1018 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1019 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1020 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1021 void os::pd_start_thread(Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1022 int status = pthread_continue_np(thread->osthread()->pthread_id()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1023 assert(status == 0, "thr_continue failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1024 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1025 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1026 // Free OS resources related to the OSThread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1027 void os::free_thread(OSThread* osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1028 assert(osthread != NULL, "osthread not set"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1029 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1030 if (Thread::current()->osthread() == osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1031 // Restore caller's signal mask |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1032 sigset_t sigmask = osthread->caller_sigmask(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1033 pthread_sigmask(SIG_SETMASK, &sigmask, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1034 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1035 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1036 delete osthread; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1037 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1038 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1039 ////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1040 // thread local storage |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1041 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1042 int os::allocate_thread_local_storage() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1043 pthread_key_t key; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1044 int rslt = pthread_key_create(&key, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1045 assert(rslt == 0, "cannot allocate thread local storage"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1046 return (int)key; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1047 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1048 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1049 // Note: This is currently not used by VM, as we don't destroy TLS key |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1050 // on VM exit. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1051 void os::free_thread_local_storage(int index) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1052 int rslt = pthread_key_delete((pthread_key_t)index); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1053 assert(rslt == 0, "invalid index"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1054 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1055 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1056 void os::thread_local_storage_at_put(int index, void* value) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1057 int rslt = pthread_setspecific((pthread_key_t)index, value); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1058 assert(rslt == 0, "pthread_setspecific failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1059 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1060 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1061 extern "C" Thread* get_thread() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1062 return ThreadLocalStorage::thread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1063 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1064 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1065 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1066 // time support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1067 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1068 // Time since start-up in seconds to a fine granularity. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1069 // Used by VMSelfDestructTimer and the MemProfiler. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1070 double os::elapsedTime() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1071 return (double)(os::elapsed_counter()) * 0.000001; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1072 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1073 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1074 jlong os::elapsed_counter() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1075 timeval time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1076 int status = gettimeofday(&time, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1077 return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1078 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1079 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1080 jlong os::elapsed_frequency() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1081 return (1000 * 1000); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1082 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1083 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1084 // For now, we say that linux does not support vtime. I have no idea |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1085 // whether it can actually be made to (DLD, 9/13/05). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1086 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1087 bool os::supports_vtime() { return false; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1088 bool os::enable_vtime() { return false; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1089 bool os::vtime_enabled() { return false; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1090 double os::elapsedVTime() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1091 // better than nothing, but not much |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1092 return elapsedTime(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1093 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1094 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1095 jlong os::javaTimeMillis() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1096 timeval time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1097 int status = gettimeofday(&time, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1098 assert(status != -1, "aix error at gettimeofday()"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1099 return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1100 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1101 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1102 // We need to manually declare mread_real_time, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1103 // because IBM didn't provide a prototype in time.h. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1104 // (they probably only ever tested in C, not C++) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1105 extern "C" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1106 int mread_real_time(timebasestruct_t *t, size_t size_of_timebasestruct_t); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1107 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1108 jlong os::javaTimeNanos() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1109 if (os::Aix::on_pase()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1110 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1111 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1112 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1113 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1114 // On AIX use the precision of processors real time clock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1115 // or time base registers. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1116 timebasestruct_t time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1117 int rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1118 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1119 // If the CPU has a time register, it will be used and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1120 // we have to convert to real time first. After convertion we have following data: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1121 // time.tb_high [seconds since 00:00:00 UTC on 1.1.1970] |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1122 // time.tb_low [nanoseconds after the last full second above] |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1123 // We better use mread_real_time here instead of read_real_time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1124 // to ensure that we will get a monotonic increasing time. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1125 if (mread_real_time(&time, TIMEBASE_SZ) != RTC_POWER) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1126 rc = time_base_to_time(&time, TIMEBASE_SZ); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1127 assert(rc != -1, "aix error at time_base_to_time()"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1128 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1129 return jlong(time.tb_high) * (1000 * 1000 * 1000) + jlong(time.tb_low); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1130 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1131 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1132 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1133 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1134 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1135 // gettimeofday - based on time in seconds since the Epoch thus does not wrap |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1136 info_ptr->max_value = ALL_64_BITS; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1137 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1138 // gettimeofday is a real time clock so it skips |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1139 info_ptr->may_skip_backward = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1140 info_ptr->may_skip_forward = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1141 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1142 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1143 info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1144 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1145 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1146 // Return the real, user, and system times in seconds from an |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1147 // arbitrary fixed point in the past. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1148 bool os::getTimesSecs(double* process_real_time, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1149 double* process_user_time, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1150 double* process_system_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1151 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1152 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1153 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1154 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1155 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1156 char * os::local_time_string(char *buf, size_t buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1157 struct tm t; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1158 time_t long_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1159 time(&long_time); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1160 localtime_r(&long_time, &t); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1161 jio_snprintf(buf, buflen, "%d-%02d-%02d %02d:%02d:%02d", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1162 t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1163 t.tm_hour, t.tm_min, t.tm_sec); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1164 return buf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1165 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1166 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1167 struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1168 return localtime_r(clock, res); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1169 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1170 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1171 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1172 // runtime exit support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1173 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1174 // Note: os::shutdown() might be called very early during initialization, or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1175 // called from signal handler. Before adding something to os::shutdown(), make |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1176 // sure it is async-safe and can handle partially initialized VM. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1177 void os::shutdown() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1178 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1179 // allow PerfMemory to attempt cleanup of any persistent resources |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1180 perfMemory_exit(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1181 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1182 // needs to remove object in file system |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1183 AttachListener::abort(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1184 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1185 // flush buffered output, finish log files |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1186 ostream_abort(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1187 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1188 // Check for abort hook |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1189 abort_hook_t abort_hook = Arguments::abort_hook(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1190 if (abort_hook != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1191 abort_hook(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1192 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1193 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1194 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1195 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1196 // Note: os::abort() might be called very early during initialization, or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1197 // called from signal handler. Before adding something to os::abort(), make |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1198 // sure it is async-safe and can handle partially initialized VM. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1199 void os::abort(bool dump_core) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1200 os::shutdown(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1201 if (dump_core) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1202 #ifndef PRODUCT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1203 fdStream out(defaultStream::output_fd()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1204 out.print_raw("Current thread is "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1205 char buf[16]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1206 jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1207 out.print_raw_cr(buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1208 out.print_raw_cr("Dumping core ..."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1209 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1210 ::abort(); // dump core |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1211 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1212 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1213 ::exit(1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1214 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1215 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1216 // Die immediately, no exit hook, no abort hook, no cleanup. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1217 void os::die() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1218 ::abort(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1219 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1220 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1221 // Unused on Aix for now. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1222 void os::set_error_file(const char *logfile) {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1223 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1224 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1225 // This method is a copy of JDK's sysGetLastErrorString |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1226 // from src/solaris/hpi/src/system_md.c |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1227 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1228 size_t os::lasterror(char *buf, size_t len) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1229 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1230 if (errno == 0) return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1231 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1232 const char *s = ::strerror(errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1233 size_t n = ::strlen(s); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1234 if (n >= len) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1235 n = len - 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1236 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1237 ::strncpy(buf, s, n); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1238 buf[n] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1239 return n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1240 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1241 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1242 intx os::current_thread_id() { return (intx)pthread_self(); } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1243 int os::current_process_id() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1244 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1245 // This implementation returns a unique pid, the pid of the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1246 // launcher thread that starts the vm 'process'. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1247 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1248 // Under POSIX, getpid() returns the same pid as the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1249 // launcher thread rather than a unique pid per thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1250 // Use gettid() if you want the old pre NPTL behaviour. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1251 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1252 // if you are looking for the result of a call to getpid() that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1253 // returns a unique pid for the calling thread, then look at the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1254 // OSThread::thread_id() method in osThread_linux.hpp file |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1255 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1256 return (int)(_initial_pid ? _initial_pid : getpid()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1257 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1258 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1259 // DLL functions |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1260 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1261 const char* os::dll_file_extension() { return ".so"; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1262 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1263 // This must be hard coded because it's the system's temporary |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1264 // directory not the java application's temp directory, ala java.io.tmpdir. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1265 const char* os::get_temp_directory() { return "/tmp"; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1266 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1267 static bool file_exists(const char* filename) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1268 struct stat statbuf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1269 if (filename == NULL || strlen(filename) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1270 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1271 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1272 return os::stat(filename, &statbuf) == 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1273 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1274 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1275 bool os::dll_build_name(char* buffer, size_t buflen, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1276 const char* pname, const char* fname) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1277 bool retval = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1278 // Copied from libhpi |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1279 const size_t pnamelen = pname ? strlen(pname) : 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1280 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1281 // Return error on buffer overflow. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1282 if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1283 *buffer = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1284 return retval; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1285 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1286 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1287 if (pnamelen == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1288 snprintf(buffer, buflen, "lib%s.so", fname); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1289 retval = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1290 } else if (strchr(pname, *os::path_separator()) != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1291 int n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1292 char** pelements = split_path(pname, &n); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1293 for (int i = 0; i < n; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1294 // Really shouldn't be NULL, but check can't hurt |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1295 if (pelements[i] == NULL || strlen(pelements[i]) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1296 continue; // skip the empty path values |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1297 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1298 snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1299 if (file_exists(buffer)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1300 retval = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1301 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1302 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1303 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1304 // release the storage |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1305 for (int i = 0; i < n; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1306 if (pelements[i] != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1307 FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1308 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1309 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1310 if (pelements != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1311 FREE_C_HEAP_ARRAY(char*, pelements, mtInternal); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1312 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1313 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1314 snprintf(buffer, buflen, "%s/lib%s.so", pname, fname); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1315 retval = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1316 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1317 return retval; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1318 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1319 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1320 // Check if addr is inside libjvm.so. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1321 bool os::address_is_in_vm(address addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1322 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1323 // Input could be a real pc or a function pointer literal. The latter |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1324 // would be a function descriptor residing in the data segment of a module. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1325 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1326 const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1327 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1328 if (strcmp(lib->get_shortname(), "libjvm.so") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1329 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1330 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1331 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1332 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1333 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1334 lib = LoadedLibraries::find_for_data_address(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1335 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1336 if (strcmp(lib->get_shortname(), "libjvm.so") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1337 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1338 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1339 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1340 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1341 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1342 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1343 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1344 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1345 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1346 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1347 // Resolve an AIX function descriptor literal to a code pointer. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1348 // If the input is a valid code pointer to a text segment of a loaded module, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1349 // it is returned unchanged. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1350 // If the input is a valid AIX function descriptor, it is resolved to the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1351 // code entry point. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1352 // If the input is neither a valid function descriptor nor a valid code pointer, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1353 // NULL is returned. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1354 static address resolve_function_descriptor_to_code_pointer(address p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1355 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1356 const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1357 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1358 // its a real code pointer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1359 return p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1360 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1361 lib = LoadedLibraries::find_for_data_address(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1362 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1363 // pointer to data segment, potential function descriptor |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1364 address code_entry = (address)(((FunctionDescriptor*)p)->entry()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1365 if (LoadedLibraries::find_for_text_address(code_entry)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1366 // Its a function descriptor |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1367 return code_entry; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1368 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1369 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1370 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1371 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1372 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1373 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1374 bool os::dll_address_to_function_name(address addr, char *buf, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1375 int buflen, int *offset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1376 if (offset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1377 *offset = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1378 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1379 if (buf) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1380 buf[0] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1381 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1382 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1383 // Resolve function ptr literals first. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1384 addr = resolve_function_descriptor_to_code_pointer(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1385 if (!addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1386 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1387 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1388 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1389 // Go through Decoder::decode to call getFuncName which reads the name from the traceback table. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1390 return Decoder::decode(addr, buf, buflen, offset); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1391 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1392 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1393 static int getModuleName(codeptr_t pc, // [in] program counter |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1394 char* p_name, size_t namelen, // [out] optional: function name |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1395 char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1396 ) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1397 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1398 // initialize output parameters |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1399 if (p_name && namelen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1400 *p_name = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1401 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1402 if (p_errmsg && errmsglen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1403 *p_errmsg = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1404 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1405 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1406 const LoadedLibraryModule* const lib = LoadedLibraries::find_for_text_address((address)pc); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1407 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1408 if (p_name && namelen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1409 sprintf(p_name, "%.*s", namelen, lib->get_shortname()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1410 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1411 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1412 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1413 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1414 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1415 fprintf(stderr, "pc outside any module"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1416 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1417 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1418 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1419 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1420 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1421 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1422 bool os::dll_address_to_library_name(address addr, char* buf, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1423 int buflen, int* offset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1424 if (offset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1425 *offset = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1426 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1427 if (buf) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1428 buf[0] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1429 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1430 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1431 // Resolve function ptr literals first. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1432 addr = resolve_function_descriptor_to_code_pointer(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1433 if (!addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1434 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1435 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1436 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1437 if (::getModuleName((codeptr_t) addr, buf, buflen, 0, 0) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1438 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1439 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1440 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1441 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1442 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1443 // Loads .dll/.so and in case of error it checks if .dll/.so was built |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1444 // for the same architecture as Hotspot is running on |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1445 void *os::dll_load(const char *filename, char *ebuf, int ebuflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1446 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1447 if (ebuf && ebuflen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1448 ebuf[0] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1449 ebuf[ebuflen - 1] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1450 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1451 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1452 if (!filename || strlen(filename) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1453 ::strncpy(ebuf, "dll_load: empty filename specified", ebuflen - 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1454 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1455 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1456 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1457 // RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1458 void * result= ::dlopen(filename, RTLD_LAZY); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1459 if (result != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1460 // Reload dll cache. Don't do this in signal handling. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1461 LoadedLibraries::reload(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1462 return result; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1463 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1464 // error analysis when dlopen fails |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1465 const char* const error_report = ::dlerror(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1466 if (error_report && ebuf && ebuflen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1467 snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1468 filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1469 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1470 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1471 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1472 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1473 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1474 // Glibc-2.0 libdl is not MT safe. If you are building with any glibc, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1475 // chances are you might want to run the generated bits against glibc-2.0 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1476 // libdl.so, so always use locking for any version of glibc. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1477 void* os::dll_lookup(void* handle, const char* name) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1478 pthread_mutex_lock(&dl_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1479 void* res = dlsym(handle, name); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1480 pthread_mutex_unlock(&dl_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1481 return res; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1482 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1483 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1484 void os::print_dll_info(outputStream *st) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1485 st->print_cr("Dynamic libraries:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1486 LoadedLibraries::print(st); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1487 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1488 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1489 void os::print_os_info(outputStream* st) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1490 st->print("OS:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1491 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1492 st->print("uname:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1493 struct utsname name; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1494 uname(&name); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1495 st->print(name.sysname); st->print(" "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1496 st->print(name.nodename); st->print(" "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1497 st->print(name.release); st->print(" "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1498 st->print(name.version); st->print(" "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1499 st->print(name.machine); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1500 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1501 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1502 // rlimit |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1503 st->print("rlimit:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1504 struct rlimit rlim; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1505 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1506 st->print(" STACK "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1507 getrlimit(RLIMIT_STACK, &rlim); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1508 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1509 else st->print("%uk", rlim.rlim_cur >> 10); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1510 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1511 st->print(", CORE "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1512 getrlimit(RLIMIT_CORE, &rlim); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1513 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1514 else st->print("%uk", rlim.rlim_cur >> 10); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1515 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1516 st->print(", NPROC "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1517 st->print("%d", sysconf(_SC_CHILD_MAX)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1518 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1519 st->print(", NOFILE "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1520 getrlimit(RLIMIT_NOFILE, &rlim); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1521 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1522 else st->print("%d", rlim.rlim_cur); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1523 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1524 st->print(", AS "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1525 getrlimit(RLIMIT_AS, &rlim); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1526 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1527 else st->print("%uk", rlim.rlim_cur >> 10); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1528 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1529 // Print limits on DATA, because it limits the C-heap. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1530 st->print(", DATA "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1531 getrlimit(RLIMIT_DATA, &rlim); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1532 if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1533 else st->print("%uk", rlim.rlim_cur >> 10); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1534 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1535 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1536 // load average |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1537 st->print("load average:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1538 double loadavg[3] = {-1.L, -1.L, -1.L}; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1539 os::loadavg(loadavg, 3); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1540 st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1541 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1542 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1543 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1544 void os::print_memory_info(outputStream* st) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1545 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1546 st->print_cr("Memory:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1547 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1548 st->print_cr(" default page size: %s", describe_pagesize(os::vm_page_size())); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1549 st->print_cr(" default stack page size: %s", describe_pagesize(os::vm_page_size())); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1550 st->print_cr(" default shm page size: %s", describe_pagesize(os::Aix::shm_default_page_size())); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1551 st->print_cr(" can use 64K pages dynamically: %s", (os::Aix::can_use_64K_pages() ? "yes" :"no")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1552 st->print_cr(" can use 16M pages dynamically: %s", (os::Aix::can_use_16M_pages() ? "yes" :"no")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1553 if (g_multipage_error != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1554 st->print_cr(" multipage error: %d", g_multipage_error); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1555 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1556 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1557 // print out LDR_CNTRL because it affects the default page sizes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1558 const char* const ldr_cntrl = ::getenv("LDR_CNTRL"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1559 st->print_cr(" LDR_CNTRL=%s.", ldr_cntrl ? ldr_cntrl : "<unset>"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1560 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1561 const char* const extshm = ::getenv("EXTSHM"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1562 st->print_cr(" EXTSHM=%s.", extshm ? extshm : "<unset>"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1563 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1564 // Call os::Aix::get_meminfo() to retrieve memory statistics. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1565 os::Aix::meminfo_t mi; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1566 if (os::Aix::get_meminfo(&mi)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1567 char buffer[256]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1568 if (os::Aix::on_aix()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1569 jio_snprintf(buffer, sizeof(buffer), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1570 " physical total : %llu\n" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1571 " physical free : %llu\n" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1572 " swap total : %llu\n" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1573 " swap free : %llu\n", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1574 mi.real_total, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1575 mi.real_free, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1576 mi.pgsp_total, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1577 mi.pgsp_free); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1578 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1579 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1580 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1581 st->print_raw(buffer); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1582 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1583 st->print_cr(" (no more information available)"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1584 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1585 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1586 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1587 void os::pd_print_cpu_info(outputStream* st) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1588 // cpu |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1589 st->print("CPU:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1590 st->print("total %d", os::processor_count()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1591 // It's not safe to query number of active processors after crash |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1592 // st->print("(active %d)", os::active_processor_count()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1593 st->print(" %s", VM_Version::cpu_features()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1594 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1595 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1596 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1597 void os::print_siginfo(outputStream* st, void* siginfo) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1598 // Use common posix version. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1599 os::Posix::print_siginfo_brief(st, (const siginfo_t*) siginfo); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1600 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1601 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1602 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1603 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1604 static void print_signal_handler(outputStream* st, int sig, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1605 char* buf, size_t buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1606 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1607 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1608 st->print_cr("Signal Handlers:"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1609 print_signal_handler(st, SIGSEGV, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1610 print_signal_handler(st, SIGBUS , buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1611 print_signal_handler(st, SIGFPE , buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1612 print_signal_handler(st, SIGPIPE, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1613 print_signal_handler(st, SIGXFSZ, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1614 print_signal_handler(st, SIGILL , buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1615 print_signal_handler(st, INTERRUPT_SIGNAL, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1616 print_signal_handler(st, SR_signum, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1617 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1618 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1619 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1620 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1621 print_signal_handler(st, SIGTRAP, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1622 print_signal_handler(st, SIGDANGER, buf, buflen); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1623 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1624 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1625 static char saved_jvm_path[MAXPATHLEN] = {0}; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1626 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1627 // Find the full path to the current module, libjvm.so or libjvm_g.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1628 void os::jvm_path(char *buf, jint buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1629 // Error checking. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1630 if (buflen < MAXPATHLEN) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1631 assert(false, "must use a large-enough buffer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1632 buf[0] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1633 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1634 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1635 // Lazy resolve the path to current module. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1636 if (saved_jvm_path[0] != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1637 strcpy(buf, saved_jvm_path); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1638 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1639 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1640 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1641 Dl_info dlinfo; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1642 int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1643 assert(ret != 0, "cannot locate libjvm"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1644 char* rp = realpath((char *)dlinfo.dli_fname, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1645 assert(rp != NULL, "error in realpath(): maybe the 'path' argument is too long?"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1646 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1647 strcpy(saved_jvm_path, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1648 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1649 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1650 void os::print_jni_name_prefix_on(outputStream* st, int args_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1651 // no prefix required, not even "_" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1652 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1653 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1654 void os::print_jni_name_suffix_on(outputStream* st, int args_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1655 // no suffix required |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1656 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1657 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1658 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1659 // sun.misc.Signal support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1660 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1661 static volatile jint sigint_count = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1662 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1663 static void |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1664 UserHandler(int sig, void *siginfo, void *context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1665 // 4511530 - sem_post is serialized and handled by the manager thread. When |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1666 // the program is interrupted by Ctrl-C, SIGINT is sent to every thread. We |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1667 // don't want to flood the manager thread with sem_post requests. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1668 if (sig == SIGINT && Atomic::add(1, &sigint_count) > 1) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1669 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1670 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1671 // Ctrl-C is pressed during error reporting, likely because the error |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1672 // handler fails to abort. Let VM die immediately. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1673 if (sig == SIGINT && is_error_reported()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1674 os::die(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1675 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1676 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1677 os::signal_notify(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1678 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1679 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1680 void* os::user_handler() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1681 return CAST_FROM_FN_PTR(void*, UserHandler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1682 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1683 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1684 extern "C" { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1685 typedef void (*sa_handler_t)(int); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1686 typedef void (*sa_sigaction_t)(int, siginfo_t *, void *); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1687 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1688 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1689 void* os::signal(int signal_number, void* handler) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1690 struct sigaction sigAct, oldSigAct; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1691 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1692 sigfillset(&(sigAct.sa_mask)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1693 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1694 // Do not block out synchronous signals in the signal handler. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1695 // Blocking synchronous signals only makes sense if you can really |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1696 // be sure that those signals won't happen during signal handling, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1697 // when the blocking applies. Normal signal handlers are lean and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1698 // do not cause signals. But our signal handlers tend to be "risky" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1699 // - secondary SIGSEGV, SIGILL, SIGBUS' may and do happen. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1700 // On AIX, PASE there was a case where a SIGSEGV happened, followed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1701 // by a SIGILL, which was blocked due to the signal mask. The process |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1702 // just hung forever. Better to crash from a secondary signal than to hang. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1703 sigdelset(&(sigAct.sa_mask), SIGSEGV); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1704 sigdelset(&(sigAct.sa_mask), SIGBUS); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1705 sigdelset(&(sigAct.sa_mask), SIGILL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1706 sigdelset(&(sigAct.sa_mask), SIGFPE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1707 sigdelset(&(sigAct.sa_mask), SIGTRAP); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1708 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1709 sigAct.sa_flags = SA_RESTART|SA_SIGINFO; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1710 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1711 sigAct.sa_handler = CAST_TO_FN_PTR(sa_handler_t, handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1712 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1713 if (sigaction(signal_number, &sigAct, &oldSigAct)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1714 // -1 means registration failed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1715 return (void *)-1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1716 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1717 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1718 return CAST_FROM_FN_PTR(void*, oldSigAct.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1719 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1720 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1721 void os::signal_raise(int signal_number) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1722 ::raise(signal_number); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1723 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1724 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1725 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1726 // The following code is moved from os.cpp for making this |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1727 // code platform specific, which it is by its very nature. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1728 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1729 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1730 // Will be modified when max signal is changed to be dynamic |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1731 int os::sigexitnum_pd() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1732 return NSIG; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1733 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1734 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1735 // a counter for each possible signal value |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1736 static volatile jint pending_signals[NSIG+1] = { 0 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1737 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1738 // Linux(POSIX) specific hand shaking semaphore. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1739 static sem_t sig_sem; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1740 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1741 void os::signal_init_pd() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1742 // Initialize signal structures |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1743 ::memset((void*)pending_signals, 0, sizeof(pending_signals)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1744 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1745 // Initialize signal semaphore |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1746 int rc = ::sem_init(&sig_sem, 0, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1747 guarantee(rc != -1, "sem_init failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1748 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1749 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1750 void os::signal_notify(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1751 Atomic::inc(&pending_signals[sig]); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1752 ::sem_post(&sig_sem); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1753 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1754 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1755 static int check_pending_signals(bool wait) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1756 Atomic::store(0, &sigint_count); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1757 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1758 for (int i = 0; i < NSIG + 1; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1759 jint n = pending_signals[i]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1760 if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1761 return i; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1762 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1763 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1764 if (!wait) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1765 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1766 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1767 JavaThread *thread = JavaThread::current(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1768 ThreadBlockInVM tbivm(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1769 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1770 bool threadIsSuspended; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1771 do { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1772 thread->set_suspend_equivalent(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1773 // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1774 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1775 ::sem_wait(&sig_sem); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1776 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1777 // were we externally suspended while we were waiting? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1778 threadIsSuspended = thread->handle_special_suspend_equivalent_condition(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1779 if (threadIsSuspended) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1780 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1781 // The semaphore has been incremented, but while we were waiting |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1782 // another thread suspended us. We don't want to continue running |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1783 // while suspended because that would surprise the thread that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1784 // suspended us. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1785 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1786 ::sem_post(&sig_sem); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1787 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1788 thread->java_suspend_self(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1789 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1790 } while (threadIsSuspended); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1791 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1792 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1793 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1794 int os::signal_lookup() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1795 return check_pending_signals(false); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1796 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1797 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1798 int os::signal_wait() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1799 return check_pending_signals(true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1800 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1801 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1802 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1803 // Virtual Memory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1804 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1805 // AddrRange describes an immutable address range |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1806 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1807 // This is a helper class for the 'shared memory bookkeeping' below. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1808 class AddrRange { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1809 friend class ShmBkBlock; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1810 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1811 char* _start; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1812 size_t _size; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1813 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1814 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1815 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1816 AddrRange(char* start, size_t size) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1817 : _start(start), _size(size) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1818 {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1819 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1820 AddrRange(const AddrRange& r) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1821 : _start(r.start()), _size(r.size()) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1822 {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1823 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1824 char* start() const { return _start; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1825 size_t size() const { return _size; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1826 char* end() const { return _start + _size; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1827 bool is_empty() const { return _size == 0 ? true : false; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1828 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1829 static AddrRange empty_range() { return AddrRange(NULL, 0); } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1830 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1831 bool contains(const char* p) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1832 return start() <= p && end() > p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1833 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1834 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1835 bool contains(const AddrRange& range) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1836 return start() <= range.start() && end() >= range.end(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1837 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1838 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1839 bool intersects(const AddrRange& range) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1840 return (range.start() <= start() && range.end() > start()) || |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1841 (range.start() < end() && range.end() >= end()) || |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1842 contains(range); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1843 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1844 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1845 bool is_same_range(const AddrRange& range) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1846 return start() == range.start() && size() == range.size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1847 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1848 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1849 // return the closest inside range consisting of whole pages |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1850 AddrRange find_closest_aligned_range(size_t pagesize) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1851 if (pagesize == 0 || is_empty()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1852 return empty_range(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1853 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1854 char* const from = (char*)align_size_up((intptr_t)_start, pagesize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1855 char* const to = (char*)align_size_down((intptr_t)end(), pagesize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1856 if (from > to) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1857 return empty_range(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1858 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1859 return AddrRange(from, to - from); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1860 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1861 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1862 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1863 //////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1864 // shared memory bookkeeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1865 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1866 // the os::reserve_memory() API and friends hand out different kind of memory, depending |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1867 // on need and circumstances. Memory may be allocated with mmap() or with shmget/shmat. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1868 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1869 // But these memory types have to be treated differently. For example, to uncommit |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1870 // mmap-based memory, msync(MS_INVALIDATE) is needed, to uncommit shmat-based memory, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1871 // disclaim64() is needed. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1872 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1873 // Therefore we need to keep track of the allocated memory segments and their |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1874 // properties. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1875 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1876 // ShmBkBlock: base class for all blocks in the shared memory bookkeeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1877 class ShmBkBlock { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1878 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1879 ShmBkBlock* _next; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1880 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1881 protected: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1882 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1883 AddrRange _range; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1884 const size_t _pagesize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1885 const bool _pinned; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1886 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1887 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1888 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1889 ShmBkBlock(AddrRange range, size_t pagesize, bool pinned) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1890 : _range(range), _pagesize(pagesize), _pinned(pinned) , _next(NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1891 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1892 assert(_pagesize == SIZE_4K || _pagesize == SIZE_64K || _pagesize == SIZE_16M, "invalid page size"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1893 assert(!_range.is_empty(), "invalid range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1894 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1895 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1896 virtual void print(outputStream* st) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1897 st->print("0x%p ... 0x%p (%llu) - %d %s pages - %s", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1898 _range.start(), _range.end(), _range.size(), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1899 _range.size() / _pagesize, describe_pagesize(_pagesize), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1900 _pinned ? "pinned" : ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1901 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1902 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1903 enum Type { MMAP, SHMAT }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1904 virtual Type getType() = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1905 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1906 char* base() const { return _range.start(); } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1907 size_t size() const { return _range.size(); } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1908 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1909 void setAddrRange(AddrRange range) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1910 _range = range; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1911 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1912 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1913 bool containsAddress(const char* p) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1914 return _range.contains(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1915 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1916 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1917 bool containsRange(const char* p, size_t size) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1918 return _range.contains(AddrRange((char*)p, size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1919 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1920 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1921 bool isSameRange(const char* p, size_t size) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1922 return _range.is_same_range(AddrRange((char*)p, size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1923 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1924 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1925 virtual bool disclaim(char* p, size_t size) = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1926 virtual bool release() = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1927 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1928 // blocks live in a list. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1929 ShmBkBlock* next() const { return _next; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1930 void set_next(ShmBkBlock* blk) { _next = blk; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1931 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1932 }; // end: ShmBkBlock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1933 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1934 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1935 // ShmBkMappedBlock: describes an block allocated with mmap() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1936 class ShmBkMappedBlock : public ShmBkBlock { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1937 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1938 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1939 ShmBkMappedBlock(AddrRange range) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1940 : ShmBkBlock(range, SIZE_4K, false) {} // mmap: always 4K, never pinned |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1941 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1942 void print(outputStream* st) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1943 ShmBkBlock::print(st); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1944 st->print_cr(" - mmap'ed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1945 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1946 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1947 Type getType() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1948 return MMAP; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1949 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1950 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1951 bool disclaim(char* p, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1952 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1953 AddrRange r(p, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1954 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1955 guarantee(_range.contains(r), "invalid disclaim"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1956 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1957 // only disclaim whole ranges. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1958 const AddrRange r2 = r.find_closest_aligned_range(_pagesize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1959 if (r2.is_empty()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1960 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1961 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1962 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1963 const int rc = ::msync(r2.start(), r2.size(), MS_INVALIDATE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1964 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1965 if (rc != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1966 warning("msync(0x%p, %llu, MS_INVALIDATE) failed (%d)\n", r2.start(), r2.size(), errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1967 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1968 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1969 return rc == 0 ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1970 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1971 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1972 bool release() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1973 // mmap'ed blocks are released using munmap |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1974 if (::munmap(_range.start(), _range.size()) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1975 warning("munmap(0x%p, %llu) failed (%d)\n", _range.start(), _range.size(), errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1976 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1977 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1978 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1979 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1980 }; // end: ShmBkMappedBlock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1981 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1982 // ShmBkShmatedBlock: describes an block allocated with shmget/shmat() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1983 class ShmBkShmatedBlock : public ShmBkBlock { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1984 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1985 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1986 ShmBkShmatedBlock(AddrRange range, size_t pagesize, bool pinned) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1987 : ShmBkBlock(range, pagesize, pinned) {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1988 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1989 void print(outputStream* st) const { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1990 ShmBkBlock::print(st); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1991 st->print_cr(" - shmat'ed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1992 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1993 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1994 Type getType() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1995 return SHMAT; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1996 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1997 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1998 bool disclaim(char* p, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1999 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2000 AddrRange r(p, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2001 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2002 if (_pinned) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2003 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2004 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2005 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2006 // shmat'ed blocks are disclaimed using disclaim64 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2007 guarantee(_range.contains(r), "invalid disclaim"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2008 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2009 // only disclaim whole ranges. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2010 const AddrRange r2 = r.find_closest_aligned_range(_pagesize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2011 if (r2.is_empty()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2012 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2013 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2014 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2015 const bool rc = my_disclaim64(r2.start(), r2.size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2016 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2017 if (Verbose && !rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2018 warning("failed to disclaim shm %p-%p\n", r2.start(), r2.end()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2019 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2020 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2021 return rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2022 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2023 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2024 bool release() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2025 bool rc = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2026 if (::shmdt(_range.start()) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2027 warning("shmdt(0x%p) failed (%d)\n", _range.start(), errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2028 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2029 rc = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2030 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2031 return rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2032 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2033 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2034 }; // end: ShmBkShmatedBlock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2035 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2036 static ShmBkBlock* g_shmbk_list = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2037 static volatile jint g_shmbk_table_lock = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2038 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2039 // keep some usage statistics |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2040 static struct { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2041 int nodes; // number of nodes in list |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2042 size_t bytes; // reserved - not committed - bytes. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2043 int reserves; // how often reserve was called |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2044 int lookups; // how often a lookup was made |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2045 } g_shmbk_stats = { 0, 0, 0, 0 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2046 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2047 // add information about a shared memory segment to the bookkeeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2048 static void shmbk_register(ShmBkBlock* p_block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2049 guarantee(p_block, "logic error"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2050 p_block->set_next(g_shmbk_list); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2051 g_shmbk_list = p_block; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2052 g_shmbk_stats.reserves ++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2053 g_shmbk_stats.bytes += p_block->size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2054 g_shmbk_stats.nodes ++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2055 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2056 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2057 // remove information about a shared memory segment by its starting address |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2058 static void shmbk_unregister(ShmBkBlock* p_block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2059 ShmBkBlock* p = g_shmbk_list; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2060 ShmBkBlock* prev = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2061 while (p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2062 if (p == p_block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2063 if (prev) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2064 prev->set_next(p->next()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2065 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2066 g_shmbk_list = p->next(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2067 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2068 g_shmbk_stats.nodes --; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2069 g_shmbk_stats.bytes -= p->size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2070 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2071 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2072 prev = p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2073 p = p->next(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2074 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2075 assert(false, "should not happen"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2076 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2077 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2078 // given a pointer, return shared memory bookkeeping record for the segment it points into |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2079 // using the returned block info must happen under lock protection |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2080 static ShmBkBlock* shmbk_find_by_containing_address(const char* addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2081 g_shmbk_stats.lookups ++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2082 ShmBkBlock* p = g_shmbk_list; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2083 while (p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2084 if (p->containsAddress(addr)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2085 return p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2086 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2087 p = p->next(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2088 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2089 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2090 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2091 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2092 // dump all information about all memory segments allocated with os::reserve_memory() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2093 void shmbk_dump_info() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2094 tty->print_cr("-- shared mem bookkeeping (alive: %d segments, %llu bytes, " |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2095 "total reserves: %d total lookups: %d)", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2096 g_shmbk_stats.nodes, g_shmbk_stats.bytes, g_shmbk_stats.reserves, g_shmbk_stats.lookups); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2097 const ShmBkBlock* p = g_shmbk_list; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2098 int i = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2099 while (p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2100 p->print(tty); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2101 p = p->next(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2102 i ++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2103 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2104 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2105 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2106 #define LOCK_SHMBK { ThreadCritical _LOCK_SHMBK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2107 #define UNLOCK_SHMBK } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2108 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2109 // End: shared memory bookkeeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2110 //////////////////////////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2111 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2112 int os::vm_page_size() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2113 // Seems redundant as all get out |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2114 assert(os::Aix::page_size() != -1, "must call os::init"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2115 return os::Aix::page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2116 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2117 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2118 // Aix allocates memory by pages. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2119 int os::vm_allocation_granularity() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2120 assert(os::Aix::page_size() != -1, "must call os::init"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2121 return os::Aix::page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2122 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2123 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2124 int os::Aix::commit_memory_impl(char* addr, size_t size, bool exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2125 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2126 // Commit is a noop. There is no explicit commit |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2127 // needed on AIX. Memory is committed when touched. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2128 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2129 // Debug : check address range for validity |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2130 #ifdef ASSERT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2131 LOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2132 ShmBkBlock* const block = shmbk_find_by_containing_address(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2133 if (!block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2134 fprintf(stderr, "invalid pointer: " INTPTR_FORMAT "\n", addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2135 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2136 assert(false, "invalid pointer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2137 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2138 } else if (!block->containsRange(addr, size)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2139 fprintf(stderr, "invalid range: " INTPTR_FORMAT " .. " INTPTR_FORMAT "\n", addr, addr + size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2140 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2141 assert(false, "invalid range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2142 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2143 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2144 UNLOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2145 #endif // ASSERT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2146 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2147 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2148 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2149 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2150 bool os::pd_commit_memory(char* addr, size_t size, bool exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2151 return os::Aix::commit_memory_impl(addr, size, exec) == 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2152 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2153 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2154 void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2155 const char* mesg) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2156 assert(mesg != NULL, "mesg must be specified"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2157 os::Aix::commit_memory_impl(addr, size, exec); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2158 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2159 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2160 int os::Aix::commit_memory_impl(char* addr, size_t size, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2161 size_t alignment_hint, bool exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2162 return os::Aix::commit_memory_impl(addr, size, exec); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2163 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2164 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2165 bool os::pd_commit_memory(char* addr, size_t size, size_t alignment_hint, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2166 bool exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2167 return os::Aix::commit_memory_impl(addr, size, alignment_hint, exec) == 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2168 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2169 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2170 void os::pd_commit_memory_or_exit(char* addr, size_t size, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2171 size_t alignment_hint, bool exec, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2172 const char* mesg) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2173 os::Aix::commit_memory_impl(addr, size, alignment_hint, exec); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2174 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2175 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2176 bool os::pd_uncommit_memory(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2177 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2178 // Delegate to ShmBkBlock class which knows how to uncommit its memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2179 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2180 bool rc = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2181 LOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2182 ShmBkBlock* const block = shmbk_find_by_containing_address(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2183 if (!block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2184 fprintf(stderr, "invalid pointer: 0x%p.\n", addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2185 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2186 assert(false, "invalid pointer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2187 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2188 } else if (!block->containsRange(addr, size)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2189 fprintf(stderr, "invalid range: 0x%p .. 0x%p.\n", addr, addr + size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2190 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2191 assert(false, "invalid range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2192 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2193 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2194 rc = block->disclaim(addr, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2195 UNLOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2196 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2197 if (Verbose && !rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2198 warning("failed to disclaim 0x%p .. 0x%p (0x%llX bytes).", addr, addr + size, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2199 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2200 return rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2201 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2202 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2203 bool os::pd_create_stack_guard_pages(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2204 return os::guard_memory(addr, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2205 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2206 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2207 bool os::remove_stack_guard_pages(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2208 return os::unguard_memory(addr, size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2209 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2210 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2211 void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2212 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2213 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2214 void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2215 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2216 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2217 void os::numa_make_global(char *addr, size_t bytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2218 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2219 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2220 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2221 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2222 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2223 bool os::numa_topology_changed() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2224 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2225 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2226 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2227 size_t os::numa_get_groups_num() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2228 return 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2229 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2230 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2231 int os::numa_get_group_id() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2232 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2233 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2234 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2235 size_t os::numa_get_leaf_groups(int *ids, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2236 if (size > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2237 ids[0] = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2238 return 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2239 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2240 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2241 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2242 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2243 bool os::get_page_info(char *start, page_info* info) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2244 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2245 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2246 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2247 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2248 return end; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2249 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2250 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2251 // Flags for reserve_shmatted_memory: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2252 #define RESSHM_WISHADDR_OR_FAIL 1 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2253 #define RESSHM_TRY_16M_PAGES 2 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2254 #define RESSHM_16M_PAGES_OR_FAIL 4 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2255 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2256 // Result of reserve_shmatted_memory: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2257 struct shmatted_memory_info_t { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2258 char* addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2259 size_t pagesize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2260 bool pinned; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2261 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2262 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2263 // Reserve a section of shmatted memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2264 // params: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2265 // bytes [in]: size of memory, in bytes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2266 // requested_addr [in]: wish address. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2267 // NULL = no wish. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2268 // If RESSHM_WISHADDR_OR_FAIL is set in flags and wish address cannot |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2269 // be obtained, function will fail. Otherwise wish address is treated as hint and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2270 // another pointer is returned. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2271 // flags [in]: some flags. Valid flags are: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2272 // RESSHM_WISHADDR_OR_FAIL - fail if wish address is given and cannot be obtained. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2273 // RESSHM_TRY_16M_PAGES - try to allocate from 16M page pool |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2274 // (requires UseLargePages and Use16MPages) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2275 // RESSHM_16M_PAGES_OR_FAIL - if you cannot allocate from 16M page pool, fail. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2276 // Otherwise any other page size will do. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2277 // p_info [out] : holds information about the created shared memory segment. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2278 static bool reserve_shmatted_memory(size_t bytes, char* requested_addr, int flags, shmatted_memory_info_t* p_info) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2279 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2280 assert(p_info, "parameter error"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2281 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2282 // init output struct. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2283 p_info->addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2284 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2285 // neither should we be here for EXTSHM=ON. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2286 if (os::Aix::extshm()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2287 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2288 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2289 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2290 // extract flags. sanity checks. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2291 const bool wishaddr_or_fail = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2292 flags & RESSHM_WISHADDR_OR_FAIL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2293 const bool try_16M_pages = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2294 flags & RESSHM_TRY_16M_PAGES; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2295 const bool f16M_pages_or_fail = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2296 flags & RESSHM_16M_PAGES_OR_FAIL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2297 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2298 // first check: if a wish address is given and it is mandatory, but not aligned to segment boundary, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2299 // shmat will fail anyway, so save some cycles by failing right away |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2300 if (requested_addr && ((uintptr_t)requested_addr % SIZE_256M == 0)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2301 if (wishaddr_or_fail) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2302 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2303 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2304 requested_addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2305 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2306 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2307 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2308 char* addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2309 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2310 // Align size of shm up to the largest possible page size, to avoid errors later on when we try to change |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2311 // pagesize dynamically. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2312 const size_t size = align_size_up(bytes, SIZE_16M); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2313 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2314 // reserve the shared segment |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2315 int shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | S_IRUSR | S_IWUSR); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2316 if (shmid == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2317 warning("shmget(.., %lld, ..) failed (errno: %d).", size, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2318 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2319 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2320 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2321 // Important note: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2322 // It is very important that we, upon leaving this function, do not leave a shm segment alive. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2323 // We must right after attaching it remove it from the system. System V shm segments are global and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2324 // survive the process. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2325 // So, from here on: Do not assert. Do not return. Always do a "goto cleanup_shm". |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2326 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2327 // try forcing the page size |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2328 size_t pagesize = -1; // unknown so far |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2329 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2330 if (UseLargePages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2331 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2332 struct shmid_ds shmbuf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2333 memset(&shmbuf, 0, sizeof(shmbuf)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2334 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2335 // First, try to take from 16M page pool if... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2336 if (os::Aix::can_use_16M_pages() // we can ... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2337 && Use16MPages // we are not explicitly forbidden to do so (-XX:-Use16MPages).. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2338 && try_16M_pages) { // caller wants us to. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2339 shmbuf.shm_pagesize = SIZE_16M; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2340 if (shmctl(shmid, SHM_PAGESIZE, &shmbuf) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2341 pagesize = SIZE_16M; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2342 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2343 warning("Failed to allocate %d 16M pages. 16M page pool might be exhausted. (shmctl failed with %d)", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2344 size / SIZE_16M, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2345 if (f16M_pages_or_fail) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2346 goto cleanup_shm; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2347 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2348 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2349 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2350 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2351 // Nothing yet? Try setting 64K pages. Note that I never saw this fail, but in theory it might, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2352 // because the 64K page pool may also be exhausted. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2353 if (pagesize == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2354 shmbuf.shm_pagesize = SIZE_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2355 if (shmctl(shmid, SHM_PAGESIZE, &shmbuf) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2356 pagesize = SIZE_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2357 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2358 warning("Failed to allocate %d 64K pages. (shmctl failed with %d)", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2359 size / SIZE_64K, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2360 // here I give up. leave page_size -1 - later, after attaching, we will query the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2361 // real page size of the attached memory. (in theory, it may be something different |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2362 // from 4K if LDR_CNTRL SHM_PSIZE is set) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2363 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2364 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2365 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2366 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2367 // sanity point |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2368 assert(pagesize == -1 || pagesize == SIZE_16M || pagesize == SIZE_64K, "wrong page size"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2369 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2370 // Now attach the shared segment. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2371 addr = (char*) shmat(shmid, requested_addr, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2372 if (addr == (char*)-1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2373 // How to handle attach failure: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2374 // If it failed for a specific wish address, tolerate this: in that case, if wish address was |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2375 // mandatory, fail, if not, retry anywhere. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2376 // If it failed for any other reason, treat that as fatal error. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2377 addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2378 if (requested_addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2379 if (wishaddr_or_fail) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2380 goto cleanup_shm; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2381 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2382 addr = (char*) shmat(shmid, NULL, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2383 if (addr == (char*)-1) { // fatal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2384 addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2385 warning("shmat failed (errno: %d)", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2386 goto cleanup_shm; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2387 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2388 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2389 } else { // fatal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2390 addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2391 warning("shmat failed (errno: %d)", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2392 goto cleanup_shm; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2393 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2394 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2395 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2396 // sanity point |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2397 assert(addr && addr != (char*) -1, "wrong address"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2398 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2399 // after successful Attach remove the segment - right away. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2400 if (::shmctl(shmid, IPC_RMID, NULL) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2401 warning("shmctl(%u, IPC_RMID) failed (%d)\n", shmid, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2402 guarantee(false, "failed to remove shared memory segment!"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2403 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2404 shmid = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2405 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2406 // query the real page size. In case setting the page size did not work (see above), the system |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2407 // may have given us something other then 4K (LDR_CNTRL) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2408 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2409 const size_t real_pagesize = os::Aix::query_pagesize(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2410 if (pagesize != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2411 assert(pagesize == real_pagesize, "unexpected pagesize after shmat"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2412 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2413 pagesize = real_pagesize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2414 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2415 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2416 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2417 // Now register the reserved block with internal book keeping. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2418 LOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2419 const bool pinned = pagesize >= SIZE_16M ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2420 ShmBkShmatedBlock* const p_block = new ShmBkShmatedBlock(AddrRange(addr, size), pagesize, pinned); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2421 assert(p_block, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2422 shmbk_register(p_block); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2423 UNLOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2424 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2425 cleanup_shm: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2426 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2427 // if we have not done so yet, remove the shared memory segment. This is very important. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2428 if (shmid != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2429 if (::shmctl(shmid, IPC_RMID, NULL) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2430 warning("shmctl(%u, IPC_RMID) failed (%d)\n", shmid, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2431 guarantee(false, "failed to remove shared memory segment!"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2432 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2433 shmid = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2434 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2435 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2436 // trace |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2437 if (Verbose && !addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2438 if (requested_addr != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2439 warning("failed to shm-allocate 0x%llX bytes at with address 0x%p.", size, requested_addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2440 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2441 warning("failed to shm-allocate 0x%llX bytes at any address.", size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2442 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2443 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2444 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2445 // hand info to caller |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2446 if (addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2447 p_info->addr = addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2448 p_info->pagesize = pagesize; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2449 p_info->pinned = pagesize == SIZE_16M ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2450 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2451 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2452 // sanity test: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2453 if (requested_addr && addr && wishaddr_or_fail) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2454 guarantee(addr == requested_addr, "shmat error"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2455 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2456 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2457 // just one more test to really make sure we have no dangling shm segments. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2458 guarantee(shmid == -1, "dangling shm segments"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2459 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2460 return addr ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2461 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2462 } // end: reserve_shmatted_memory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2463 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2464 // Reserve memory using mmap. Behaves the same as reserve_shmatted_memory(): |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2465 // will return NULL in case of an error. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2466 static char* reserve_mmaped_memory(size_t bytes, char* requested_addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2467 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2468 // if a wish address is given, but not aligned to 4K page boundary, mmap will fail. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2469 if (requested_addr && ((uintptr_t)requested_addr % os::vm_page_size() != 0)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2470 warning("Wish address 0x%p not aligned to page boundary.", requested_addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2471 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2472 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2473 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2474 const size_t size = align_size_up(bytes, SIZE_4K); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2475 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2476 // Note: MAP_SHARED (instead of MAP_PRIVATE) needed to be able to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2477 // msync(MS_INVALIDATE) (see os::uncommit_memory) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2478 int flags = MAP_ANONYMOUS | MAP_SHARED; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2479 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2480 // MAP_FIXED is needed to enforce requested_addr - manpage is vague about what |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2481 // it means if wishaddress is given but MAP_FIXED is not set. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2482 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2483 // Note however that this changes semantics in SPEC1170 mode insofar as MAP_FIXED |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2484 // clobbers the address range, which is probably not what the caller wants. That's |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2485 // why I assert here (again) that the SPEC1170 compat mode is off. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2486 // If we want to be able to run under SPEC1170, we have to do some porting and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2487 // testing. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2488 if (requested_addr != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2489 assert(!os::Aix::xpg_sus_mode(), "SPEC1170 mode not allowed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2490 flags |= MAP_FIXED; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2491 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2492 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2493 char* addr = (char*)::mmap(requested_addr, size, PROT_READ|PROT_WRITE|PROT_EXEC, flags, -1, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2494 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2495 if (addr == MAP_FAILED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2496 // attach failed: tolerate for specific wish addresses. Not being able to attach |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2497 // anywhere is a fatal error. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2498 if (requested_addr == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2499 // It's ok to fail here if the machine has not enough memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2500 warning("mmap(NULL, 0x%llX, ..) failed (%d)", size, errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2501 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2502 addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2503 goto cleanup_mmap; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2504 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2505 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2506 // If we did request a specific address and that address was not available, fail. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2507 if (addr && requested_addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2508 guarantee(addr == requested_addr, "unexpected"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2509 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2510 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2511 // register this mmap'ed segment with book keeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2512 LOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2513 ShmBkMappedBlock* const p_block = new ShmBkMappedBlock(AddrRange(addr, size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2514 assert(p_block, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2515 shmbk_register(p_block); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2516 UNLOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2517 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2518 cleanup_mmap: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2519 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2520 if (addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2521 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2522 fprintf(stderr, "mmap-allocated 0x%p .. 0x%p (0x%llX bytes)\n", addr, addr + bytes, bytes); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2523 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2524 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2525 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2526 if (requested_addr != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2527 warning("failed to mmap-allocate 0x%llX bytes at wish address 0x%p.", bytes, requested_addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2528 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2529 warning("failed to mmap-allocate 0x%llX bytes at any address.", bytes); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2530 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2531 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2532 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2533 return addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2534 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2535 } // end: reserve_mmaped_memory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2536 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2537 // Reserves and attaches a shared memory segment. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2538 // Will assert if a wish address is given and could not be obtained. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2539 char* os::pd_reserve_memory(size_t bytes, char* requested_addr, size_t alignment_hint) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2540 return os::attempt_reserve_memory_at(bytes, requested_addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2541 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2542 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2543 bool os::pd_release_memory(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2544 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2545 // delegate to ShmBkBlock class which knows how to uncommit its memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2546 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2547 bool rc = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2548 LOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2549 ShmBkBlock* const block = shmbk_find_by_containing_address(addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2550 if (!block) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2551 fprintf(stderr, "invalid pointer: 0x%p.\n", addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2552 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2553 assert(false, "invalid pointer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2554 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2555 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2556 else if (!block->isSameRange(addr, size)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2557 if (block->getType() == ShmBkBlock::MMAP) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2558 // Release only the same range or a the beginning or the end of a range. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2559 if (block->base() == addr && size < block->size()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2560 ShmBkMappedBlock* const b = new ShmBkMappedBlock(AddrRange(block->base() + size, block->size() - size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2561 assert(b, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2562 shmbk_register(b); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2563 block->setAddrRange(AddrRange(addr, size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2564 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2565 else if (addr > block->base() && addr + size == block->base() + block->size()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2566 ShmBkMappedBlock* const b = new ShmBkMappedBlock(AddrRange(block->base(), block->size() - size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2567 assert(b, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2568 shmbk_register(b); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2569 block->setAddrRange(AddrRange(addr, size)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2570 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2571 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2572 fprintf(stderr, "invalid mmap range: 0x%p .. 0x%p.\n", addr, addr + size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2573 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2574 assert(false, "invalid mmap range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2575 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2576 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2577 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2578 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2579 // Release only the same range. No partial release allowed. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2580 // Soften the requirement a bit, because the user may think he owns a smaller size |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2581 // than the block is due to alignment etc. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2582 if (block->base() != addr || block->size() < size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2583 fprintf(stderr, "invalid shmget range: 0x%p .. 0x%p.\n", addr, addr + size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2584 shmbk_dump_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2585 assert(false, "invalid shmget range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2586 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2587 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2588 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2589 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2590 rc = block->release(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2591 assert(rc, "release failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2592 // remove block from bookkeeping |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2593 shmbk_unregister(block); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2594 delete block; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2595 UNLOCK_SHMBK |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2596 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2597 if (!rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2598 warning("failed to released %lu bytes at 0x%p", size, addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2599 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2600 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2601 return rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2602 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2603 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2604 static bool checked_mprotect(char* addr, size_t size, int prot) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2605 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2606 // Little problem here: if SPEC1170 behaviour is off, mprotect() on AIX will |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2607 // not tell me if protection failed when trying to protect an un-protectable range. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2608 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2609 // This means if the memory was allocated using shmget/shmat, protection wont work |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2610 // but mprotect will still return 0: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2611 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2612 // See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2613 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2614 bool rc = ::mprotect(addr, size, prot) == 0 ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2615 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2616 if (!rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2617 const char* const s_errno = strerror(errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2618 warning("mprotect(" PTR_FORMAT "-" PTR_FORMAT ", 0x%X) failed (%s).", addr, addr + size, prot, s_errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2619 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2620 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2621 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2622 // mprotect success check |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2623 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2624 // Mprotect said it changed the protection but can I believe it? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2625 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2626 // To be sure I need to check the protection afterwards. Try to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2627 // read from protected memory and check whether that causes a segfault. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2628 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2629 if (!os::Aix::xpg_sus_mode()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2630 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2631 if (StubRoutines::SafeFetch32_stub()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2632 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2633 const bool read_protected = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2634 (SafeFetch32((int*)addr, 0x12345678) == 0x12345678 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2635 SafeFetch32((int*)addr, 0x76543210) == 0x76543210) ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2636 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2637 if (prot & PROT_READ) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2638 rc = !read_protected; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2639 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2640 rc = read_protected; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2641 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2642 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2643 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2644 if (!rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2645 assert(false, "mprotect failed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2646 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2647 return rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2648 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2649 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2650 // Set protections specified |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2651 bool os::protect_memory(char* addr, size_t size, ProtType prot, bool is_committed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2652 unsigned int p = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2653 switch (prot) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2654 case MEM_PROT_NONE: p = PROT_NONE; break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2655 case MEM_PROT_READ: p = PROT_READ; break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2656 case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2657 case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2658 default: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2659 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2660 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2661 // is_committed is unused. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2662 return checked_mprotect(addr, size, p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2663 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2664 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2665 bool os::guard_memory(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2666 return checked_mprotect(addr, size, PROT_NONE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2667 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2668 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2669 bool os::unguard_memory(char* addr, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2670 return checked_mprotect(addr, size, PROT_READ|PROT_WRITE|PROT_EXEC); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2671 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2672 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2673 // Large page support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2674 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2675 static size_t _large_page_size = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2676 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2677 // Enable large page support if OS allows that. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2678 void os::large_page_init() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2679 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2680 // Note: os::Aix::query_multipage_support must run first. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2681 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2682 if (!UseLargePages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2683 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2684 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2685 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2686 if (!Aix::can_use_64K_pages()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2687 assert(!Aix::can_use_16M_pages(), "64K is a precondition for 16M."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2688 UseLargePages = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2689 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2690 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2691 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2692 if (!Aix::can_use_16M_pages() && Use16MPages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2693 fprintf(stderr, "Cannot use 16M pages. Please ensure that there is a 16M page pool " |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2694 " and that the VM runs with CAP_BYPASS_RAC_VMM and CAP_PROPAGATE capabilities.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2695 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2696 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2697 // Do not report 16M page alignment as part of os::_page_sizes if we are |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2698 // explicitly forbidden from using 16M pages. Doing so would increase the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2699 // alignment the garbage collector calculates with, slightly increasing |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2700 // heap usage. We should only pay for 16M alignment if we really want to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2701 // use 16M pages. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2702 if (Use16MPages && Aix::can_use_16M_pages()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2703 _large_page_size = SIZE_16M; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2704 _page_sizes[0] = SIZE_16M; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2705 _page_sizes[1] = SIZE_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2706 _page_sizes[2] = SIZE_4K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2707 _page_sizes[3] = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2708 } else if (Aix::can_use_64K_pages()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2709 _large_page_size = SIZE_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2710 _page_sizes[0] = SIZE_64K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2711 _page_sizes[1] = SIZE_4K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2712 _page_sizes[2] = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2713 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2714 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2715 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2716 ("Default large page size is 0x%llX.", _large_page_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2717 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2718 } // end: os::large_page_init() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2719 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2720 char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2721 // "exec" is passed in but not used. Creating the shared image for |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2722 // the code cache doesn't have an SHM_X executable permission to check. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2723 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2724 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2725 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2726 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2727 bool os::release_memory_special(char* base, size_t bytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2728 // detaching the SHM segment will also delete it, see reserve_memory_special() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2729 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2730 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2731 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2732 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2733 size_t os::large_page_size() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2734 return _large_page_size; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2735 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2736 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2737 bool os::can_commit_large_page_memory() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2738 // Well, sadly we cannot commit anything at all (see comment in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2739 // os::commit_memory) but we claim to so we can make use of large pages |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2740 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2741 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2742 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2743 bool os::can_execute_large_page_memory() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2744 // We can do that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2745 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2746 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2747 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2748 // Reserve memory at an arbitrary address, only if that area is |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2749 // available (and not reserved for something else). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2750 char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2751 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2752 bool use_mmap = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2753 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2754 // mmap: smaller graining, no large page support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2755 // shm: large graining (256M), large page support, limited number of shm segments |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2756 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2757 // Prefer mmap wherever we either do not need large page support or have OS limits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2758 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2759 if (!UseLargePages || bytes < SIZE_16M) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2760 use_mmap = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2761 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2762 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2763 char* addr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2764 if (use_mmap) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2765 addr = reserve_mmaped_memory(bytes, requested_addr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2766 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2767 // shmat: wish address is mandatory, and do not try 16M pages here. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2768 shmatted_memory_info_t info; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2769 const int flags = RESSHM_WISHADDR_OR_FAIL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2770 if (reserve_shmatted_memory(bytes, requested_addr, flags, &info)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2771 addr = info.addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2772 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2773 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2774 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2775 return addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2776 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2777 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2778 size_t os::read(int fd, void *buf, unsigned int nBytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2779 return ::read(fd, buf, nBytes); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2780 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2781 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2782 #define NANOSECS_PER_MILLISEC 1000000 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2783 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2784 int os::sleep(Thread* thread, jlong millis, bool interruptible) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2785 assert(thread == Thread::current(), "thread consistency check"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2786 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2787 // Prevent nasty overflow in deadline calculation |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2788 // by handling long sleeps similar to solaris or windows. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2789 const jlong limit = INT_MAX; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2790 int result; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2791 while (millis > limit) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2792 if ((result = os::sleep(thread, limit, interruptible)) != OS_OK) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2793 return result; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2794 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2795 millis -= limit; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2796 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2797 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2798 ParkEvent * const slp = thread->_SleepEvent; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2799 slp->reset(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2800 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2801 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2802 if (interruptible) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2803 jlong prevtime = javaTimeNanos(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2804 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2805 // Prevent precision loss and too long sleeps |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2806 jlong deadline = prevtime + millis * NANOSECS_PER_MILLISEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2807 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2808 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2809 if (os::is_interrupted(thread, true)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2810 return OS_INTRPT; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2811 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2812 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2813 jlong newtime = javaTimeNanos(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2814 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2815 assert(newtime >= prevtime, "time moving backwards"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2816 // Doing prevtime and newtime in microseconds doesn't help precision, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2817 // and trying to round up to avoid lost milliseconds can result in a |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2818 // too-short delay. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2819 millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2820 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2821 if (millis <= 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2822 return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2823 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2824 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2825 // Stop sleeping if we passed the deadline |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2826 if (newtime >= deadline) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2827 return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2828 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2829 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2830 prevtime = newtime; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2831 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2832 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2833 assert(thread->is_Java_thread(), "sanity check"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2834 JavaThread *jt = (JavaThread *) thread; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2835 ThreadBlockInVM tbivm(jt); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2836 OSThreadWaitState osts(jt->osthread(), false /* not Object.wait() */); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2837 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2838 jt->set_suspend_equivalent(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2839 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2840 slp->park(millis); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2841 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2842 // were we externally suspended while we were waiting? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2843 jt->check_and_wait_while_suspended(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2844 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2845 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2846 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2847 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2848 jlong prevtime = javaTimeNanos(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2849 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2850 // Prevent precision loss and too long sleeps |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2851 jlong deadline = prevtime + millis * NANOSECS_PER_MILLISEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2852 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2853 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2854 // It'd be nice to avoid the back-to-back javaTimeNanos() calls on |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2855 // the 1st iteration ... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2856 jlong newtime = javaTimeNanos(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2857 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2858 if (newtime - prevtime < 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2859 // time moving backwards, should only happen if no monotonic clock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2860 // not a guarantee() because JVM should not abort on kernel/glibc bugs |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2861 // - HS14 Commented out as not implemented. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2862 // - TODO Maybe we should implement it? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2863 //assert(!Aix::supports_monotonic_clock(), "time moving backwards"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2864 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2865 millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2866 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2867 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2868 if (millis <= 0) break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2869 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2870 if (newtime >= deadline) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2871 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2872 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2873 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2874 prevtime = newtime; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2875 slp->park(millis); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2876 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2877 return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2878 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2879 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2880 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2881 int os::naked_sleep() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2882 // %% make the sleep time an integer flag. for now use 1 millisec. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2883 return os::sleep(Thread::current(), 1, false); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2884 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2885 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2886 // Sleep forever; naked call to OS-specific sleep; use with CAUTION |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2887 void os::infinite_sleep() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2888 while (true) { // sleep forever ... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2889 ::sleep(100); // ... 100 seconds at a time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2890 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2891 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2892 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2893 // Used to convert frequent JVM_Yield() to nops |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2894 bool os::dont_yield() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2895 return DontYieldALot; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2896 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2897 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2898 void os::yield() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2899 sched_yield(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2900 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2901 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2902 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2903 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2904 void os::yield_all(int attempts) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2905 // Yields to all threads, including threads with lower priorities |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2906 // Threads on Linux are all with same priority. The Solaris style |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2907 // os::yield_all() with nanosleep(1ms) is not necessary. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2908 sched_yield(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2909 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2910 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2911 // Called from the tight loops to possibly influence time-sharing heuristics |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2912 void os::loop_breaker(int attempts) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2913 os::yield_all(attempts); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2914 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2915 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2916 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2917 // thread priority support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2918 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2919 // From AIX manpage to pthread_setschedparam |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2920 // (see: http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2921 // topic=/com.ibm.aix.basetechref/doc/basetrf1/pthread_setschedparam.htm): |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2922 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2923 // "If schedpolicy is SCHED_OTHER, then sched_priority must be in the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2924 // range from 40 to 80, where 40 is the least favored priority and 80 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2925 // is the most favored." |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2926 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2927 // (Actually, I doubt this even has an impact on AIX, as we do kernel |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2928 // scheduling there; however, this still leaves iSeries.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2929 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2930 // We use the same values for AIX and PASE. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2931 int os::java_to_os_priority[CriticalPriority + 1] = { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2932 54, // 0 Entry should never be used |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2933 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2934 55, // 1 MinPriority |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2935 55, // 2 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2936 56, // 3 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2937 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2938 56, // 4 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2939 57, // 5 NormPriority |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2940 57, // 6 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2941 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2942 58, // 7 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2943 58, // 8 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2944 59, // 9 NearMaxPriority |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2945 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2946 60, // 10 MaxPriority |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2947 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2948 60 // 11 CriticalPriority |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2949 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2950 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2951 OSReturn os::set_native_priority(Thread* thread, int newpri) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2952 if (!UseThreadPriorities) return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2953 pthread_t thr = thread->osthread()->pthread_id(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2954 int policy = SCHED_OTHER; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2955 struct sched_param param; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2956 param.sched_priority = newpri; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2957 int ret = pthread_setschedparam(thr, policy, ¶m); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2958 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2959 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2960 if (ret == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2961 fprintf(stderr, "changed priority of thread %d to %d\n", (int)thr, newpri); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2962 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2963 fprintf(stderr, "Could not changed priority for thread %d to %d (error %d, %s)\n", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2964 (int)thr, newpri, ret, strerror(ret)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2965 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2966 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2967 return (ret == 0) ? OS_OK : OS_ERR; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2968 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2969 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2970 OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2971 if (!UseThreadPriorities) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2972 *priority_ptr = java_to_os_priority[NormPriority]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2973 return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2974 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2975 pthread_t thr = thread->osthread()->pthread_id(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2976 int policy = SCHED_OTHER; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2977 struct sched_param param; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2978 int ret = pthread_getschedparam(thr, &policy, ¶m); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2979 *priority_ptr = param.sched_priority; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2980 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2981 return (ret == 0) ? OS_OK : OS_ERR; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2982 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2983 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2984 // Hint to the underlying OS that a task switch would not be good. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2985 // Void return because it's a hint and can fail. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2986 void os::hint_no_preempt() {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2987 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2988 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2989 // suspend/resume support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2990 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2991 // the low-level signal-based suspend/resume support is a remnant from the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2992 // old VM-suspension that used to be for java-suspension, safepoints etc, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2993 // within hotspot. Now there is a single use-case for this: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2994 // - calling get_thread_pc() on the VMThread by the flat-profiler task |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2995 // that runs in the watcher thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2996 // The remaining code is greatly simplified from the more general suspension |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2997 // code that used to be used. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2998 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2999 // The protocol is quite simple: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3000 // - suspend: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3001 // - sends a signal to the target thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3002 // - polls the suspend state of the osthread using a yield loop |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3003 // - target thread signal handler (SR_handler) sets suspend state |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3004 // and blocks in sigsuspend until continued |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3005 // - resume: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3006 // - sets target osthread state to continue |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3007 // - sends signal to end the sigsuspend loop in the SR_handler |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3008 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3009 // Note that the SR_lock plays no role in this suspend/resume protocol. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3010 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3011 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3012 static void resume_clear_context(OSThread *osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3013 osthread->set_ucontext(NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3014 osthread->set_siginfo(NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3015 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3016 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3017 static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3018 osthread->set_ucontext(context); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3019 osthread->set_siginfo(siginfo); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3020 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3021 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3022 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3023 // Handler function invoked when a thread's execution is suspended or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3024 // resumed. We have to be careful that only async-safe functions are |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3025 // called here (Note: most pthread functions are not async safe and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3026 // should be avoided.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3027 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3028 // Note: sigwait() is a more natural fit than sigsuspend() from an |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3029 // interface point of view, but sigwait() prevents the signal hander |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3030 // from being run. libpthread would get very confused by not having |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3031 // its signal handlers run and prevents sigwait()'s use with the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3032 // mutex granting granting signal. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3033 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3034 // Currently only ever called on the VMThread and JavaThreads (PC sampling). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3035 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3036 static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3037 // Save and restore errno to avoid confusing native code with EINTR |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3038 // after sigsuspend. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3039 int old_errno = errno; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3040 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3041 Thread* thread = Thread::current(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3042 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3043 assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3044 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3045 os::SuspendResume::State current = osthread->sr.state(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3046 if (current == os::SuspendResume::SR_SUSPEND_REQUEST) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3047 suspend_save_context(osthread, siginfo, context); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3048 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3049 // attempt to switch the state, we assume we had a SUSPEND_REQUEST |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3050 os::SuspendResume::State state = osthread->sr.suspended(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3051 if (state == os::SuspendResume::SR_SUSPENDED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3052 sigset_t suspend_set; // signals for sigsuspend() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3053 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3054 // get current set of blocked signals and unblock resume signal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3055 pthread_sigmask(SIG_BLOCK, NULL, &suspend_set); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3056 sigdelset(&suspend_set, SR_signum); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3057 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3058 // wait here until we are resumed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3059 while (1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3060 sigsuspend(&suspend_set); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3061 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3062 os::SuspendResume::State result = osthread->sr.running(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3063 if (result == os::SuspendResume::SR_RUNNING) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3064 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3065 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3066 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3067 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3068 } else if (state == os::SuspendResume::SR_RUNNING) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3069 // request was cancelled, continue |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3070 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3071 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3072 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3073 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3074 resume_clear_context(osthread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3075 } else if (current == os::SuspendResume::SR_RUNNING) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3076 // request was cancelled, continue |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3077 } else if (current == os::SuspendResume::SR_WAKEUP_REQUEST) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3078 // ignore |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3079 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3080 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3081 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3082 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3083 errno = old_errno; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3084 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3085 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3086 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3087 static int SR_initialize() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3088 struct sigaction act; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3089 char *s; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3090 // Get signal number to use for suspend/resume |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3091 if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3092 int sig = ::strtol(s, 0, 10); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3093 if (sig > 0 || sig < NSIG) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3094 SR_signum = sig; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3095 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3096 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3097 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3098 assert(SR_signum > SIGSEGV && SR_signum > SIGBUS, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3099 "SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3100 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3101 sigemptyset(&SR_sigset); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3102 sigaddset(&SR_sigset, SR_signum); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3103 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3104 // Set up signal handler for suspend/resume. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3105 act.sa_flags = SA_RESTART|SA_SIGINFO; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3106 act.sa_handler = (void (*)(int)) SR_handler; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3107 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3108 // SR_signum is blocked by default. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3109 // 4528190 - We also need to block pthread restart signal (32 on all |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3110 // supported Linux platforms). Note that LinuxThreads need to block |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3111 // this signal for all threads to work properly. So we don't have |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3112 // to use hard-coded signal number when setting up the mask. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3113 pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3114 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3115 if (sigaction(SR_signum, &act, 0) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3116 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3117 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3118 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3119 // Save signal flag |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3120 os::Aix::set_our_sigflags(SR_signum, act.sa_flags); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3121 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3122 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3123 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3124 static int SR_finalize() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3125 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3126 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3127 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3128 static int sr_notify(OSThread* osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3129 int status = pthread_kill(osthread->pthread_id(), SR_signum); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3130 assert_status(status == 0, status, "pthread_kill"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3131 return status; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3132 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3133 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3134 // "Randomly" selected value for how long we want to spin |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3135 // before bailing out on suspending a thread, also how often |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3136 // we send a signal to a thread we want to resume |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3137 static const int RANDOMLY_LARGE_INTEGER = 1000000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3138 static const int RANDOMLY_LARGE_INTEGER2 = 100; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3139 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3140 // returns true on success and false on error - really an error is fatal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3141 // but this seems the normal response to library errors |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3142 static bool do_suspend(OSThread* osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3143 assert(osthread->sr.is_running(), "thread should be running"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3144 // mark as suspended and send signal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3145 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3146 if (osthread->sr.request_suspend() != os::SuspendResume::SR_SUSPEND_REQUEST) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3147 // failed to switch, state wasn't running? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3148 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3149 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3150 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3151 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3152 if (sr_notify(osthread) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3153 // try to cancel, switch to running |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3154 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3155 os::SuspendResume::State result = osthread->sr.cancel_suspend(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3156 if (result == os::SuspendResume::SR_RUNNING) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3157 // cancelled |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3158 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3159 } else if (result == os::SuspendResume::SR_SUSPENDED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3160 // somehow managed to suspend |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3161 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3162 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3163 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3164 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3165 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3166 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3167 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3168 // managed to send the signal and switch to SUSPEND_REQUEST, now wait for SUSPENDED |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3169 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3170 for (int n = 0; !osthread->sr.is_suspended(); n++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3171 for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3172 os::yield_all(i); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3173 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3174 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3175 // timeout, try to cancel the request |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3176 if (n >= RANDOMLY_LARGE_INTEGER) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3177 os::SuspendResume::State cancelled = osthread->sr.cancel_suspend(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3178 if (cancelled == os::SuspendResume::SR_RUNNING) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3179 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3180 } else if (cancelled == os::SuspendResume::SR_SUSPENDED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3181 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3182 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3183 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3184 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3185 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3186 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3187 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3188 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3189 guarantee(osthread->sr.is_suspended(), "Must be suspended"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3190 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3191 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3192 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3193 static void do_resume(OSThread* osthread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3194 //assert(osthread->sr.is_suspended(), "thread should be suspended"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3195 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3196 if (osthread->sr.request_wakeup() != os::SuspendResume::SR_WAKEUP_REQUEST) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3197 // failed to switch to WAKEUP_REQUEST |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3198 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3199 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3200 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3201 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3202 while (!osthread->sr.is_running()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3203 if (sr_notify(osthread) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3204 for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3205 for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3206 os::yield_all(i); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3207 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3208 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3209 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3210 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3211 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3212 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3213 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3214 guarantee(osthread->sr.is_running(), "Must be running!"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3215 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3216 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3217 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3218 // interrupt support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3219 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3220 void os::interrupt(Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3221 assert(Thread::current() == thread || Threads_lock->owned_by_self(), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3222 "possibility of dangling Thread pointer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3223 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3224 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3225 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3226 if (!osthread->interrupted()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3227 osthread->set_interrupted(true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3228 // More than one thread can get here with the same value of osthread, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3229 // resulting in multiple notifications. We do, however, want the store |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3230 // to interrupted() to be visible to other threads before we execute unpark(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3231 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3232 ParkEvent * const slp = thread->_SleepEvent; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3233 if (slp != NULL) slp->unpark(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3234 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3235 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3236 // For JSR166. Unpark even if interrupt status already was set |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3237 if (thread->is_Java_thread()) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3238 ((JavaThread*)thread)->parker()->unpark(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3239 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3240 ParkEvent * ev = thread->_ParkEvent; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3241 if (ev != NULL) ev->unpark(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3242 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3243 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3244 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3245 bool os::is_interrupted(Thread* thread, bool clear_interrupted) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3246 assert(Thread::current() == thread || Threads_lock->owned_by_self(), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3247 "possibility of dangling Thread pointer"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3248 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3249 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3250 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3251 bool interrupted = osthread->interrupted(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3252 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3253 if (interrupted && clear_interrupted) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3254 osthread->set_interrupted(false); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3255 // consider thread->_SleepEvent->reset() ... optional optimization |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3256 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3257 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3258 return interrupted; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3259 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3260 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3261 /////////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3262 // signal handling (except suspend/resume) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3263 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3264 // This routine may be used by user applications as a "hook" to catch signals. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3265 // The user-defined signal handler must pass unrecognized signals to this |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3266 // routine, and if it returns true (non-zero), then the signal handler must |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3267 // return immediately. If the flag "abort_if_unrecognized" is true, then this |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3268 // routine will never retun false (zero), but instead will execute a VM panic |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3269 // routine kill the process. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3270 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3271 // If this routine returns false, it is OK to call it again. This allows |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3272 // the user-defined signal handler to perform checks either before or after |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3273 // the VM performs its own checks. Naturally, the user code would be making |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3274 // a serious error if it tried to handle an exception (such as a null check |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3275 // or breakpoint) that the VM was generating for its own correct operation. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3276 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3277 // This routine may recognize any of the following kinds of signals: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3278 // SIGBUS, SIGSEGV, SIGILL, SIGFPE, SIGQUIT, SIGPIPE, SIGXFSZ, SIGUSR1. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3279 // It should be consulted by handlers for any of those signals. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3280 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3281 // The caller of this routine must pass in the three arguments supplied |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3282 // to the function referred to in the "sa_sigaction" (not the "sa_handler") |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3283 // field of the structure passed to sigaction(). This routine assumes that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3284 // the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3285 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3286 // Note that the VM will print warnings if it detects conflicting signal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3287 // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3288 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3289 extern "C" JNIEXPORT int |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3290 JVM_handle_aix_signal(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3291 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3292 // Set thread signal mask (for some reason on AIX sigthreadmask() seems |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3293 // to be the thing to call; documentation is not terribly clear about whether |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3294 // pthread_sigmask also works, and if it does, whether it does the same. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3295 bool set_thread_signal_mask(int how, const sigset_t* set, sigset_t* oset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3296 const int rc = ::pthread_sigmask(how, set, oset); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3297 // return value semantics differ slightly for error case: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3298 // pthread_sigmask returns error number, sigthreadmask -1 and sets global errno |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3299 // (so, pthread_sigmask is more theadsafe for error handling) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3300 // But success is always 0. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3301 return rc == 0 ? true : false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3302 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3303 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3304 // Function to unblock all signals which are, according |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3305 // to POSIX, typical program error signals. If they happen while being blocked, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3306 // they typically will bring down the process immediately. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3307 bool unblock_program_error_signals() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3308 sigset_t set; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3309 ::sigemptyset(&set); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3310 ::sigaddset(&set, SIGILL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3311 ::sigaddset(&set, SIGBUS); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3312 ::sigaddset(&set, SIGFPE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3313 ::sigaddset(&set, SIGSEGV); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3314 return set_thread_signal_mask(SIG_UNBLOCK, &set, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3315 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3316 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3317 // Renamed from 'signalHandler' to avoid collision with other shared libs. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3318 void javaSignalHandler(int sig, siginfo_t* info, void* uc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3319 assert(info != NULL && uc != NULL, "it must be old kernel"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3320 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3321 // Never leave program error signals blocked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3322 // on all our platforms they would bring down the process immediately when |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3323 // getting raised while being blocked. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3324 unblock_program_error_signals(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3325 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3326 JVM_handle_aix_signal(sig, info, uc, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3327 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3328 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3329 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3330 // This boolean allows users to forward their own non-matching signals |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3331 // to JVM_handle_aix_signal, harmlessly. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3332 bool os::Aix::signal_handlers_are_installed = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3333 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3334 // For signal-chaining |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3335 struct sigaction os::Aix::sigact[MAXSIGNUM]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3336 unsigned int os::Aix::sigs = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3337 bool os::Aix::libjsig_is_loaded = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3338 typedef struct sigaction *(*get_signal_t)(int); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3339 get_signal_t os::Aix::get_signal_action = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3340 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3341 struct sigaction* os::Aix::get_chained_signal_action(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3342 struct sigaction *actp = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3343 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3344 if (libjsig_is_loaded) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3345 // Retrieve the old signal handler from libjsig |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3346 actp = (*get_signal_action)(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3347 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3348 if (actp == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3349 // Retrieve the preinstalled signal handler from jvm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3350 actp = get_preinstalled_handler(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3351 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3352 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3353 return actp; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3354 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3355 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3356 static bool call_chained_handler(struct sigaction *actp, int sig, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3357 siginfo_t *siginfo, void *context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3358 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3359 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3360 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3361 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3362 bool os::Aix::chained_handler(int sig, siginfo_t* siginfo, void* context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3363 bool chained = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3364 // signal-chaining |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3365 if (UseSignalChaining) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3366 struct sigaction *actp = get_chained_signal_action(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3367 if (actp != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3368 chained = call_chained_handler(actp, sig, siginfo, context); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3369 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3370 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3371 return chained; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3372 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3373 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3374 struct sigaction* os::Aix::get_preinstalled_handler(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3375 if ((((unsigned int)1 << sig) & sigs) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3376 return &sigact[sig]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3377 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3378 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3379 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3380 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3381 void os::Aix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3382 assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3383 sigact[sig] = oldAct; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3384 sigs |= (unsigned int)1 << sig; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3385 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3386 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3387 // for diagnostic |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3388 int os::Aix::sigflags[MAXSIGNUM]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3389 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3390 int os::Aix::get_our_sigflags(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3391 assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3392 return sigflags[sig]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3393 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3394 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3395 void os::Aix::set_our_sigflags(int sig, int flags) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3396 assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3397 sigflags[sig] = flags; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3398 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3399 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3400 void os::Aix::set_signal_handler(int sig, bool set_installed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3401 // Check for overwrite. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3402 struct sigaction oldAct; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3403 sigaction(sig, (struct sigaction*)NULL, &oldAct); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3404 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3405 void* oldhand = oldAct.sa_sigaction |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3406 ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3407 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3408 // Renamed 'signalHandler' to avoid collision with other shared libs. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3409 if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3410 oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3411 oldhand != CAST_FROM_FN_PTR(void*, (sa_sigaction_t)javaSignalHandler)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3412 if (AllowUserSignalHandlers || !set_installed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3413 // Do not overwrite; user takes responsibility to forward to us. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3414 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3415 } else if (UseSignalChaining) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3416 // save the old handler in jvm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3417 save_preinstalled_handler(sig, oldAct); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3418 // libjsig also interposes the sigaction() call below and saves the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3419 // old sigaction on it own. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3420 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3421 fatal(err_msg("Encountered unexpected pre-existing sigaction handler " |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3422 "%#lx for signal %d.", (long)oldhand, sig)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3423 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3424 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3425 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3426 struct sigaction sigAct; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3427 sigfillset(&(sigAct.sa_mask)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3428 if (!set_installed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3429 sigAct.sa_handler = SIG_DFL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3430 sigAct.sa_flags = SA_RESTART; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3431 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3432 // Renamed 'signalHandler' to avoid collision with other shared libs. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3433 sigAct.sa_sigaction = javaSignalHandler; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3434 sigAct.sa_flags = SA_SIGINFO|SA_RESTART; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3435 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3436 // Save flags, which are set by ours |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3437 assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3438 sigflags[sig] = sigAct.sa_flags; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3439 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3440 int ret = sigaction(sig, &sigAct, &oldAct); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3441 assert(ret == 0, "check"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3442 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3443 void* oldhand2 = oldAct.sa_sigaction |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3444 ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3445 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3446 assert(oldhand2 == oldhand, "no concurrent signal handler installation"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3447 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3448 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3449 // install signal handlers for signals that HotSpot needs to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3450 // handle in order to support Java-level exception handling. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3451 void os::Aix::install_signal_handlers() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3452 if (!signal_handlers_are_installed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3453 signal_handlers_are_installed = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3454 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3455 // signal-chaining |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3456 typedef void (*signal_setting_t)(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3457 signal_setting_t begin_signal_setting = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3458 signal_setting_t end_signal_setting = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3459 begin_signal_setting = CAST_TO_FN_PTR(signal_setting_t, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3460 dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3461 if (begin_signal_setting != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3462 end_signal_setting = CAST_TO_FN_PTR(signal_setting_t, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3463 dlsym(RTLD_DEFAULT, "JVM_end_signal_setting")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3464 get_signal_action = CAST_TO_FN_PTR(get_signal_t, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3465 dlsym(RTLD_DEFAULT, "JVM_get_signal_action")); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3466 libjsig_is_loaded = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3467 assert(UseSignalChaining, "should enable signal-chaining"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3468 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3469 if (libjsig_is_loaded) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3470 // Tell libjsig jvm is setting signal handlers |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3471 (*begin_signal_setting)(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3472 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3473 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3474 set_signal_handler(SIGSEGV, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3475 set_signal_handler(SIGPIPE, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3476 set_signal_handler(SIGBUS, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3477 set_signal_handler(SIGILL, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3478 set_signal_handler(SIGFPE, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3479 set_signal_handler(SIGTRAP, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3480 set_signal_handler(SIGXFSZ, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3481 set_signal_handler(SIGDANGER, true); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3482 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3483 if (libjsig_is_loaded) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3484 // Tell libjsig jvm finishes setting signal handlers |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3485 (*end_signal_setting)(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3486 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3487 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3488 // We don't activate signal checker if libjsig is in place, we trust ourselves |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3489 // and if UserSignalHandler is installed all bets are off. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3490 // Log that signal checking is off only if -verbose:jni is specified. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3491 if (CheckJNICalls) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3492 if (libjsig_is_loaded) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3493 tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3494 check_signals = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3495 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3496 if (AllowUserSignalHandlers) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3497 tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3498 check_signals = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3499 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3500 // need to initialize check_signal_done |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3501 ::sigemptyset(&check_signal_done); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3502 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3503 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3504 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3505 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3506 static const char* get_signal_handler_name(address handler, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3507 char* buf, int buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3508 int offset; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3509 bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3510 if (found) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3511 // skip directory names |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3512 const char *p1, *p2; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3513 p1 = buf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3514 size_t len = strlen(os::file_separator()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3515 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3516 // The way os::dll_address_to_library_name is implemented on Aix |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3517 // right now, it always returns -1 for the offset which is not |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3518 // terribly informative. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3519 // Will fix that. For now, omit the offset. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3520 jio_snprintf(buf, buflen, "%s", p1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3521 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3522 jio_snprintf(buf, buflen, PTR_FORMAT, handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3523 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3524 return buf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3525 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3526 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3527 static void print_signal_handler(outputStream* st, int sig, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3528 char* buf, size_t buflen) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3529 struct sigaction sa; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3530 sigaction(sig, NULL, &sa); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3531 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3532 st->print("%s: ", os::exception_name(sig, buf, buflen)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3533 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3534 address handler = (sa.sa_flags & SA_SIGINFO) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3535 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3536 : CAST_FROM_FN_PTR(address, sa.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3537 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3538 if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3539 st->print("SIG_DFL"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3540 } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3541 st->print("SIG_IGN"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3542 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3543 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3544 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3545 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3546 // Print readable mask. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3547 st->print(", sa_mask[0]="); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3548 os::Posix::print_signal_set_short(st, &sa.sa_mask); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3549 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3550 address rh = VMError::get_resetted_sighandler(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3551 // May be, handler was resetted by VMError? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3552 if (rh != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3553 handler = rh; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3554 sa.sa_flags = VMError::get_resetted_sigflags(sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3555 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3556 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3557 // Print textual representation of sa_flags. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3558 st->print(", sa_flags="); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3559 os::Posix::print_sa_flags(st, sa.sa_flags); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3560 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3561 // Check: is it our handler? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3562 if (handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)javaSignalHandler) || |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3563 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3564 // It is our signal handler. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3565 // Check for flags, reset system-used one! |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3566 if ((int)sa.sa_flags != os::Aix::get_our_sigflags(sig)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3567 st->print(", flags was changed from " PTR32_FORMAT ", consider using jsig library", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3568 os::Aix::get_our_sigflags(sig)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3569 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3570 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3571 st->cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3572 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3573 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3574 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3575 #define DO_SIGNAL_CHECK(sig) \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3576 if (!sigismember(&check_signal_done, sig)) \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3577 os::Aix::check_signal_handler(sig) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3578 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3579 // This method is a periodic task to check for misbehaving JNI applications |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3580 // under CheckJNI, we can add any periodic checks here |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3581 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3582 void os::run_periodic_checks() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3583 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3584 if (check_signals == false) return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3585 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3586 // SEGV and BUS if overridden could potentially prevent |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3587 // generation of hs*.log in the event of a crash, debugging |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3588 // such a case can be very challenging, so we absolutely |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3589 // check the following for a good measure: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3590 DO_SIGNAL_CHECK(SIGSEGV); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3591 DO_SIGNAL_CHECK(SIGILL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3592 DO_SIGNAL_CHECK(SIGFPE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3593 DO_SIGNAL_CHECK(SIGBUS); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3594 DO_SIGNAL_CHECK(SIGPIPE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3595 DO_SIGNAL_CHECK(SIGXFSZ); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3596 if (UseSIGTRAP) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3597 DO_SIGNAL_CHECK(SIGTRAP); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3598 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3599 DO_SIGNAL_CHECK(SIGDANGER); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3600 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3601 // ReduceSignalUsage allows the user to override these handlers |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3602 // see comments at the very top and jvm_solaris.h |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3603 if (!ReduceSignalUsage) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3604 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3605 DO_SIGNAL_CHECK(SHUTDOWN2_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3606 DO_SIGNAL_CHECK(SHUTDOWN3_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3607 DO_SIGNAL_CHECK(BREAK_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3608 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3609 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3610 DO_SIGNAL_CHECK(SR_signum); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3611 DO_SIGNAL_CHECK(INTERRUPT_SIGNAL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3612 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3613 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3614 typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3615 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3616 static os_sigaction_t os_sigaction = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3617 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3618 void os::Aix::check_signal_handler(int sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3619 char buf[O_BUFLEN]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3620 address jvmHandler = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3621 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3622 struct sigaction act; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3623 if (os_sigaction == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3624 // only trust the default sigaction, in case it has been interposed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3625 os_sigaction = (os_sigaction_t)dlsym(RTLD_DEFAULT, "sigaction"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3626 if (os_sigaction == NULL) return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3627 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3628 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3629 os_sigaction(sig, (struct sigaction*)NULL, &act); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3630 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3631 address thisHandler = (act.sa_flags & SA_SIGINFO) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3632 ? CAST_FROM_FN_PTR(address, act.sa_sigaction) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3633 : CAST_FROM_FN_PTR(address, act.sa_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3634 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3635 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3636 switch(sig) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3637 case SIGSEGV: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3638 case SIGBUS: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3639 case SIGFPE: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3640 case SIGPIPE: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3641 case SIGILL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3642 case SIGXFSZ: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3643 // Renamed 'signalHandler' to avoid collision with other shared libs. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3644 jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)javaSignalHandler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3645 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3646 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3647 case SHUTDOWN1_SIGNAL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3648 case SHUTDOWN2_SIGNAL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3649 case SHUTDOWN3_SIGNAL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3650 case BREAK_SIGNAL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3651 jvmHandler = (address)user_handler(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3652 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3653 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3654 case INTERRUPT_SIGNAL: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3655 jvmHandler = CAST_FROM_FN_PTR(address, SIG_DFL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3656 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3657 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3658 default: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3659 if (sig == SR_signum) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3660 jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3661 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3662 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3663 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3664 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3665 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3666 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3667 if (thisHandler != jvmHandler) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3668 tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3669 tty->print("expected:%s", get_signal_handler_name(jvmHandler, buf, O_BUFLEN)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3670 tty->print_cr(" found:%s", get_signal_handler_name(thisHandler, buf, O_BUFLEN)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3671 // No need to check this sig any longer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3672 sigaddset(&check_signal_done, sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3673 } else if (os::Aix::get_our_sigflags(sig) != 0 && (int)act.sa_flags != os::Aix::get_our_sigflags(sig)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3674 tty->print("Warning: %s handler flags ", exception_name(sig, buf, O_BUFLEN)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3675 tty->print("expected:" PTR32_FORMAT, os::Aix::get_our_sigflags(sig)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3676 tty->print_cr(" found:" PTR32_FORMAT, act.sa_flags); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3677 // No need to check this sig any longer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3678 sigaddset(&check_signal_done, sig); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3679 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3680 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3681 // Dump all the signal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3682 if (sigismember(&check_signal_done, sig)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3683 print_signal_handlers(tty, buf, O_BUFLEN); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3684 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3685 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3686 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3687 extern bool signal_name(int signo, char* buf, size_t len); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3688 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3689 const char* os::exception_name(int exception_code, char* buf, size_t size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3690 if (0 < exception_code && exception_code <= SIGRTMAX) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3691 // signal |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3692 if (!signal_name(exception_code, buf, size)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3693 jio_snprintf(buf, size, "SIG%d", exception_code); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3694 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3695 return buf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3696 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3697 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3698 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3699 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3700 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3701 // To install functions for atexit system call |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3702 extern "C" { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3703 static void perfMemory_exit_helper() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3704 perfMemory_exit(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3705 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3706 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3707 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3708 // This is called _before_ the most of global arguments have been parsed. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3709 void os::init(void) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3710 // This is basic, we want to know if that ever changes. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3711 // (shared memory boundary is supposed to be a 256M aligned) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3712 assert(SHMLBA == ((uint64_t)0x10000000ULL)/*256M*/, "unexpected"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3713 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3714 // First off, we need to know whether we run on AIX or PASE, and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3715 // the OS level we run on. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3716 os::Aix::initialize_os_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3717 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3718 // Scan environment (SPEC1170 behaviour, etc) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3719 os::Aix::scan_environment(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3720 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3721 // Check which pages are supported by AIX. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3722 os::Aix::query_multipage_support(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3723 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3724 // Next, we need to initialize libo4 and libperfstat libraries. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3725 if (os::Aix::on_pase()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3726 os::Aix::initialize_libo4(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3727 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3728 os::Aix::initialize_libperfstat(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3729 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3730 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3731 // Reset the perfstat information provided by ODM. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3732 if (os::Aix::on_aix()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3733 libperfstat::perfstat_reset(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3734 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3735 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3736 // Now initialze basic system properties. Note that for some of the values we |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3737 // need libperfstat etc. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3738 os::Aix::initialize_system_info(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3739 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3740 // Initialize large page support. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3741 if (UseLargePages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3742 os::large_page_init(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3743 if (!UseLargePages) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3744 // initialize os::_page_sizes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3745 _page_sizes[0] = Aix::page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3746 _page_sizes[1] = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3747 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3748 fprintf(stderr, "Large Page initialization failed: setting UseLargePages=0.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3749 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3750 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3751 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3752 // initialize os::_page_sizes |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3753 _page_sizes[0] = Aix::page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3754 _page_sizes[1] = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3755 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3756 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3757 // debug trace |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3758 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3759 fprintf(stderr, "os::vm_page_size 0x%llX\n", os::vm_page_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3760 fprintf(stderr, "os::large_page_size 0x%llX\n", os::large_page_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3761 fprintf(stderr, "os::_page_sizes = ( "); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3762 for (int i = 0; _page_sizes[i]; i ++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3763 fprintf(stderr, " %s ", describe_pagesize(_page_sizes[i])); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3764 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3765 fprintf(stderr, ")\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3766 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3767 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3768 _initial_pid = getpid(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3769 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3770 clock_tics_per_sec = sysconf(_SC_CLK_TCK); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3771 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3772 init_random(1234567); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3773 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3774 ThreadCritical::initialize(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3775 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3776 // Main_thread points to the aboriginal thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3777 Aix::_main_thread = pthread_self(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3778 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3779 initial_time_count = os::elapsed_counter(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3780 pthread_mutex_init(&dl_mutex, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3781 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3782 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3783 // this is called _after_ the global arguments have been parsed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3784 jint os::init_2(void) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3785 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3786 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3787 fprintf(stderr, "processor count: %d\n", os::_processor_count); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3788 fprintf(stderr, "physical memory: %lu\n", Aix::_physical_memory); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3789 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3790 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3791 // initially build up the loaded dll map |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3792 LoadedLibraries::reload(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3793 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3794 const int page_size = Aix::page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3795 const int map_size = page_size; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3796 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3797 address map_address = (address) MAP_FAILED; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3798 const int prot = PROT_READ; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3799 const int flags = MAP_PRIVATE|MAP_ANONYMOUS; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3800 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3801 // use optimized addresses for the polling page, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3802 // e.g. map it to a special 32-bit address. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3803 if (OptimizePollingPageLocation) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3804 // architecture-specific list of address wishes: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3805 address address_wishes[] = { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3806 // AIX: addresses lower than 0x30000000 don't seem to work on AIX. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3807 // PPC64: all address wishes are non-negative 32 bit values where |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3808 // the lower 16 bits are all zero. we can load these addresses |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3809 // with a single ppc_lis instruction. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3810 (address) 0x30000000, (address) 0x31000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3811 (address) 0x32000000, (address) 0x33000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3812 (address) 0x40000000, (address) 0x41000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3813 (address) 0x42000000, (address) 0x43000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3814 (address) 0x50000000, (address) 0x51000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3815 (address) 0x52000000, (address) 0x53000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3816 (address) 0x60000000, (address) 0x61000000, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3817 (address) 0x62000000, (address) 0x63000000 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3818 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3819 int address_wishes_length = sizeof(address_wishes)/sizeof(address); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3820 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3821 // iterate over the list of address wishes: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3822 for (int i=0; i<address_wishes_length; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3823 // try to map with current address wish. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3824 // AIX: AIX needs MAP_FIXED if we provide an address and mmap will |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3825 // fail if the address is already mapped. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3826 map_address = (address) ::mmap(address_wishes[i] - (ssize_t)page_size, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3827 map_size, prot, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3828 flags | MAP_FIXED, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3829 -1, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3830 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3831 fprintf(stderr, "SafePoint Polling Page address: %p (wish) => %p\n", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3832 address_wishes[i], map_address + (ssize_t)page_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3833 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3834 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3835 if (map_address + (ssize_t)page_size == address_wishes[i]) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3836 // map succeeded and map_address is at wished address, exit loop. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3837 break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3838 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3839 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3840 if (map_address != (address) MAP_FAILED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3841 // map succeeded, but polling_page is not at wished address, unmap and continue. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3842 ::munmap(map_address, map_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3843 map_address = (address) MAP_FAILED; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3844 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3845 // map failed, continue loop. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3846 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3847 } // end OptimizePollingPageLocation |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3848 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3849 if (map_address == (address) MAP_FAILED) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3850 map_address = (address) ::mmap(NULL, map_size, prot, flags, -1, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3851 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3852 guarantee(map_address != MAP_FAILED, "os::init_2: failed to allocate polling page"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3853 os::set_polling_page(map_address); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3854 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3855 if (!UseMembar) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3856 address mem_serialize_page = (address) ::mmap(NULL, Aix::page_size(), PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3857 guarantee(mem_serialize_page != NULL, "mmap Failed for memory serialize page"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3858 os::set_memory_serialize_page(mem_serialize_page); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3859 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3860 #ifndef PRODUCT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3861 if (Verbose && PrintMiscellaneous) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3862 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3863 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3864 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3865 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3866 // initialize suspend/resume support - must do this before signal_sets_init() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3867 if (SR_initialize() != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3868 perror("SR_initialize failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3869 return JNI_ERR; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3870 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3871 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3872 Aix::signal_sets_init(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3873 Aix::install_signal_handlers(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3874 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3875 // Check minimum allowable stack size for thread creation and to initialize |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3876 // the java system classes, including StackOverflowError - depends on page |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3877 // size. Add a page for compiler2 recursion in main thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3878 // Add in 2*BytesPerWord times page size to account for VM stack during |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3879 // class initialization depending on 32 or 64 bit VM. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3880 os::Aix::min_stack_allowed = MAX2(os::Aix::min_stack_allowed, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3881 (size_t)(StackYellowPages+StackRedPages+StackShadowPages + |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3882 2*BytesPerWord COMPILER2_PRESENT(+1)) * Aix::page_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3883 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3884 size_t threadStackSizeInBytes = ThreadStackSize * K; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3885 if (threadStackSizeInBytes != 0 && |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3886 threadStackSizeInBytes < os::Aix::min_stack_allowed) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3887 tty->print_cr("\nThe stack size specified is too small, " |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3888 "Specify at least %dk", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3889 os::Aix::min_stack_allowed / K); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3890 return JNI_ERR; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3891 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3892 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3893 // Make the stack size a multiple of the page size so that |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3894 // the yellow/red zones can be guarded. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3895 // note that this can be 0, if no default stacksize was set |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3896 JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size())); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3897 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3898 Aix::libpthread_init(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3899 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3900 if (MaxFDLimit) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3901 // set the number of file descriptors to max. print out error |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3902 // if getrlimit/setrlimit fails but continue regardless. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3903 struct rlimit nbr_files; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3904 int status = getrlimit(RLIMIT_NOFILE, &nbr_files); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3905 if (status != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3906 if (PrintMiscellaneous && (Verbose || WizardMode)) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3907 perror("os::init_2 getrlimit failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3908 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3909 nbr_files.rlim_cur = nbr_files.rlim_max; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3910 status = setrlimit(RLIMIT_NOFILE, &nbr_files); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3911 if (status != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3912 if (PrintMiscellaneous && (Verbose || WizardMode)) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3913 perror("os::init_2 setrlimit failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3914 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3915 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3916 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3917 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3918 if (PerfAllowAtExitRegistration) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3919 // only register atexit functions if PerfAllowAtExitRegistration is set. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3920 // atexit functions can be delayed until process exit time, which |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3921 // can be problematic for embedded VM situations. Embedded VMs should |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3922 // call DestroyJavaVM() to assure that VM resources are released. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3923 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3924 // note: perfMemory_exit_helper atexit function may be removed in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3925 // the future if the appropriate cleanup code can be added to the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3926 // VM_Exit VMOperation's doit method. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3927 if (atexit(perfMemory_exit_helper) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3928 warning("os::init_2 atexit(perfMemory_exit_helper) failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3929 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3930 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3931 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3932 return JNI_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3933 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3934 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3935 // this is called at the end of vm_initialization |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3936 void os::init_3(void) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3937 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3938 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3939 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3940 // Mark the polling page as unreadable |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3941 void os::make_polling_page_unreadable(void) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3942 if (!guard_memory((char*)_polling_page, Aix::page_size())) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3943 fatal("Could not disable polling page"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3944 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3945 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3946 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3947 // Mark the polling page as readable |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3948 void os::make_polling_page_readable(void) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3949 // Changed according to os_linux.cpp. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3950 if (!checked_mprotect((char *)_polling_page, Aix::page_size(), PROT_READ)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3951 fatal(err_msg("Could not enable polling page at " PTR_FORMAT, _polling_page)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3952 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3953 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3954 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3955 int os::active_processor_count() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3956 int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3957 assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3958 return online_cpus; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3959 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3960 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3961 void os::set_native_thread_name(const char *name) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3962 // Not yet implemented. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3963 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3964 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3965 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3966 bool os::distribute_processes(uint length, uint* distribution) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3967 // Not yet implemented. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3968 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3969 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3970 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3971 bool os::bind_to_processor(uint processor_id) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3972 // Not yet implemented. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3973 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3974 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3975 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3976 void os::SuspendedThreadTask::internal_do_task() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3977 if (do_suspend(_thread->osthread())) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3978 SuspendedThreadTaskContext context(_thread, _thread->osthread()->ucontext()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3979 do_task(context); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3980 do_resume(_thread->osthread()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3981 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3982 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3983 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3984 class PcFetcher : public os::SuspendedThreadTask { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3985 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3986 PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3987 ExtendedPC result(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3988 protected: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3989 void do_task(const os::SuspendedThreadTaskContext& context); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3990 private: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3991 ExtendedPC _epc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3992 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3993 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3994 ExtendedPC PcFetcher::result() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3995 guarantee(is_done(), "task is not done yet."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3996 return _epc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3997 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3998 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3999 void PcFetcher::do_task(const os::SuspendedThreadTaskContext& context) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4000 Thread* thread = context.thread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4001 OSThread* osthread = thread->osthread(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4002 if (osthread->ucontext() != NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4003 _epc = os::Aix::ucontext_get_pc((ucontext_t *) context.ucontext()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4004 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4005 // NULL context is unexpected, double-check this is the VMThread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4006 guarantee(thread->is_VM_thread(), "can only be called for VMThread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4007 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4008 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4009 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4010 // Suspends the target using the signal mechanism and then grabs the PC before |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4011 // resuming the target. Used by the flat-profiler only |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4012 ExtendedPC os::get_thread_pc(Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4013 // Make sure that it is called by the watcher for the VMThread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4014 assert(Thread::current()->is_Watcher_thread(), "Must be watcher"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4015 assert(thread->is_VM_thread(), "Can only be called for VMThread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4016 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4017 PcFetcher fetcher(thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4018 fetcher.run(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4019 return fetcher.result(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4020 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4021 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4022 // Not neede on Aix. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4023 // int os::Aix::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4024 // } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4025 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4026 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4027 // debug support |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4028 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4029 static address same_page(address x, address y) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4030 intptr_t page_bits = -os::vm_page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4031 if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4032 return x; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4033 else if (x > y) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4034 return (address)(intptr_t(y) | ~page_bits) + 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4035 else |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4036 return (address)(intptr_t(y) & page_bits); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4037 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4038 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4039 bool os::find(address addr, outputStream* st) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4040 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4041 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4042 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4043 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4044 //////////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4045 // misc |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4046 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4047 // This does not do anything on Aix. This is basically a hook for being |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4048 // able to use structured exception handling (thread-local exception filters) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4049 // on, e.g., Win32. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4050 void |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4051 os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4052 JavaCallArguments* args, Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4053 f(value, method, args, thread); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4054 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4055 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4056 void os::print_statistics() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4057 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4058 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4059 int os::message_box(const char* title, const char* message) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4060 int i; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4061 fdStream err(defaultStream::error_fd()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4062 for (i = 0; i < 78; i++) err.print_raw("="); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4063 err.cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4064 err.print_raw_cr(title); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4065 for (i = 0; i < 78; i++) err.print_raw("-"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4066 err.cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4067 err.print_raw_cr(message); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4068 for (i = 0; i < 78; i++) err.print_raw("="); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4069 err.cr(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4070 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4071 char buf[16]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4072 // Prevent process from exiting upon "read error" without consuming all CPU |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4073 while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4074 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4075 return buf[0] == 'y' || buf[0] == 'Y'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4076 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4077 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4078 int os::stat(const char *path, struct stat *sbuf) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4079 char pathbuf[MAX_PATH]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4080 if (strlen(path) > MAX_PATH - 1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4081 errno = ENAMETOOLONG; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4082 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4083 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4084 os::native_path(strcpy(pathbuf, path)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4085 return ::stat(pathbuf, sbuf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4086 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4087 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4088 bool os::check_heap(bool force) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4089 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4090 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4091 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4092 // int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4093 // return ::vsnprintf(buf, count, format, args); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4094 // } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4095 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4096 // Is a (classpath) directory empty? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4097 bool os::dir_is_empty(const char* path) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4098 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4099 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4100 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4101 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4102 // This code originates from JDK's sysOpen and open64_w |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4103 // from src/solaris/hpi/src/system_md.c |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4104 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4105 #ifndef O_DELETE |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4106 #define O_DELETE 0x10000 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4107 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4108 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4109 // Open a file. Unlink the file immediately after open returns |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4110 // if the specified oflag has the O_DELETE flag set. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4111 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4112 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4113 int os::open(const char *path, int oflag, int mode) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4114 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4115 if (strlen(path) > MAX_PATH - 1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4116 errno = ENAMETOOLONG; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4117 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4118 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4119 int fd; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4120 int o_delete = (oflag & O_DELETE); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4121 oflag = oflag & ~O_DELETE; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4122 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4123 fd = ::open64(path, oflag, mode); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4124 if (fd == -1) return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4125 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4126 //If the open succeeded, the file might still be a directory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4127 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4128 struct stat64 buf64; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4129 int ret = ::fstat64(fd, &buf64); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4130 int st_mode = buf64.st_mode; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4131 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4132 if (ret != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4133 if ((st_mode & S_IFMT) == S_IFDIR) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4134 errno = EISDIR; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4135 ::close(fd); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4136 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4137 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4138 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4139 ::close(fd); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4140 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4141 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4142 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4143 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4144 // All file descriptors that are opened in the JVM and not |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4145 // specifically destined for a subprocess should have the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4146 // close-on-exec flag set. If we don't set it, then careless 3rd |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4147 // party native code might fork and exec without closing all |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4148 // appropriate file descriptors (e.g. as we do in closeDescriptors in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4149 // UNIXProcess.c), and this in turn might: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4150 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4151 // - cause end-of-file to fail to be detected on some file |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4152 // descriptors, resulting in mysterious hangs, or |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4153 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4154 // - might cause an fopen in the subprocess to fail on a system |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4155 // suffering from bug 1085341. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4156 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4157 // (Yes, the default setting of the close-on-exec flag is a Unix |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4158 // design flaw.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4159 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4160 // See: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4161 // 1085341: 32-bit stdio routines should support file descriptors >255 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4162 // 4843136: (process) pipe file descriptor from Runtime.exec not being closed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4163 // 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4164 #ifdef FD_CLOEXEC |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4165 { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4166 int flags = ::fcntl(fd, F_GETFD); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4167 if (flags != -1) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4168 ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4169 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4170 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4171 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4172 if (o_delete != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4173 ::unlink(path); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4174 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4175 return fd; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4176 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4177 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4178 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4179 // create binary file, rewriting existing file if required |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4180 int os::create_binary_file(const char* path, bool rewrite_existing) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4181 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4182 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4183 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4184 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4185 // return current position of file pointer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4186 jlong os::current_file_offset(int fd) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4187 return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4188 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4189 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4190 // move file pointer to the specified offset |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4191 jlong os::seek_to_file_offset(int fd, jlong offset) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4192 return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4193 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4194 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4195 // This code originates from JDK's sysAvailable |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4196 // from src/solaris/hpi/src/native_threads/src/sys_api_td.c |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4197 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4198 int os::available(int fd, jlong *bytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4199 jlong cur, end; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4200 int mode; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4201 struct stat64 buf64; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4202 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4203 if (::fstat64(fd, &buf64) >= 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4204 mode = buf64.st_mode; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4205 if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4206 // XXX: is the following call interruptible? If so, this might |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4207 // need to go through the INTERRUPT_IO() wrapper as for other |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4208 // blocking, interruptible calls in this file. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4209 int n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4210 if (::ioctl(fd, FIONREAD, &n) >= 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4211 *bytes = n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4212 return 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4213 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4214 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4215 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4216 if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4217 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4218 } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4219 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4220 } else if (::lseek64(fd, cur, SEEK_SET) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4221 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4222 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4223 *bytes = end - cur; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4224 return 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4225 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4226 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4227 int os::socket_available(int fd, jint *pbytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4228 // Linux doc says EINTR not returned, unlike Solaris |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4229 int ret = ::ioctl(fd, FIONREAD, pbytes); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4230 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4231 //%% note ioctl can return 0 when successful, JVM_SocketAvailable |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4232 // is expected to return 0 on failure and 1 on success to the jdk. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4233 return (ret < 0) ? 0 : 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4234 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4235 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4236 // Map a block of memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4237 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4238 char *addr, size_t bytes, bool read_only, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4239 bool allow_exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4240 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4241 return NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4242 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4243 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4244 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4245 // Remap a block of memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4246 char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4247 char *addr, size_t bytes, bool read_only, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4248 bool allow_exec) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4249 // same as map_memory() on this OS |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4250 return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4251 allow_exec); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4252 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4253 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4254 // Unmap a block of memory. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4255 bool os::pd_unmap_memory(char* addr, size_t bytes) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4256 return munmap(addr, bytes) == 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4257 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4258 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4259 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4260 // are used by JVM M&M and JVMTI to get user+sys or user CPU time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4261 // of a thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4262 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4263 // current_thread_cpu_time() and thread_cpu_time(Thread*) returns |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4264 // the fast estimate available on the platform. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4265 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4266 jlong os::current_thread_cpu_time() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4267 // return user + sys since the cost is the same |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4268 const jlong n = os::thread_cpu_time(Thread::current(), true /* user + sys */); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4269 assert(n >= 0, "negative CPU time"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4270 return n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4271 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4272 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4273 jlong os::thread_cpu_time(Thread* thread) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4274 // consistent with what current_thread_cpu_time() returns |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4275 const jlong n = os::thread_cpu_time(thread, true /* user + sys */); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4276 assert(n >= 0, "negative CPU time"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4277 return n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4278 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4279 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4280 jlong os::current_thread_cpu_time(bool user_sys_cpu_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4281 const jlong n = os::thread_cpu_time(Thread::current(), user_sys_cpu_time); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4282 assert(n >= 0, "negative CPU time"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4283 return n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4284 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4285 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4286 static bool thread_cpu_time_unchecked(Thread* thread, jlong* p_sys_time, jlong* p_user_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4287 bool error = false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4288 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4289 jlong sys_time = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4290 jlong user_time = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4291 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4292 // reimplemented using getthrds64(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4293 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4294 // goes like this: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4295 // For the thread in question, get the kernel thread id. Then get the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4296 // kernel thread statistics using that id. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4297 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4298 // This only works of course when no pthread scheduling is used, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4299 // ie there is a 1:1 relationship to kernel threads. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4300 // On AIX, see AIXTHREAD_SCOPE variable. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4301 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4302 pthread_t pthtid = thread->osthread()->pthread_id(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4303 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4304 // retrieve kernel thread id for the pthread: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4305 tid64_t tid = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4306 struct __pthrdsinfo pinfo; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4307 // I just love those otherworldly IBM APIs which force me to hand down |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4308 // dummy buffers for stuff I dont care for... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4309 char dummy[1]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4310 int dummy_size = sizeof(dummy); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4311 if (pthread_getthrds_np(&pthtid, PTHRDSINFO_QUERY_TID, &pinfo, sizeof(pinfo), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4312 dummy, &dummy_size) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4313 tid = pinfo.__pi_tid; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4314 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4315 tty->print_cr("pthread_getthrds_np failed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4316 error = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4317 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4318 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4319 // retrieve kernel timing info for that kernel thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4320 if (!error) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4321 struct thrdentry64 thrdentry; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4322 if (getthrds64(getpid(), &thrdentry, sizeof(thrdentry), &tid, 1) == 1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4323 sys_time = thrdentry.ti_ru.ru_stime.tv_sec * 1000000000LL + thrdentry.ti_ru.ru_stime.tv_usec * 1000LL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4324 user_time = thrdentry.ti_ru.ru_utime.tv_sec * 1000000000LL + thrdentry.ti_ru.ru_utime.tv_usec * 1000LL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4325 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4326 tty->print_cr("pthread_getthrds_np failed."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4327 error = true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4328 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4329 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4330 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4331 if (p_sys_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4332 *p_sys_time = sys_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4333 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4334 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4335 if (p_user_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4336 *p_user_time = user_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4337 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4338 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4339 if (error) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4340 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4341 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4342 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4343 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4344 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4345 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4346 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4347 jlong sys_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4348 jlong user_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4349 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4350 if (!thread_cpu_time_unchecked(thread, &sys_time, &user_time)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4351 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4352 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4353 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4354 return user_sys_cpu_time ? sys_time + user_time : user_time; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4355 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4356 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4357 void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4358 info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4359 info_ptr->may_skip_backward = false; // elapsed time not wall time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4360 info_ptr->may_skip_forward = false; // elapsed time not wall time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4361 info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4362 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4363 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4364 void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4365 info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4366 info_ptr->may_skip_backward = false; // elapsed time not wall time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4367 info_ptr->may_skip_forward = false; // elapsed time not wall time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4368 info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4369 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4370 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4371 bool os::is_thread_cpu_time_supported() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4372 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4373 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4374 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4375 // System loadavg support. Returns -1 if load average cannot be obtained. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4376 // For now just return the system wide load average (no processor sets). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4377 int os::loadavg(double values[], int nelem) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4378 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4379 // Implemented using libperfstat on AIX. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4380 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4381 guarantee(nelem >= 0 && nelem <= 3, "argument error"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4382 guarantee(values, "argument error"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4383 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4384 if (os::Aix::on_pase()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4385 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4386 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4387 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4388 // AIX: use libperfstat |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4389 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4390 // See also: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4391 // http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/perfstat_cputot.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4392 // /usr/include/libperfstat.h: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4393 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4394 // Use the already AIX version independent get_cpuinfo. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4395 os::Aix::cpuinfo_t ci; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4396 if (os::Aix::get_cpuinfo(&ci)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4397 for (int i = 0; i < nelem; i++) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4398 values[i] = ci.loadavg[i]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4399 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4400 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4401 return -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4402 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4403 return nelem; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4404 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4405 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4406 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4407 void os::pause() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4408 char filename[MAX_PATH]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4409 if (PauseAtStartupFile && PauseAtStartupFile[0]) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4410 jio_snprintf(filename, MAX_PATH, PauseAtStartupFile); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4411 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4412 jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4413 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4414 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4415 int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4416 if (fd != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4417 struct stat buf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4418 ::close(fd); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4419 while (::stat(filename, &buf) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4420 (void)::poll(NULL, 0, 100); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4421 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4422 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4423 jio_fprintf(stderr, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4424 "Could not open pause file '%s', continuing immediately.\n", filename); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4425 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4426 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4427 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4428 bool os::Aix::is_primordial_thread() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4429 if (pthread_self() == (pthread_t)1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4430 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4431 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4432 return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4433 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4434 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4435 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4436 // OS recognitions (PASE/AIX, OS level) call this before calling any |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4437 // one of Aix::on_pase(), Aix::os_version() static |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4438 void os::Aix::initialize_os_info() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4439 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4440 assert(_on_pase == -1 && _os_version == -1, "already called."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4441 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4442 struct utsname uts; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4443 memset(&uts, 0, sizeof(uts)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4444 strcpy(uts.sysname, "?"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4445 if (::uname(&uts) == -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4446 fprintf(stderr, "uname failed (%d)\n", errno); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4447 guarantee(0, "Could not determine whether we run on AIX or PASE"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4448 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4449 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4450 fprintf(stderr,"uname says: sysname \"%s\" version \"%s\" release \"%s\" " |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4451 "node \"%s\" machine \"%s\"\n", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4452 uts.sysname, uts.version, uts.release, uts.nodename, uts.machine); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4453 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4454 const int major = atoi(uts.version); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4455 assert(major > 0, "invalid OS version"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4456 const int minor = atoi(uts.release); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4457 assert(minor > 0, "invalid OS release"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4458 _os_version = (major << 8) | minor; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4459 if (strcmp(uts.sysname, "OS400") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4460 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4461 } else if (strcmp(uts.sysname, "AIX") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4462 // We run on AIX. We do not support versions older than AIX 5.3. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4463 _on_pase = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4464 if (_os_version < 0x0503) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4465 fprintf(stderr, "AIX release older than AIX 5.3 not supported.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4466 assert(false, "AIX release too old."); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4467 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4468 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4469 fprintf(stderr, "We run on AIX %d.%d\n", major, minor); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4470 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4471 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4472 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4473 assert(false, "unknown OS"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4474 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4475 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4476 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4477 guarantee(_on_pase != -1 && _os_version, "Could not determine AIX/OS400 release"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4478 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4479 } // end: os::Aix::initialize_os_info() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4480 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4481 // Scan environment for important settings which might effect the VM. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4482 // Trace out settings. Warn about invalid settings and/or correct them. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4483 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4484 // Must run after os::Aix::initialue_os_info(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4485 void os::Aix::scan_environment() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4486 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4487 char* p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4488 int rc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4489 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4490 // Warn explicity if EXTSHM=ON is used. That switch changes how |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4491 // System V shared memory behaves. One effect is that page size of |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4492 // shared memory cannot be change dynamically, effectivly preventing |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4493 // large pages from working. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4494 // This switch was needed on AIX 32bit, but on AIX 64bit the general |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4495 // recommendation is (in OSS notes) to switch it off. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4496 p = ::getenv("EXTSHM"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4497 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4498 fprintf(stderr, "EXTSHM=%s.\n", p ? p : "<unset>"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4499 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4500 if (p && strcmp(p, "ON") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4501 fprintf(stderr, "Unsupported setting: EXTSHM=ON. Large Page support will be disabled.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4502 _extshm = 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4503 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4504 _extshm = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4505 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4506 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4507 // SPEC1170 behaviour: will change the behaviour of a number of POSIX APIs. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4508 // Not tested, not supported. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4509 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4510 // Note that it might be worth the trouble to test and to require it, if only to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4511 // get useful return codes for mprotect. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4512 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4513 // Note: Setting XPG_SUS_ENV in the process is too late. Must be set earlier (before |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4514 // exec() ? before loading the libjvm ? ....) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4515 p = ::getenv("XPG_SUS_ENV"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4516 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4517 fprintf(stderr, "XPG_SUS_ENV=%s.\n", p ? p : "<unset>"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4518 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4519 if (p && strcmp(p, "ON") == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4520 _xpg_sus_mode = 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4521 fprintf(stderr, "Unsupported setting: XPG_SUS_ENV=ON\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4522 // This is not supported. Worst of all, it changes behaviour of mmap MAP_FIXED to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4523 // clobber address ranges. If we ever want to support that, we have to do some |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4524 // testing first. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4525 guarantee(false, "XPG_SUS_ENV=ON not supported"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4526 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4527 _xpg_sus_mode = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4528 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4529 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4530 // Switch off AIX internal (pthread) guard pages. This has |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4531 // immediate effect for any pthread_create calls which follow. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4532 p = ::getenv("AIXTHREAD_GUARDPAGES"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4533 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4534 fprintf(stderr, "AIXTHREAD_GUARDPAGES=%s.\n", p ? p : "<unset>"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4535 fprintf(stderr, "setting AIXTHREAD_GUARDPAGES=0.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4536 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4537 rc = ::putenv("AIXTHREAD_GUARDPAGES=0"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4538 guarantee(rc == 0, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4539 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4540 } // end: os::Aix::scan_environment() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4541 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4542 // PASE: initialize the libo4 library (AS400 PASE porting library). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4543 void os::Aix::initialize_libo4() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4544 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4545 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4546 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4547 // AIX: initialize the libperfstat library (we load this dynamically |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4548 // because it is only available on AIX. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4549 void os::Aix::initialize_libperfstat() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4550 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4551 assert(os::Aix::on_aix(), "AIX only"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4552 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4553 if (!libperfstat::init()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4554 fprintf(stderr, "libperfstat initialization failed.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4555 assert(false, "libperfstat initialization failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4556 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4557 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4558 fprintf(stderr, "libperfstat initialized.\n"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4559 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4560 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4561 } // end: os::Aix::initialize_libperfstat |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4562 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4563 ///////////////////////////////////////////////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4564 // thread stack |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4565 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4566 // function to query the current stack size using pthread_getthrds_np |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4567 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4568 // ! do not change anything here unless you know what you are doing ! |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4569 static void query_stack_dimensions(address* p_stack_base, size_t* p_stack_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4570 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4571 // This only works when invoked on a pthread. As we agreed not to use |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4572 // primordial threads anyway, I assert here |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4573 guarantee(!os::Aix::is_primordial_thread(), "not allowed on the primordial thread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4574 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4575 // information about this api can be found (a) in the pthread.h header and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4576 // (b) in http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/pthread_getthrds_np.htm |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4577 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4578 // The use of this API to find out the current stack is kind of undefined. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4579 // But after a lot of tries and asking IBM about it, I concluded that it is safe |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4580 // enough for cases where I let the pthread library create its stacks. For cases |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4581 // where I create an own stack and pass this to pthread_create, it seems not to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4582 // work (the returned stack size in that case is 0). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4583 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4584 pthread_t tid = pthread_self(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4585 struct __pthrdsinfo pinfo; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4586 char dummy[1]; // we only need this to satisfy the api and to not get E |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4587 int dummy_size = sizeof(dummy); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4588 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4589 memset(&pinfo, 0, sizeof(pinfo)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4590 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4591 const int rc = pthread_getthrds_np (&tid, PTHRDSINFO_QUERY_ALL, &pinfo, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4592 sizeof(pinfo), dummy, &dummy_size); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4593 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4594 if (rc != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4595 fprintf(stderr, "pthread_getthrds_np failed (%d)\n", rc); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4596 guarantee(0, "pthread_getthrds_np failed"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4597 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4598 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4599 guarantee(pinfo.__pi_stackend, "returned stack base invalid"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4600 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4601 // the following can happen when invoking pthread_getthrds_np on a pthread running on a user provided stack |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4602 // (when handing down a stack to pthread create, see pthread_attr_setstackaddr). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4603 // Not sure what to do here - I feel inclined to forbid this use case completely. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4604 guarantee(pinfo.__pi_stacksize, "returned stack size invalid"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4605 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4606 // On AIX, stacks are not necessarily page aligned so round the base and size accordingly |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4607 if (p_stack_base) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4608 (*p_stack_base) = (address) align_size_up((intptr_t)pinfo.__pi_stackend, os::Aix::stack_page_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4609 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4610 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4611 if (p_stack_size) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4612 (*p_stack_size) = pinfo.__pi_stacksize - os::Aix::stack_page_size(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4613 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4614 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4615 #ifndef PRODUCT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4616 if (Verbose) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4617 fprintf(stderr, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4618 "query_stack_dimensions() -> real stack_base=" INTPTR_FORMAT ", real stack_addr=" INTPTR_FORMAT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4619 ", real stack_size=" INTPTR_FORMAT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4620 ", stack_base=" INTPTR_FORMAT ", stack_size=" INTPTR_FORMAT "\n", |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4621 (intptr_t)pinfo.__pi_stackend, (intptr_t)pinfo.__pi_stackaddr, pinfo.__pi_stacksize, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4622 (intptr_t)align_size_up((intptr_t)pinfo.__pi_stackend, os::Aix::stack_page_size()), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4623 pinfo.__pi_stacksize - os::Aix::stack_page_size()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4624 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4625 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4626 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4627 } // end query_stack_dimensions |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4628 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4629 // get the current stack base from the OS (actually, the pthread library) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4630 address os::current_stack_base() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4631 address p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4632 query_stack_dimensions(&p, 0); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4633 return p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4634 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4635 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4636 // get the current stack size from the OS (actually, the pthread library) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4637 size_t os::current_stack_size() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4638 size_t s; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4639 query_stack_dimensions(0, &s); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4640 return s; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4641 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4642 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4643 // Refer to the comments in os_solaris.cpp park-unpark. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4644 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4645 // Beware -- Some versions of NPTL embody a flaw where pthread_cond_timedwait() can |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4646 // hang indefinitely. For instance NPTL 0.60 on 2.4.21-4ELsmp is vulnerable. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4647 // For specifics regarding the bug see GLIBC BUGID 261237 : |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4648 // http://www.mail-archive.com/debian-glibc@lists.debian.org/msg10837.html. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4649 // Briefly, pthread_cond_timedwait() calls with an expiry time that's not in the future |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4650 // will either hang or corrupt the condvar, resulting in subsequent hangs if the condvar |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4651 // is used. (The simple C test-case provided in the GLIBC bug report manifests the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4652 // hang). The JVM is vulernable via sleep(), Object.wait(timo), LockSupport.parkNanos() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4653 // and monitorenter when we're using 1-0 locking. All those operations may result in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4654 // calls to pthread_cond_timedwait(). Using LD_ASSUME_KERNEL to use an older version |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4655 // of libpthread avoids the problem, but isn't practical. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4656 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4657 // Possible remedies: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4658 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4659 // 1. Establish a minimum relative wait time. 50 to 100 msecs seems to work. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4660 // This is palliative and probabilistic, however. If the thread is preempted |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4661 // between the call to compute_abstime() and pthread_cond_timedwait(), more |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4662 // than the minimum period may have passed, and the abstime may be stale (in the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4663 // past) resultin in a hang. Using this technique reduces the odds of a hang |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4664 // but the JVM is still vulnerable, particularly on heavily loaded systems. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4665 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4666 // 2. Modify park-unpark to use per-thread (per ParkEvent) pipe-pairs instead |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4667 // of the usual flag-condvar-mutex idiom. The write side of the pipe is set |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4668 // NDELAY. unpark() reduces to write(), park() reduces to read() and park(timo) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4669 // reduces to poll()+read(). This works well, but consumes 2 FDs per extant |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4670 // thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4671 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4672 // 3. Embargo pthread_cond_timedwait() and implement a native "chron" thread |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4673 // that manages timeouts. We'd emulate pthread_cond_timedwait() by enqueuing |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4674 // a timeout request to the chron thread and then blocking via pthread_cond_wait(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4675 // This also works well. In fact it avoids kernel-level scalability impediments |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4676 // on certain platforms that don't handle lots of active pthread_cond_timedwait() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4677 // timers in a graceful fashion. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4678 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4679 // 4. When the abstime value is in the past it appears that control returns |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4680 // correctly from pthread_cond_timedwait(), but the condvar is left corrupt. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4681 // Subsequent timedwait/wait calls may hang indefinitely. Given that, we |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4682 // can avoid the problem by reinitializing the condvar -- by cond_destroy() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4683 // followed by cond_init() -- after all calls to pthread_cond_timedwait(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4684 // It may be possible to avoid reinitialization by checking the return |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4685 // value from pthread_cond_timedwait(). In addition to reinitializing the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4686 // condvar we must establish the invariant that cond_signal() is only called |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4687 // within critical sections protected by the adjunct mutex. This prevents |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4688 // cond_signal() from "seeing" a condvar that's in the midst of being |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4689 // reinitialized or that is corrupt. Sadly, this invariant obviates the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4690 // desirable signal-after-unlock optimization that avoids futile context switching. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4691 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4692 // I'm also concerned that some versions of NTPL might allocate an auxilliary |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4693 // structure when a condvar is used or initialized. cond_destroy() would |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4694 // release the helper structure. Our reinitialize-after-timedwait fix |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4695 // put excessive stress on malloc/free and locks protecting the c-heap. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4696 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4697 // We currently use (4). See the WorkAroundNTPLTimedWaitHang flag. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4698 // It may be possible to refine (4) by checking the kernel and NTPL verisons |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4699 // and only enabling the work-around for vulnerable environments. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4700 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4701 // utility to compute the abstime argument to timedwait: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4702 // millis is the relative timeout time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4703 // abstime will be the absolute timeout time |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4704 // TODO: replace compute_abstime() with unpackTime() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4705 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4706 static struct timespec* compute_abstime(timespec* abstime, jlong millis) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4707 if (millis < 0) millis = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4708 struct timeval now; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4709 int status = gettimeofday(&now, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4710 assert(status == 0, "gettimeofday"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4711 jlong seconds = millis / 1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4712 millis %= 1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4713 if (seconds > 50000000) { // see man cond_timedwait(3T) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4714 seconds = 50000000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4715 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4716 abstime->tv_sec = now.tv_sec + seconds; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4717 long usec = now.tv_usec + millis * 1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4718 if (usec >= 1000000) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4719 abstime->tv_sec += 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4720 usec -= 1000000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4721 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4722 abstime->tv_nsec = usec * 1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4723 return abstime; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4724 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4725 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4726 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4727 // Test-and-clear _Event, always leaves _Event set to 0, returns immediately. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4728 // Conceptually TryPark() should be equivalent to park(0). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4729 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4730 int os::PlatformEvent::TryPark() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4731 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4732 const int v = _Event; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4733 guarantee ((v == 0) || (v == 1), "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4734 if (Atomic::cmpxchg (0, &_Event, v) == v) return v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4735 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4736 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4737 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4738 void os::PlatformEvent::park() { // AKA "down()" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4739 // Invariant: Only the thread associated with the Event/PlatformEvent |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4740 // may call park(). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4741 // TODO: assert that _Assoc != NULL or _Assoc == Self |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4742 int v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4743 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4744 v = _Event; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4745 if (Atomic::cmpxchg (v-1, &_Event, v) == v) break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4746 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4747 guarantee (v >= 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4748 if (v == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4749 // Do this the hard way by blocking ... |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4750 int status = pthread_mutex_lock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4751 assert_status(status == 0, status, "mutex_lock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4752 guarantee (_nParked == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4753 ++ _nParked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4754 while (_Event < 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4755 status = pthread_cond_wait(_cond, _mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4756 assert_status(status == 0 || status == ETIMEDOUT, status, "cond_timedwait"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4757 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4758 -- _nParked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4759 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4760 // In theory we could move the ST of 0 into _Event past the unlock(), |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4761 // but then we'd need a MEMBAR after the ST. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4762 _Event = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4763 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4764 assert_status(status == 0, status, "mutex_unlock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4765 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4766 guarantee (_Event >= 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4767 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4768 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4769 int os::PlatformEvent::park(jlong millis) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4770 guarantee (_nParked == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4771 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4772 int v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4773 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4774 v = _Event; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4775 if (Atomic::cmpxchg (v-1, &_Event, v) == v) break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4776 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4777 guarantee (v >= 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4778 if (v != 0) return OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4779 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4780 // We do this the hard way, by blocking the thread. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4781 // Consider enforcing a minimum timeout value. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4782 struct timespec abst; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4783 compute_abstime(&abst, millis); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4784 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4785 int ret = OS_TIMEOUT; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4786 int status = pthread_mutex_lock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4787 assert_status(status == 0, status, "mutex_lock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4788 guarantee (_nParked == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4789 ++_nParked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4790 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4791 // Object.wait(timo) will return because of |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4792 // (a) notification |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4793 // (b) timeout |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4794 // (c) thread.interrupt |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4795 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4796 // Thread.interrupt and object.notify{All} both call Event::set. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4797 // That is, we treat thread.interrupt as a special case of notification. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4798 // The underlying Solaris implementation, cond_timedwait, admits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4799 // spurious/premature wakeups, but the JLS/JVM spec prevents the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4800 // JVM from making those visible to Java code. As such, we must |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4801 // filter out spurious wakeups. We assume all ETIME returns are valid. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4802 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4803 // TODO: properly differentiate simultaneous notify+interrupt. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4804 // In that case, we should propagate the notify to another waiter. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4805 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4806 while (_Event < 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4807 status = pthread_cond_timedwait(_cond, _mutex, &abst); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4808 assert_status(status == 0 || status == ETIMEDOUT, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4809 status, "cond_timedwait"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4810 if (!FilterSpuriousWakeups) break; // previous semantics |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4811 if (status == ETIMEDOUT) break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4812 // We consume and ignore EINTR and spurious wakeups. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4813 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4814 --_nParked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4815 if (_Event >= 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4816 ret = OS_OK; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4817 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4818 _Event = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4819 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4820 assert_status(status == 0, status, "mutex_unlock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4821 assert (_nParked == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4822 return ret; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4823 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4824 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4825 void os::PlatformEvent::unpark() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4826 int v, AnyWaiters; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4827 for (;;) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4828 v = _Event; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4829 if (v > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4830 // The LD of _Event could have reordered or be satisfied |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4831 // by a read-aside from this processor's write buffer. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4832 // To avoid problems execute a barrier and then |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4833 // ratify the value. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4834 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4835 if (_Event == v) return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4836 continue; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4837 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4838 if (Atomic::cmpxchg (v+1, &_Event, v) == v) break; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4839 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4840 if (v < 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4841 // Wait for the thread associated with the event to vacate |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4842 int status = pthread_mutex_lock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4843 assert_status(status == 0, status, "mutex_lock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4844 AnyWaiters = _nParked; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4845 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4846 if (AnyWaiters != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4847 // We intentional signal *after* dropping the lock |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4848 // to avoid a common class of futile wakeups. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4849 status = pthread_cond_signal(_cond); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4850 assert_status(status == 0, status, "cond_signal"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4851 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4852 // Mutex should be locked for pthread_cond_signal(_cond). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4853 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4854 assert_status(status == 0, status, "mutex_unlock"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4855 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4856 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4857 // Note that we signal() _after dropping the lock for "immortal" Events. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4858 // This is safe and avoids a common class of futile wakeups. In rare |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4859 // circumstances this can cause a thread to return prematurely from |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4860 // cond_{timed}wait() but the spurious wakeup is benign and the victim will |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4861 // simply re-test the condition and re-park itself. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4862 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4863 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4864 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4865 // JSR166 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4866 // ------------------------------------------------------- |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4867 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4868 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4869 // The solaris and linux implementations of park/unpark are fairly |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4870 // conservative for now, but can be improved. They currently use a |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4871 // mutex/condvar pair, plus a a count. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4872 // Park decrements count if > 0, else does a condvar wait. Unpark |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4873 // sets count to 1 and signals condvar. Only one thread ever waits |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4874 // on the condvar. Contention seen when trying to park implies that someone |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4875 // is unparking you, so don't wait. And spurious returns are fine, so there |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4876 // is no need to track notifications. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4877 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4878 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4879 #define MAX_SECS 100000000 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4880 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4881 // This code is common to linux and solaris and will be moved to a |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4882 // common place in dolphin. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4883 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4884 // The passed in time value is either a relative time in nanoseconds |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4885 // or an absolute time in milliseconds. Either way it has to be unpacked |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4886 // into suitable seconds and nanoseconds components and stored in the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4887 // given timespec structure. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4888 // Given time is a 64-bit value and the time_t used in the timespec is only |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4889 // a signed-32-bit value (except on 64-bit Linux) we have to watch for |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4890 // overflow if times way in the future are given. Further on Solaris versions |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4891 // prior to 10 there is a restriction (see cond_timedwait) that the specified |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4892 // number of seconds, in abstime, is less than current_time + 100,000,000. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4893 // As it will be 28 years before "now + 100000000" will overflow we can |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4894 // ignore overflow and just impose a hard-limit on seconds using the value |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4895 // of "now + 100,000,000". This places a limit on the timeout of about 3.17 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4896 // years from "now". |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4897 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4898 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4899 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4900 assert (time > 0, "convertTime"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4901 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4902 struct timeval now; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4903 int status = gettimeofday(&now, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4904 assert(status == 0, "gettimeofday"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4905 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4906 time_t max_secs = now.tv_sec + MAX_SECS; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4907 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4908 if (isAbsolute) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4909 jlong secs = time / 1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4910 if (secs > max_secs) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4911 absTime->tv_sec = max_secs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4912 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4913 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4914 absTime->tv_sec = secs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4915 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4916 absTime->tv_nsec = (time % 1000) * NANOSECS_PER_MILLISEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4917 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4918 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4919 jlong secs = time / NANOSECS_PER_SEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4920 if (secs >= MAX_SECS) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4921 absTime->tv_sec = max_secs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4922 absTime->tv_nsec = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4923 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4924 else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4925 absTime->tv_sec = now.tv_sec + secs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4926 absTime->tv_nsec = (time % NANOSECS_PER_SEC) + now.tv_usec*1000; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4927 if (absTime->tv_nsec >= NANOSECS_PER_SEC) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4928 absTime->tv_nsec -= NANOSECS_PER_SEC; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4929 ++absTime->tv_sec; // note: this must be <= max_secs |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4930 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4931 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4932 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4933 assert(absTime->tv_sec >= 0, "tv_sec < 0"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4934 assert(absTime->tv_sec <= max_secs, "tv_sec > max_secs"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4935 assert(absTime->tv_nsec >= 0, "tv_nsec < 0"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4936 assert(absTime->tv_nsec < NANOSECS_PER_SEC, "tv_nsec >= nanos_per_sec"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4937 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4938 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4939 void Parker::park(bool isAbsolute, jlong time) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4940 // Optional fast-path check: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4941 // Return immediately if a permit is available. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4942 if (_counter > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4943 _counter = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4944 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4945 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4946 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4947 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4948 Thread* thread = Thread::current(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4949 assert(thread->is_Java_thread(), "Must be JavaThread"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4950 JavaThread *jt = (JavaThread *)thread; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4951 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4952 // Optional optimization -- avoid state transitions if there's an interrupt pending. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4953 // Check interrupt before trying to wait |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4954 if (Thread::is_interrupted(thread, false)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4955 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4956 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4957 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4958 // Next, demultiplex/decode time arguments |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4959 timespec absTime; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4960 if (time < 0 || (isAbsolute && time == 0)) { // don't wait at all |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4961 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4962 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4963 if (time > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4964 unpackTime(&absTime, isAbsolute, time); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4965 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4966 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4967 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4968 // Enter safepoint region |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4969 // Beware of deadlocks such as 6317397. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4970 // The per-thread Parker:: mutex is a classic leaf-lock. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4971 // In particular a thread must never block on the Threads_lock while |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4972 // holding the Parker:: mutex. If safepoints are pending both the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4973 // the ThreadBlockInVM() CTOR and DTOR may grab Threads_lock. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4974 ThreadBlockInVM tbivm(jt); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4975 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4976 // Don't wait if cannot get lock since interference arises from |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4977 // unblocking. Also. check interrupt before trying wait |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4978 if (Thread::is_interrupted(thread, false) || pthread_mutex_trylock(_mutex) != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4979 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4980 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4981 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4982 int status; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4983 if (_counter > 0) { // no wait needed |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4984 _counter = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4985 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4986 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4987 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4988 return; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4989 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4990 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4991 #ifdef ASSERT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4992 // Don't catch signals while blocked; let the running threads have the signals. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4993 // (This allows a debugger to break into the running thread.) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4994 sigset_t oldsigs; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4995 sigset_t* allowdebug_blocked = os::Aix::allowdebug_blocked_signals(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4996 pthread_sigmask(SIG_BLOCK, allowdebug_blocked, &oldsigs); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4997 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4998 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4999 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5000 jt->set_suspend_equivalent(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5001 // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5002 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5003 if (time == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5004 status = pthread_cond_wait (_cond, _mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5005 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5006 status = pthread_cond_timedwait (_cond, _mutex, &absTime); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5007 if (status != 0 && WorkAroundNPTLTimedWaitHang) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5008 pthread_cond_destroy (_cond); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5009 pthread_cond_init (_cond, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5010 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5011 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5012 assert_status(status == 0 || status == EINTR || |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5013 status == ETIME || status == ETIMEDOUT, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5014 status, "cond_timedwait"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5015 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5016 #ifdef ASSERT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5017 pthread_sigmask(SIG_SETMASK, &oldsigs, NULL); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5018 #endif |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5019 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5020 _counter = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5021 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5022 assert_status(status == 0, status, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5023 // If externally suspended while waiting, re-suspend |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5024 if (jt->handle_special_suspend_equivalent_condition()) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5025 jt->java_suspend_self(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5026 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5027 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5028 OrderAccess::fence(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5029 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5030 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5031 void Parker::unpark() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5032 int s, status; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5033 status = pthread_mutex_lock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5034 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5035 s = _counter; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5036 _counter = 1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5037 if (s < 1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5038 if (WorkAroundNPTLTimedWaitHang) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5039 status = pthread_cond_signal (_cond); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5040 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5041 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5042 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5043 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5044 status = pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5045 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5046 status = pthread_cond_signal (_cond); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5047 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5048 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5049 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5050 pthread_mutex_unlock(_mutex); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5051 assert (status == 0, "invariant"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5052 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5053 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5054 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5055 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5056 extern char** environ; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5057 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5058 // Run the specified command in a separate process. Return its exit value, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5059 // or -1 on failure (e.g. can't fork a new process). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5060 // Unlike system(), this function can be called from signal handler. It |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5061 // doesn't block SIGINT et al. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5062 int os::fork_and_exec(char* cmd) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5063 Unimplemented(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5064 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5065 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5066 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5067 // is_headless_jre() |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5068 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5069 // Test for the existence of xawt/libmawt.so or libawt_xawt.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5070 // in order to report if we are running in a headless jre. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5071 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5072 // Since JDK8 xawt/libmawt.so is moved into the same directory |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5073 // as libawt.so, and renamed libawt_xawt.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5074 bool os::is_headless_jre() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5075 struct stat statbuf; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5076 char buf[MAXPATHLEN]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5077 char libmawtpath[MAXPATHLEN]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5078 const char *xawtstr = "/xawt/libmawt.so"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5079 const char *new_xawtstr = "/libawt_xawt.so"; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5080 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5081 char *p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5082 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5083 // Get path to libjvm.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5084 os::jvm_path(buf, sizeof(buf)); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5085 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5086 // Get rid of libjvm.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5087 p = strrchr(buf, '/'); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5088 if (p == NULL) return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5089 else *p = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5090 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5091 // Get rid of client or server |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5092 p = strrchr(buf, '/'); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5093 if (p == NULL) return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5094 else *p = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5095 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5096 // check xawt/libmawt.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5097 strcpy(libmawtpath, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5098 strcat(libmawtpath, xawtstr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5099 if (::stat(libmawtpath, &statbuf) == 0) return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5100 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5101 // check libawt_xawt.so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5102 strcpy(libmawtpath, buf); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5103 strcat(libmawtpath, new_xawtstr); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5104 if (::stat(libmawtpath, &statbuf) == 0) return false; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5105 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5106 return true; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5107 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5108 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5109 // Get the default path to the core file |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5110 // Returns the length of the string |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5111 int os::get_core_path(char* buffer, size_t bufferSize) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5112 const char* p = get_current_directory(buffer, bufferSize); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5113 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5114 if (p == NULL) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5115 assert(p != NULL, "failed to get current directory"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5116 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5117 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5118 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5119 return strlen(buffer); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5120 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5121 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5122 #ifndef PRODUCT |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5123 void TestReserveMemorySpecial_test() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5124 // No tests available for this platform |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5125 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5126 #endif |