< prev index next >

test/compiler/codecache/CheckSegmentedCodeCache.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2015, 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  */


  35  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  36  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  37  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CheckSegmentedCodeCache
  38  */
  39 public class CheckSegmentedCodeCache {
  40   private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  41   // Code heap names
  42   private static final String NON_METHOD = "CodeHeap 'non-nmethods'";
  43   private static final String PROFILED = "CodeHeap 'profiled nmethods'";
  44   private static final String NON_PROFILED = "CodeHeap 'non-profiled nmethods'";
  45 
  46   private static void verifySegmentedCodeCache(ProcessBuilder pb, boolean enabled) throws Exception {
  47     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  48     out.shouldHaveExitValue(0);
  49     if (enabled) {
  50       try {
  51         // Non-nmethod code heap should be always available with the segmented code cache
  52         out.shouldContain(NON_METHOD);
  53       } catch (RuntimeException e) {
  54         // Check if TieredCompilation is disabled (in a client VM)
  55         if(!out.getOutput().contains("TieredCompilation is disabled in this release.")) {
  56           // Code cache is not segmented
  57           throw new RuntimeException("No code cache segmentation.");
  58         }
  59       }
  60     } else {
  61       out.shouldNotContain(NON_METHOD);
  62     }
  63   }
  64 
  65   private static void verifyCodeHeapNotExists(ProcessBuilder pb, String... heapNames) throws Exception {
  66     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  67     out.shouldHaveExitValue(0);
  68     for (String name : heapNames) {
  69       out.shouldNotContain(name);
  70     }
  71   }
  72 
  73   private static void failsWith(ProcessBuilder pb, String message) throws Exception {
  74     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  75     out.shouldContain(message);


   1 /*
   2  * Copyright (c) 2014, 2016, 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  */


  35  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  36  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  37  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CheckSegmentedCodeCache
  38  */
  39 public class CheckSegmentedCodeCache {
  40   private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  41   // Code heap names
  42   private static final String NON_METHOD = "CodeHeap 'non-nmethods'";
  43   private static final String PROFILED = "CodeHeap 'profiled nmethods'";
  44   private static final String NON_PROFILED = "CodeHeap 'non-profiled nmethods'";
  45 
  46   private static void verifySegmentedCodeCache(ProcessBuilder pb, boolean enabled) throws Exception {
  47     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  48     out.shouldHaveExitValue(0);
  49     if (enabled) {
  50       try {
  51         // Non-nmethod code heap should be always available with the segmented code cache
  52         out.shouldContain(NON_METHOD);
  53       } catch (RuntimeException e) {
  54         // Check if TieredCompilation is disabled (in a client VM)
  55         if(!out.getOutput().contains("-XX:+TieredCompilation not supported in this VM")) {
  56           // Code cache is not segmented
  57           throw new RuntimeException("No code cache segmentation.");
  58         }
  59       }
  60     } else {
  61       out.shouldNotContain(NON_METHOD);
  62     }
  63   }
  64 
  65   private static void verifyCodeHeapNotExists(ProcessBuilder pb, String... heapNames) throws Exception {
  66     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  67     out.shouldHaveExitValue(0);
  68     for (String name : heapNames) {
  69       out.shouldNotContain(name);
  70     }
  71   }
  72 
  73   private static void failsWith(ProcessBuilder pb, String message) throws Exception {
  74     OutputAnalyzer out = new OutputAnalyzer(pb.start());
  75     out.shouldContain(message);


< prev index next >