11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.util.*;
28
29 import sun.jvm.hotspot.debugger.*;
30 import sun.jvm.hotspot.types.*;
31 import sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess;
32 import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess;
33 import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess;
34 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
35 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
36 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
37 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
38 import sun.jvm.hotspot.runtime.linux_aarch64.LinuxAARCH64JavaThreadPDAccess;
39 import sun.jvm.hotspot.runtime.linux_ppc64.LinuxPPC64JavaThreadPDAccess;
40 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
41 import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
42 import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
43 import sun.jvm.hotspot.utilities.*;
44 import sun.jvm.hotspot.utilities.Observable;
45 import sun.jvm.hotspot.utilities.Observer;
46
47 class ThreadsList extends VMObject {
48 private static AddressField threadsField;
49 private static CIntegerField lengthField;
50
51 static {
52 VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
53 }
54
55 private static synchronized void initialize(TypeDataBase db) {
56 Type type = db.lookupType("ThreadsList");
57 lengthField = type.getCIntegerField("_length");
58 threadsField = type.getAddressField("_threads");
59 }
60
81 private static ThreadsList _list;
82
83 static {
84 VM.registerVMInitializedObserver(new Observer() {
85 public void update(Observable o, Object data) {
86 initialize(VM.getVM().getTypeDataBase());
87 }
88 });
89 }
90
91 private static synchronized void initialize(TypeDataBase db) {
92 Type type = db.lookupType("ThreadsSMRSupport");
93 threadListField = type.getAddressField("_java_thread_list");
94
95 // Instantiate appropriate platform-specific JavaThreadFactory
96 String os = VM.getVM().getOS();
97 String cpu = VM.getVM().getCPU();
98
99 access = null;
100 // FIXME: find the platform specific PD class by reflection?
101 if (os.equals("solaris")) {
102 if (cpu.equals("sparc")) {
103 access = new SolarisSPARCJavaThreadPDAccess();
104 } else if (cpu.equals("x86")) {
105 access = new SolarisX86JavaThreadPDAccess();
106 } else if (cpu.equals("amd64")) {
107 access = new SolarisAMD64JavaThreadPDAccess();
108 }
109 } else if (os.equals("win32")) {
110 if (cpu.equals("x86")) {
111 access = new Win32X86JavaThreadPDAccess();
112 } else if (cpu.equals("amd64")) {
113 access = new Win32AMD64JavaThreadPDAccess();
114 }
115 } else if (os.equals("linux")) {
116 if (cpu.equals("x86")) {
117 access = new LinuxX86JavaThreadPDAccess();
118 } else if (cpu.equals("amd64")) {
119 access = new LinuxAMD64JavaThreadPDAccess();
120 } else if (cpu.equals("sparc")) {
121 access = new LinuxSPARCJavaThreadPDAccess();
122 } else if (cpu.equals("ppc64")) {
123 access = new LinuxPPC64JavaThreadPDAccess();
124 } else if (cpu.equals("aarch64")) {
125 access = new LinuxAARCH64JavaThreadPDAccess();
126 } else {
127 try {
128 access = (JavaThreadPDAccess)
129 Class.forName("sun.jvm.hotspot.runtime.linux_" +
130 cpu.toLowerCase() + ".Linux" + cpu.toUpperCase() +
131 "JavaThreadPDAccess").getDeclaredConstructor().newInstance();
132 } catch (Exception e) {
133 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
134 " not yet supported");
135 }
136 }
137 } else if (os.equals("bsd")) {
138 if (cpu.equals("x86")) {
139 access = new BsdX86JavaThreadPDAccess();
140 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
141 access = new BsdAMD64JavaThreadPDAccess();
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.util.*;
28
29 import sun.jvm.hotspot.debugger.*;
30 import sun.jvm.hotspot.types.*;
31 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
32 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
33 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
34 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
35 import sun.jvm.hotspot.runtime.linux_aarch64.LinuxAARCH64JavaThreadPDAccess;
36 import sun.jvm.hotspot.runtime.linux_ppc64.LinuxPPC64JavaThreadPDAccess;
37 import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
38 import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
39 import sun.jvm.hotspot.utilities.*;
40 import sun.jvm.hotspot.utilities.Observable;
41 import sun.jvm.hotspot.utilities.Observer;
42
43 class ThreadsList extends VMObject {
44 private static AddressField threadsField;
45 private static CIntegerField lengthField;
46
47 static {
48 VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
49 }
50
51 private static synchronized void initialize(TypeDataBase db) {
52 Type type = db.lookupType("ThreadsList");
53 lengthField = type.getCIntegerField("_length");
54 threadsField = type.getAddressField("_threads");
55 }
56
77 private static ThreadsList _list;
78
79 static {
80 VM.registerVMInitializedObserver(new Observer() {
81 public void update(Observable o, Object data) {
82 initialize(VM.getVM().getTypeDataBase());
83 }
84 });
85 }
86
87 private static synchronized void initialize(TypeDataBase db) {
88 Type type = db.lookupType("ThreadsSMRSupport");
89 threadListField = type.getAddressField("_java_thread_list");
90
91 // Instantiate appropriate platform-specific JavaThreadFactory
92 String os = VM.getVM().getOS();
93 String cpu = VM.getVM().getCPU();
94
95 access = null;
96 // FIXME: find the platform specific PD class by reflection?
97 if (os.equals("win32")) {
98 if (cpu.equals("x86")) {
99 access = new Win32X86JavaThreadPDAccess();
100 } else if (cpu.equals("amd64")) {
101 access = new Win32AMD64JavaThreadPDAccess();
102 }
103 } else if (os.equals("linux")) {
104 if (cpu.equals("x86")) {
105 access = new LinuxX86JavaThreadPDAccess();
106 } else if (cpu.equals("amd64")) {
107 access = new LinuxAMD64JavaThreadPDAccess();
108 } else if (cpu.equals("ppc64")) {
109 access = new LinuxPPC64JavaThreadPDAccess();
110 } else if (cpu.equals("aarch64")) {
111 access = new LinuxAARCH64JavaThreadPDAccess();
112 } else {
113 try {
114 access = (JavaThreadPDAccess)
115 Class.forName("sun.jvm.hotspot.runtime.linux_" +
116 cpu.toLowerCase() + ".Linux" + cpu.toUpperCase() +
117 "JavaThreadPDAccess").getDeclaredConstructor().newInstance();
118 } catch (Exception e) {
119 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
120 " not yet supported");
121 }
122 }
123 } else if (os.equals("bsd")) {
124 if (cpu.equals("x86")) {
125 access = new BsdX86JavaThreadPDAccess();
126 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
127 access = new BsdAMD64JavaThreadPDAccess();
|