Path: blob/master/test/hotspot/jtreg/compiler/lib/ir_framework/Check.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 check method of a <b>checked test</b>.32*33* <p>34* Let {@code t} be a test method specifying the {@link Test @Test} annotation and {@code c} be a check method specifying35* the {@code @Check(test = "t")} annotation. These two methods represent a so-called <i>checked test</i>. The only36* difference to a <i>base test</i> (see {@link Test}) is that the framework will invoke the check method {@code c}37* directly after the invocation of the test method {@code t} which allows to do some additional verification,38* including the return value of {@code t}. The framework does the following, similar as for <i>base tests</i>:39* <ol>40* <li><p>The framework warms {@code t} up by invoking it for a predefined number of iterations (default: 2000)41* or any number specified by an additional {@link Warmup @Warmup} annotation at {@code t} or by using42* {@link TestFramework#setDefaultWarmup(int)} (could also be 0 which skips the warm-up completely which is43* similar to simulating {@code -Xcomp}). After each invocation of {@code t}, the framework also invokes44* {@code c} if the {@code @Check} annotation specifies {@link CheckAt#EACH_INVOCATION} at {@link #when()}.45* More information about the warm-up in general can be found at {@link Warmup}</li>46* <li><p>After the warm-up, the framework compiles {@code t} at the specified compilation level set by47* {@link Test#compLevel()} (default {@link CompLevel#ANY} will pick the highest available level which is48* usually {@link CompLevel#C2}).</li>49* <li><p>The framework invokes {@code t} one more time to run the compilation. Afterwards, the framework will50* always invoke {@code c} again to be able perform additional checks after the compilation of {@code t}.</li>51* <li><p>The framework checks any specified {@link IR @IR} constraints at the test method {@code t}.52* More information about IR matching can be found at {@link IR}.</li>53* </ol>54*55* <p>56* The test method {@code t} has the same properties and follows the same constraints as stated in {@link Test}.57* <p>58* The following additional constraints must be met for the test method {@code t} and check method {@code c}:59* <ul>60* <li><p>{@code c} must specify the method name {@code t} as property in {@code @Check(test = "t")}61* (see {@link #test()}. Specifying a non-{@code @Test} annotated method or a {@code @Test} method that62* has already been used by another {@code @Check} or {@link Run @Run} method results in a {@link TestFormatException}.63* <li><p>{@code c} can specify the following method parameter combinations:64* <ul>65* <li><p>void</li>66* <li><p>One parameter: {@link TestInfo} which provides some information about {@code t} and utility methods.</li>67* <li><p>One parameter: the <i>exact</i> same type as the return value of {@code t}. When {@code c} is68* invoked by the framework, this parameter contains the return value of {@code t}.</li>69* <li><p>1st parameter: {@link TestInfo}; 2nd parameter: the <i>exact</i> same type as the return value of70* {@code t} (see above)</li>71* <li><p> Any other combination will result in a {@link TestFormatException}.72* </ul>73* <li><p>{@code c} is not compiled nor inlined.74* <li><p>{@code c} must be part of the test class. Using {@code @Check} in nested or other classes is not allowed.</li>75* <li><p>{@code c} cannot specify any helper-method-specific compile command annotations76* ({@link ForceCompile @ForceCompile}, {@link DontCompile @DontCompile}, {@link ForceInline @ForceInline},77* {@link DontInline @DontInline}).</li>78* </ul>79*80* <p>81* If no verification is required, use a <i>base test</i> (see {@link Test}). If {@code t} must be invoked with more82* complex or varying arguments and/or the {@code t} must be invoked differently in subsequent invocations, use a83* <i>custom run test</i> (see {@link Run}).84*85* <p>86* Examples on how to write checked tests can be found in {@link jdk.test.lib.hotspot.ir_framework.examples.CheckedTestExample}87* and also as part of the internal testing in the package {@link jdk.test.lib.hotspot.ir_framework.tests}.88*89* @see Test90* @see TestInfo91* @see CheckAt92*/93@Retention(RetentionPolicy.RUNTIME)94public @interface Check {95/**96* The unique associated {@link Test} method for this {@code @Check} annotated check method. The framework will directly97* invoke the {@code @Check} method after each invocation or only after the compilation of the associated {@code @Test}98* method (depending on the value set with {@link #when()}).99* <p>100* If a non-{@code @Test} annotated method or a {@code @Test} method that has already been used by another101* {@code @Check} or {@link Run} method is specified, then a {@link TestFormatException} is thrown.102*103* @see Test104*/105String test();106/**107* When should the {@code @Check} method be invoked? By default, the check is done after each invocation which is108* encouraged if performance is not critical.109*110* @see CheckAt111*/112CheckAt when() default CheckAt.EACH_INVOCATION;113}114115116