equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
39 instantiated by the JavaThreadFactory in the Threads class. */ |
39 instantiated by the JavaThreadFactory in the Threads class. */ |
40 |
40 |
41 public class JavaThread extends Thread { |
41 public class JavaThread extends Thread { |
42 private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.JavaThread.DEBUG") != null; |
42 private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.JavaThread.DEBUG") != null; |
43 |
43 |
44 private static AddressField nextField; |
|
45 private static sun.jvm.hotspot.types.OopField threadObjField; |
44 private static sun.jvm.hotspot.types.OopField threadObjField; |
46 private static AddressField anchorField; |
45 private static AddressField anchorField; |
47 private static AddressField lastJavaSPField; |
46 private static AddressField lastJavaSPField; |
48 private static AddressField lastJavaPCField; |
47 private static AddressField lastJavaPCField; |
49 private static CIntegerField threadStateField; |
48 private static CIntegerField threadStateField; |
82 |
81 |
83 private static synchronized void initialize(TypeDataBase db) { |
82 private static synchronized void initialize(TypeDataBase db) { |
84 Type type = db.lookupType("JavaThread"); |
83 Type type = db.lookupType("JavaThread"); |
85 Type anchorType = db.lookupType("JavaFrameAnchor"); |
84 Type anchorType = db.lookupType("JavaFrameAnchor"); |
86 |
85 |
87 nextField = type.getAddressField("_next"); |
|
88 threadObjField = type.getOopField("_threadObj"); |
86 threadObjField = type.getOopField("_threadObj"); |
89 anchorField = type.getAddressField("_anchor"); |
87 anchorField = type.getAddressField("_anchor"); |
90 lastJavaSPField = anchorType.getAddressField("_last_Java_sp"); |
88 lastJavaSPField = anchorType.getAddressField("_last_Java_sp"); |
91 lastJavaPCField = anchorType.getAddressField("_last_Java_pc"); |
89 lastJavaPCField = anchorType.getAddressField("_last_Java_pc"); |
92 threadStateField = type.getCIntegerField("_thread_state"); |
90 threadStateField = type.getCIntegerField("_thread_state"); |
116 super(addr); |
114 super(addr); |
117 } |
115 } |
118 |
116 |
119 void setThreadPDAccess(JavaThreadPDAccess access) { |
117 void setThreadPDAccess(JavaThreadPDAccess access) { |
120 this.access = access; |
118 this.access = access; |
121 } |
|
122 |
|
123 public JavaThread next() { |
|
124 Address threadAddr = nextField.getValue(addr); |
|
125 if (threadAddr == null) { |
|
126 return null; |
|
127 } |
|
128 |
|
129 return VM.getVM().getThreads().createJavaThreadWrapper(threadAddr); |
|
130 } |
119 } |
131 |
120 |
132 /** NOTE: for convenience, this differs in definition from the underlying VM. |
121 /** NOTE: for convenience, this differs in definition from the underlying VM. |
133 Only "pure" JavaThreads return true; CompilerThreads, the CodeCacheSweeperThread, |
122 Only "pure" JavaThreads return true; CompilerThreads, the CodeCacheSweeperThread, |
134 JVMDIDebuggerThreads return false. |
123 JVMDIDebuggerThreads return false. |