Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/lib/ir_framework/Run.java
64507 views
1
/*
2
* Copyright (c) 2021, 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
*/
23
24
package compiler.lib.ir_framework;
25
26
import compiler.lib.ir_framework.shared.TestFormatException;
27
28
import java.lang.annotation.Retention;
29
import java.lang.annotation.RetentionPolicy;
30
31
/**
32
* Annotation for a run method of a <b>custom run test</b>.
33
*
34
* <p>
35
* Let {@code t} be a test method specifying the {@link Test @Test} annotation and {@code r} be a run method specifying
36
* the {@code @Run(test = "t")} annotation. These two methods represent a so-called <i>custom run test</i>. The only
37
* difference to a <i>base test</i> (see {@link Test}) is that the framework will not invoke the test method {@code t}
38
* but instead the run method {@code r} which is then responsible to invoke {@code t} in any way and optionally do any
39
* additional verification (e.g. of the return value). If {@code r} does not specify {@link RunMode#STANDALONE} as
40
* {@link #mode()} property, the framework does the following, similar as for <i>base tests</i>:
41
* <ol>
42
* <li><p>The framework warms {@code r} up by invoking it for a predefined number of iterations (default: 2000)
43
* or any number specified by an additional {@link Warmup} annotation at the run method {@code r} or by using
44
* {@link TestFramework#setDefaultWarmup(int)} (could also be 0 which skips the warm-up completely which is
45
* similar to simulating {@code -Xcomp}). More information about the warm-up in general can be found in
46
* {@link Warmup @Warmup}.</li>
47
* <li><p>After the warm-up, the framework compiles the test method {@code t} at the specified compilation level set by
48
* {@link Test#compLevel()} (default {@link CompLevel#ANY} will pick the highest available level which is usually
49
* {@link CompLevel#C2}).</li>
50
* <li><p>The framework invokes the run method {@code r} one more time to check the compilation.</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
* If {@code r} specifies {@link RunMode#STANDALONE} as {@link #mode()} property, the framework gives complete
57
* control to the run method {@code r}:
58
* <ol>
59
* <li><p>The framework invokes the run method {@code r} only one time without any warm-up or compilation of
60
* {@code t} ({@link Warmup @Warmup} is not allowed at {@code r} in this case).</li>
61
* <li><p>After this single invocation, the framework directly checks any specified {@link IR} constraints at the test
62
* method {@code t}. The run method {@code r} needs to make sure to reliably trigger a C2 compilation. Otherwise,
63
* IR matching will fail. More information about IR matching can be found at {@link IR}.</li>
64
* </ol>
65
*
66
* <p>
67
* The test method {@code t} and run method {@code r} have the following properties:
68
* <ul>
69
* <li><p>{@code t} can specify any parameter or return type except {@link AbstractInfo} or any of its subclasses.</li>
70
* <li><p>{@code t} is not inlined.
71
* <li><p>{@code r} is not compiled nor inlined.
72
* <li><p>{@code r} is responsible to invoke {@code t} in any way (once, multiple times or even skipping on some
73
* invocations of {@code r}).
74
* <li><p>{@code r} can specify the following method parameter combinations:
75
* <ul>
76
* <li><p>void</li>
77
* <li><p>One parameter: {@link RunInfo} which provides some information about {@code t} and utility methods.</li>
78
* <li><p>Any other combination will result in a {@link TestFormatException}.
79
* </ul>
80
* <li><p>{@code t} and {@code r} must be part of the test class. Using {@code @Run} and {@code @Test} in nested or
81
* other helper classes is not allowed.</li>
82
* <li><p>{@code t} and {@code r} cannot specify any helper-method-specific compile command annotations
83
* ({@link ForceCompile @ForceCompile}, {@link DontCompile @DontCompile}, {@link ForceInline @ForceInline},
84
* {@link DontInline @DontInline}).</li>
85
* </ul>
86
*
87
* <p>
88
* Examples on how to write custom run tests can be found in {@link jdk.test.lib.hotspot.ir_framework.examples.CustomRunTestExample}
89
* and also as part of the internal testing in the package {@link jdk.test.lib.hotspot.ir_framework.tests}.
90
*
91
* @see Test
92
* @see RunInfo
93
* @see RunMode
94
*/
95
@Retention(RetentionPolicy.RUNTIME)
96
public @interface Run {
97
/**
98
* The associated {@link Test @Test} methods (one or more) for this {@code @Run} annotated run method.
99
* The framework directly invokes the run method instead of the associated {@code @Test} methods.
100
*/
101
String[] test();
102
103
/**
104
* The mode of this custom run test.
105
*
106
* @see RunMode
107
*/
108
RunMode mode() default RunMode.NORMAL;
109
}
110
111