Path: blob/master/test/hotspot/jtreg/compiler/lib/ir_framework/Run.java
64507 views
/*1* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package compiler.lib.ir_framework;2425import compiler.lib.ir_framework.shared.TestFormatException;2627import java.lang.annotation.Retention;28import java.lang.annotation.RetentionPolicy;2930/**31* Annotation for a run method of a <b>custom run test</b>.32*33* <p>34* Let {@code t} be a test method specifying the {@link Test @Test} annotation and {@code r} be a run method specifying35* the {@code @Run(test = "t")} annotation. These two methods represent a so-called <i>custom run test</i>. The only36* difference to a <i>base test</i> (see {@link Test}) is that the framework will not invoke the test method {@code t}37* but instead the run method {@code r} which is then responsible to invoke {@code t} in any way and optionally do any38* additional verification (e.g. of the return value). If {@code r} does not specify {@link RunMode#STANDALONE} as39* {@link #mode()} property, the framework does the following, similar as for <i>base tests</i>:40* <ol>41* <li><p>The framework warms {@code r} up by invoking it for a predefined number of iterations (default: 2000)42* or any number specified by an additional {@link Warmup} annotation at the run method {@code r} or by using43* {@link TestFramework#setDefaultWarmup(int)} (could also be 0 which skips the warm-up completely which is44* similar to simulating {@code -Xcomp}). More information about the warm-up in general can be found in45* {@link Warmup @Warmup}.</li>46* <li><p>After the warm-up, the framework compiles the test method {@code t} at the specified compilation level set by47* {@link Test#compLevel()} (default {@link CompLevel#ANY} will pick the highest available level which is usually48* {@link CompLevel#C2}).</li>49* <li><p>The framework invokes the run method {@code r} one more time to check the compilation.</li>50* <li><p>The framework checks any specified {@link IR @IR} constraints at the test method {@code t}.51* More information about IR matching can be found at {@link IR}.</li>52* </ol>53*54* <p>55* If {@code r} specifies {@link RunMode#STANDALONE} as {@link #mode()} property, the framework gives complete56* control to the run method {@code r}:57* <ol>58* <li><p>The framework invokes the run method {@code r} only one time without any warm-up or compilation of59* {@code t} ({@link Warmup @Warmup} is not allowed at {@code r} in this case).</li>60* <li><p>After this single invocation, the framework directly checks any specified {@link IR} constraints at the test61* method {@code t}. The run method {@code r} needs to make sure to reliably trigger a C2 compilation. Otherwise,62* IR matching will fail. More information about IR matching can be found at {@link IR}.</li>63* </ol>64*65* <p>66* The test method {@code t} and run method {@code r} have the following properties:67* <ul>68* <li><p>{@code t} can specify any parameter or return type except {@link AbstractInfo} or any of its subclasses.</li>69* <li><p>{@code t} is not inlined.70* <li><p>{@code r} is not compiled nor inlined.71* <li><p>{@code r} is responsible to invoke {@code t} in any way (once, multiple times or even skipping on some72* invocations of {@code r}).73* <li><p>{@code r} can specify the following method parameter combinations:74* <ul>75* <li><p>void</li>76* <li><p>One parameter: {@link RunInfo} which provides some information about {@code t} and utility methods.</li>77* <li><p>Any other combination will result in a {@link TestFormatException}.78* </ul>79* <li><p>{@code t} and {@code r} must be part of the test class. Using {@code @Run} and {@code @Test} in nested or80* other helper classes is not allowed.</li>81* <li><p>{@code t} and {@code r} cannot specify any helper-method-specific compile command annotations82* ({@link ForceCompile @ForceCompile}, {@link DontCompile @DontCompile}, {@link ForceInline @ForceInline},83* {@link DontInline @DontInline}).</li>84* </ul>85*86* <p>87* Examples on how to write custom run tests can be found in {@link jdk.test.lib.hotspot.ir_framework.examples.CustomRunTestExample}88* and also as part of the internal testing in the package {@link jdk.test.lib.hotspot.ir_framework.tests}.89*90* @see Test91* @see RunInfo92* @see RunMode93*/94@Retention(RetentionPolicy.RUNTIME)95public @interface Run {96/**97* The associated {@link Test @Test} methods (one or more) for this {@code @Run} annotated run method.98* The framework directly invokes the run method instead of the associated {@code @Test} methods.99*/100String[] test();101102/**103* The mode of this custom run test.104*105* @see RunMode106*/107RunMode mode() default RunMode.NORMAL;108}109110111