< prev index next >

test/compiler/tiered/LevelTransitionTest.java

Print this page




   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 import java.lang.reflect.Executable;
  25 import java.lang.reflect.Method;
  26 import java.util.Objects;
  27 import java.util.concurrent.Callable;

  28 
  29 /**
  30  * @test LevelTransitionTest
  31  * @library /testlibrary /../../test/lib /compiler/whitebox
  32  * @modules java.base/sun.misc
  33  *          java.management
  34  * @ignore 8067651
  35  * @build TransitionsTestExecutor LevelTransitionTest
  36  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  37  * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  38  *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
  39  *                   -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
  40  *                   -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::*
  41  *                   TransitionsTestExecutor LevelTransitionTest
  42  * @summary Test the correctness of compilation level transitions for different methods
  43  */
  44 public class LevelTransitionTest extends TieredLevelsTest {
  45     /** Shows if method was profiled by being executed on levels 2 or 3 */
  46     protected boolean isMethodProfiled;
  47     private int transitionCount;
  48 
  49     public static void main(String[] args) throws Throwable {
  50         assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
  51 


 116                 nextLevel = isMethodProfiled ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
 117                         : CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE;
 118                 break;
 119             case CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE:
 120             case CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE:
 121                 nextLevel = CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION;
 122                 isMethodProfiled = true;
 123                 break;
 124         }
 125         nextLevel = isTrivial() ? CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE : nextLevel;
 126         return Math.min(nextLevel, CompilerWhiteBoxTest.TIERED_STOP_AT_LEVEL);
 127     }
 128 
 129     /**
 130      * Determines if tested method should be handled as trivial
 131      *
 132      * @return {@code true} for trivial methods, {@code false} otherwise
 133      */
 134     protected boolean isTrivial() {
 135         return testCase == ExtendedTestCase.ACCESSOR_TEST
 136                 || testCase == SimpleTestCase.METHOD_TEST
 137                 || testCase == SimpleTestCase.STATIC_TEST
 138                 || (testCase == ExtendedTestCase.TRIVIAL_CODE_TEST && isMethodProfiled);
 139     }
 140 
 141     /**
 142      * Invokes {@linkplain #method} until its compilation level is changed.
 143      * Note that if the level won't change, it will be an endless loop
 144      *
 145      * @return compilation level the {@linkplain #method} was compiled on
 146      */
 147     protected int changeCompLevel() {
 148         int currentLevel = getCompLevel();
 149         int newLevel = currentLevel;
 150         int result = 0;
 151         while (currentLevel == newLevel) {
 152             result = compile(1);
 153             if (WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
 154                 newLevel = getCompLevel();
 155             }
 156         }
 157         return newLevel;




   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 import java.lang.reflect.Executable;
  25 import java.lang.reflect.Method;
  26 import java.util.Objects;
  27 import java.util.concurrent.Callable;
  28 import compiler.whitebox.CompilerWhiteBoxTest;
  29 
  30 /**
  31  * @test LevelTransitionTest
  32  * @library /testlibrary /../../test/lib /
  33  * @modules java.base/sun.misc
  34  *          java.management
  35  * @ignore 8067651
  36  * @build TransitionsTestExecutor LevelTransitionTest
  37  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  38  * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  39  *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
  40  *                   -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
  41  *                   -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::*
  42  *                   TransitionsTestExecutor LevelTransitionTest
  43  * @summary Test the correctness of compilation level transitions for different methods
  44  */
  45 public class LevelTransitionTest extends TieredLevelsTest {
  46     /** Shows if method was profiled by being executed on levels 2 or 3 */
  47     protected boolean isMethodProfiled;
  48     private int transitionCount;
  49 
  50     public static void main(String[] args) throws Throwable {
  51         assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
  52 


 117                 nextLevel = isMethodProfiled ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
 118                         : CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE;
 119                 break;
 120             case CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE:
 121             case CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE:
 122                 nextLevel = CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION;
 123                 isMethodProfiled = true;
 124                 break;
 125         }
 126         nextLevel = isTrivial() ? CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE : nextLevel;
 127         return Math.min(nextLevel, CompilerWhiteBoxTest.TIERED_STOP_AT_LEVEL);
 128     }
 129 
 130     /**
 131      * Determines if tested method should be handled as trivial
 132      *
 133      * @return {@code true} for trivial methods, {@code false} otherwise
 134      */
 135     protected boolean isTrivial() {
 136         return testCase == ExtendedTestCase.ACCESSOR_TEST
 137                 || testCase.name().equals("METHOD_TEST")
 138                 || testCase.name().equals("STATIC_TEST")
 139                 || (testCase == ExtendedTestCase.TRIVIAL_CODE_TEST && isMethodProfiled);
 140     }
 141 
 142     /**
 143      * Invokes {@linkplain #method} until its compilation level is changed.
 144      * Note that if the level won't change, it will be an endless loop
 145      *
 146      * @return compilation level the {@linkplain #method} was compiled on
 147      */
 148     protected int changeCompLevel() {
 149         int currentLevel = getCompLevel();
 150         int newLevel = currentLevel;
 151         int result = 0;
 152         while (currentLevel == newLevel) {
 153             result = compile(1);
 154             if (WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
 155                 newLevel = getCompLevel();
 156             }
 157         }
 158         return newLevel;


< prev index next >