test/compiler/codecache/CheckSegmentedCodeCache.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff test/compiler/codecache

test/compiler/codecache/CheckSegmentedCodeCache.java

Print this page




  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 import com.oracle.java.testlibrary.*;
  25 
  26 /*
  27  * @test CheckSegmentedCodeCache
  28  * @bug 8015774
  29  * @summary "Checks VM options related to the segmented code cache"
  30  * @library /testlibrary
  31  * @run main/othervm CheckSegmentedCodeCache
  32  */
  33 public class CheckSegmentedCodeCache {
  34   // Code heap names
  35   private static final String NON_METHOD = "CodeHeap 'non-methods'";
  36   private static final String PROFILED = "CodeHeap 'profiled nmethods'";
  37   private static final String NON_PROFILED = "CodeHeap 'non-profiled nmethods'";
  38 
  39   private static void verifySegmentedCodeCache(ProcessBuilder pb, boolean enabled) throws Exception {
  40     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  41     if (enabled) {
  42       try {
  43         // Non-method code heap should be always available with the segmented code cache
  44         out.shouldContain(NON_METHOD);
  45       } catch (RuntimeException e) {
  46         // TieredCompilation is disabled in a client VM
  47         out.shouldContain("TieredCompilation is disabled in this release.");
  48       }
  49     } else {
  50       out.shouldNotContain(NON_METHOD);
  51     }
  52     out.shouldHaveExitValue(0);
  53   }
  54 
  55   private static void verifyCodeHeapNotExists(ProcessBuilder pb, String... heapNames) throws Exception {
  56     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  57     for (String name : heapNames) {
  58       out.shouldNotContain(name);
  59     }
  60   }
  61 
  62   private static void failsWith(ProcessBuilder pb, String message) throws Exception {
  63     OutputAnalyzer out = new OutputAnalyzer(pb.start());


  94                                                "-XX:+PrintCodeCache", "-version");
  95     verifySegmentedCodeCache(pb, true);
  96 
  97     // The profiled and non-profiled code heaps should not be available in
  98     // interpreter-only mode
  99     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 100                                                "-Xint",
 101                                                "-XX:+PrintCodeCache", "-version");
 102     verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED);
 103     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 104                                                "-XX:TieredStopAtLevel=0",
 105                                                "-XX:+PrintCodeCache", "-version");
 106     verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED);
 107 
 108     // If we stop compilation at CompLevel_simple
 109     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 110                                                "-XX:TieredStopAtLevel=1",
 111                                                "-XX:+PrintCodeCache", "-version");
 112     verifyCodeHeapNotExists(pb, PROFILED);
 113 
 114     // Fails with too small non-method code heap size
 115     pb = ProcessTools.createJavaProcessBuilder("-XX:NonMethodCodeHeapSize=100K");
 116     failsWith(pb, "Invalid NonMethodCodeHeapSize");
 117 
 118     // Fails if code heap sizes do not add up
 119     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 120                                                "-XX:ReservedCodeCacheSize=10M",
 121                                                "-XX:NonMethodCodeHeapSize=5M",
 122                                                "-XX:ProfiledCodeHeapSize=5M",
 123                                                "-XX:NonProfiledCodeHeapSize=5M");
 124     failsWith(pb, "Invalid code heap sizes");
 125 
 126     // Fails if not enough space for VM internal code
 127     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 128                                                "-XX:ReservedCodeCacheSize=1700K",
 129                                                "-XX:InitialCodeCacheSize=100K");
 130     failsWith(pb, "Not enough space in non-method code heap to run VM");
 131   }
 132 }


  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 import com.oracle.java.testlibrary.*;
  25 
  26 /*
  27  * @test CheckSegmentedCodeCache
  28  * @bug 8015774
  29  * @summary "Checks VM options related to the segmented code cache"
  30  * @library /testlibrary
  31  * @run main/othervm CheckSegmentedCodeCache
  32  */
  33 public class CheckSegmentedCodeCache {
  34   // Code heap names
  35   private static final String NON_METHOD = "CodeHeap 'non-nmethods'";
  36   private static final String PROFILED = "CodeHeap 'profiled nmethods'";
  37   private static final String NON_PROFILED = "CodeHeap 'non-profiled nmethods'";
  38 
  39   private static void verifySegmentedCodeCache(ProcessBuilder pb, boolean enabled) throws Exception {
  40     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  41     if (enabled) {
  42       try {
  43         // Non-nmethod code heap should be always available with the segmented code cache
  44         out.shouldContain(NON_METHOD);
  45       } catch (RuntimeException e) {
  46         // TieredCompilation is disabled in a client VM
  47         out.shouldContain("TieredCompilation is disabled in this release.");
  48       }
  49     } else {
  50       out.shouldNotContain(NON_METHOD);
  51     }
  52     out.shouldHaveExitValue(0);
  53   }
  54 
  55   private static void verifyCodeHeapNotExists(ProcessBuilder pb, String... heapNames) throws Exception {
  56     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  57     for (String name : heapNames) {
  58       out.shouldNotContain(name);
  59     }
  60   }
  61 
  62   private static void failsWith(ProcessBuilder pb, String message) throws Exception {
  63     OutputAnalyzer out = new OutputAnalyzer(pb.start());


  94                                                "-XX:+PrintCodeCache", "-version");
  95     verifySegmentedCodeCache(pb, true);
  96 
  97     // The profiled and non-profiled code heaps should not be available in
  98     // interpreter-only mode
  99     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 100                                                "-Xint",
 101                                                "-XX:+PrintCodeCache", "-version");
 102     verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED);
 103     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 104                                                "-XX:TieredStopAtLevel=0",
 105                                                "-XX:+PrintCodeCache", "-version");
 106     verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED);
 107 
 108     // If we stop compilation at CompLevel_simple
 109     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 110                                                "-XX:TieredStopAtLevel=1",
 111                                                "-XX:+PrintCodeCache", "-version");
 112     verifyCodeHeapNotExists(pb, PROFILED);
 113 
 114     // Fails with too small non-nmethod code heap size
 115     pb = ProcessTools.createJavaProcessBuilder("-XX:NonNMethodCodeHeapSize=100K");
 116     failsWith(pb, "Invalid NonNMethodCodeHeapSize");
 117 
 118     // Fails if code heap sizes do not add up
 119     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 120                                                "-XX:ReservedCodeCacheSize=10M",
 121                                                "-XX:NonNMethodCodeHeapSize=5M",
 122                                                "-XX:ProfiledCodeHeapSize=5M",
 123                                                "-XX:NonProfiledCodeHeapSize=5M");
 124     failsWith(pb, "Invalid code heap sizes");
 125 
 126     // Fails if not enough space for VM internal code
 127     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
 128                                                "-XX:ReservedCodeCacheSize=1700K",
 129                                                "-XX:InitialCodeCacheSize=100K");
 130     failsWith(pb, "Not enough space in non-nmethod code heap to run VM");
 131   }
 132 }
test/compiler/codecache/CheckSegmentedCodeCache.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File