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