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.hotspot.code;
26
27 import java.lang.management.ManagementFactory;
28 import java.lang.management.MemoryPoolMXBean;
29 import java.util.EnumSet;
30
31 import sun.hotspot.WhiteBox;
32
33 public enum BlobType {
34 // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
35 MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'"),
36 // Execution level 2 and 3 (profiled) nmethods
37 MethodProfiled(1, "CodeHeap 'profiled nmethods'"),
38 // Non-nmethods like Buffers, Adapters and Runtime Stubs
39 NonNMethod(2, "CodeHeap 'non-nmethods'") {
40 @Override
41 public boolean allowTypeWhenOverflow(BlobType type) {
42 return super.allowTypeWhenOverflow(type)
43 || type == BlobType.MethodNonProfiled;
44 }
45 },
46 // All types (No code cache segmentation)
47 All(3, "CodeCache");
48
49 public final int id;
50 private final String beanName;
51
52 private BlobType(int id, String beanName) {
53 this.id = id;
54 this.beanName = beanName;
55 }
56
57 public MemoryPoolMXBean getMemoryPool() {
58 for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
59 String name = bean.getName();
60 if (beanName.equals(name)) {
61 return bean;
62 }
63 }
64 return null;
65 }
66
67 public boolean allowTypeWhenOverflow(BlobType type) {
68 return type == this;
69 }
70
71 public static EnumSet<BlobType> getAvailable() {
72 WhiteBox whiteBox = WhiteBox.getWhiteBox();
73 if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
74 // only All for non segmented world
75 return EnumSet.of(All);
76 }
77 if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
78 // only NonNMethod for -Xint
79 return EnumSet.of(NonNMethod);
80 }
81
82 EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
83 if (!whiteBox.getBooleanVMFlag("TieredCompilation")
84 || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
85 // there is no MethodProfiled in non tiered world or pure C1
86 result.remove(MethodProfiled);
87 }
88 return result;
89 }
90 }
|
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.hotspot.code;
26
27 import java.lang.management.ManagementFactory;
28 import java.lang.management.MemoryPoolMXBean;
29 import java.util.EnumSet;
30
31 import sun.hotspot.WhiteBox;
32
33 public enum BlobType {
34 // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
35 MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'", "NonProfiledCodeHeapSize"),
36 // Execution level 2 and 3 (profiled) nmethods
37 MethodProfiled(1, "CodeHeap 'profiled nmethods'", "ProfiledCodeHeapSize"),
38 // Non-nmethods like Buffers, Adapters and Runtime Stubs
39 NonNMethod(2, "CodeHeap 'non-nmethods'", "NonNMethodCodeHeapSize") {
40 @Override
41 public boolean allowTypeWhenOverflow(BlobType type) {
42 return super.allowTypeWhenOverflow(type)
43 || type == BlobType.MethodNonProfiled;
44 }
45 },
46 // All types (No code cache segmentation)
47 All(3, "CodeCache", "ReservedCodeCacheSize");
48
49 public final int id;
50 public final String sizeOptionName;
51 public final String beanName;
52
53 private BlobType(int id, String beanName, String sizeOptionName) {
54 this.id = id;
55 this.beanName = beanName;
56 this.sizeOptionName = sizeOptionName;
57 }
58
59 public MemoryPoolMXBean getMemoryPool() {
60 for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
61 String name = bean.getName();
62 if (beanName.equals(name)) {
63 return bean;
64 }
65 }
66 return null;
67 }
68
69 public boolean allowTypeWhenOverflow(BlobType type) {
70 return type == this;
71 }
72
73 public static EnumSet<BlobType> getAvailable() {
74 WhiteBox whiteBox = WhiteBox.getWhiteBox();
75 if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
76 // only All for non segmented world
77 return EnumSet.of(All);
78 }
79 if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
80 // only NonNMethod for -Xint
81 return EnumSet.of(NonNMethod);
82 }
83
84 EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
85 if (!whiteBox.getBooleanVMFlag("TieredCompilation")
86 || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
87 // there is no MethodProfiled in non tiered world or pure C1
88 result.remove(MethodProfiled);
89 }
90 return result;
91 }
92
93 public long getSize() {
94 return WhiteBox.getWhiteBox().getUintxVMFlag(sizeOptionName);
95 }
96 }
|