1 /* |
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
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 |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
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.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 } |
|