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");
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 }
|
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_x86.Win32X86JavaThreadPDAccess;
32 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
33 import sun.jvm.hotspot.runtime.win32_aarch64.Win32AARCH64JavaThreadPDAccess;
34 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
35 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
36 import sun.jvm.hotspot.runtime.linux_aarch64.LinuxAARCH64JavaThreadPDAccess;
37 import sun.jvm.hotspot.runtime.linux_ppc64.LinuxPPC64JavaThreadPDAccess;
38 import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
39 import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
40 import sun.jvm.hotspot.utilities.*;
41 import sun.jvm.hotspot.utilities.Observable;
42 import sun.jvm.hotspot.utilities.Observer;
43
44 class ThreadsList extends VMObject {
45 private static AddressField threadsField;
46 private static CIntegerField lengthField;
47
48 static {
49 VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
50 }
51
52 private static synchronized void initialize(TypeDataBase db) {
53 Type type = db.lookupType("ThreadsList");
83 initialize(VM.getVM().getTypeDataBase());
84 }
85 });
86 }
87
88 private static synchronized void initialize(TypeDataBase db) {
89 Type type = db.lookupType("ThreadsSMRSupport");
90 threadListField = type.getAddressField("_java_thread_list");
91
92 // Instantiate appropriate platform-specific JavaThreadFactory
93 String os = VM.getVM().getOS();
94 String cpu = VM.getVM().getCPU();
95
96 access = null;
97 // FIXME: find the platform specific PD class by reflection?
98 if (os.equals("win32")) {
99 if (cpu.equals("x86")) {
100 access = new Win32X86JavaThreadPDAccess();
101 } else if (cpu.equals("amd64")) {
102 access = new Win32AMD64JavaThreadPDAccess();
103 } else if (cpu.equals("aarch64")) {
104 access = new Win32AARCH64JavaThreadPDAccess();
105 }
106 } else if (os.equals("linux")) {
107 if (cpu.equals("x86")) {
108 access = new LinuxX86JavaThreadPDAccess();
109 } else if (cpu.equals("amd64")) {
110 access = new LinuxAMD64JavaThreadPDAccess();
111 } else if (cpu.equals("ppc64")) {
112 access = new LinuxPPC64JavaThreadPDAccess();
113 } else if (cpu.equals("aarch64")) {
114 access = new LinuxAARCH64JavaThreadPDAccess();
115 } else {
116 try {
117 access = (JavaThreadPDAccess)
118 Class.forName("sun.jvm.hotspot.runtime.linux_" +
119 cpu.toLowerCase() + ".Linux" + cpu.toUpperCase() +
120 "JavaThreadPDAccess").getDeclaredConstructor().newInstance();
121 } catch (Exception e) {
122 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
123 " not yet supported");
124 }
|