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
25
26 package org.graalvm.compiler.hotspot.test;
27
28 import java.util.Arrays;
29
30 import org.graalvm.compiler.bytecode.Bytecode;
31 import org.graalvm.compiler.bytecode.BytecodeDisassembler;
32 import org.graalvm.compiler.bytecode.BytecodeStream;
33 import org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecode;
34 import org.graalvm.compiler.core.CompilationWrapper.ExceptionAction;
35 import org.graalvm.compiler.core.GraalCompilerOptions;
36 import org.graalvm.compiler.core.target.Backend;
37 import org.graalvm.compiler.core.test.GraalCompilerTest;
38 import org.graalvm.compiler.debug.DebugContext;
39 import org.graalvm.compiler.debug.GraalError;
40 import org.graalvm.compiler.debug.TTY;
41 import org.graalvm.compiler.hotspot.CompilationTask;
42 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
43 import org.graalvm.compiler.hotspot.HotSpotGraalCompiler;
44 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
45 import org.graalvm.compiler.java.BciBlockMapping;
46 import org.graalvm.compiler.java.BciBlockMapping.BciBlock;
47 import org.graalvm.compiler.nodes.StructuredGraph;
48 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
49 import org.graalvm.compiler.options.OptionValues;
50 import org.junit.Assert;
51
52 import jdk.vm.ci.code.Architecture;
53 import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
54 import jdk.vm.ci.hotspot.HotSpotCompilationRequestResult;
117 }
118 }
119 }
120 }
121 TTY.println("Cannot find loop back edge with bytecode loops at:%s", Arrays.toString(bciBlockMapping.getLoopHeaders()));
122 TTY.println(new BytecodeDisassembler().disassemble(code));
123 return -1;
124 }
125
126 protected static void checkResult(Result result) {
127 Assert.assertNull("Unexpected exception", result.exception);
128 Assert.assertNotNull(result.returnValue);
129 Assert.assertTrue(result.returnValue instanceof ReturnValue);
130 Assert.assertEquals(ReturnValue.SUCCESS, result.returnValue);
131 }
132
133 protected void compileOSR(OptionValues options, ResolvedJavaMethod method) {
134 OptionValues goptions = options;
135 // Silence diagnostics for permanent bailout errors as they
136 // are expected for some OSR tests.
137 if (!GraalCompilerOptions.CompilationBailoutAction.hasBeenSet(options)) {
138 goptions = new OptionValues(options, GraalCompilerOptions.CompilationBailoutAction, ExceptionAction.Silent);
139 }
140 // ensure eager resolving
141 StructuredGraph graph = parseEager(method, AllowAssumptions.YES, goptions);
142 DebugContext debug = graph.getDebug();
143 int bci = getBackedgeBCI(debug, method);
144 assert bci != -1;
145 compile(debug, method, bci);
146 }
147
148 protected enum ReturnValue {
149 SUCCESS,
150 FAILURE,
151 SIDE
152 }
153
154 public GraalOSRTestBase() {
155 super();
156 }
157
158 public GraalOSRTestBase(Class<? extends Architecture> arch) {
|
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
25
26 package org.graalvm.compiler.hotspot.test;
27
28 import java.util.Arrays;
29
30 import org.graalvm.compiler.bytecode.Bytecode;
31 import org.graalvm.compiler.bytecode.BytecodeDisassembler;
32 import org.graalvm.compiler.bytecode.BytecodeStream;
33 import org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecode;
34 import org.graalvm.compiler.core.GraalCompilerOptions;
35 import org.graalvm.compiler.core.target.Backend;
36 import org.graalvm.compiler.core.test.GraalCompilerTest;
37 import org.graalvm.compiler.debug.DebugContext;
38 import org.graalvm.compiler.debug.GraalError;
39 import org.graalvm.compiler.debug.TTY;
40 import org.graalvm.compiler.hotspot.CompilationTask;
41 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
42 import org.graalvm.compiler.hotspot.HotSpotGraalCompiler;
43 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
44 import org.graalvm.compiler.java.BciBlockMapping;
45 import org.graalvm.compiler.java.BciBlockMapping.BciBlock;
46 import org.graalvm.compiler.nodes.StructuredGraph;
47 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
48 import org.graalvm.compiler.options.OptionValues;
49 import org.junit.Assert;
50
51 import jdk.vm.ci.code.Architecture;
52 import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
53 import jdk.vm.ci.hotspot.HotSpotCompilationRequestResult;
116 }
117 }
118 }
119 }
120 TTY.println("Cannot find loop back edge with bytecode loops at:%s", Arrays.toString(bciBlockMapping.getLoopHeaders()));
121 TTY.println(new BytecodeDisassembler().disassemble(code));
122 return -1;
123 }
124
125 protected static void checkResult(Result result) {
126 Assert.assertNull("Unexpected exception", result.exception);
127 Assert.assertNotNull(result.returnValue);
128 Assert.assertTrue(result.returnValue instanceof ReturnValue);
129 Assert.assertEquals(ReturnValue.SUCCESS, result.returnValue);
130 }
131
132 protected void compileOSR(OptionValues options, ResolvedJavaMethod method) {
133 OptionValues goptions = options;
134 // Silence diagnostics for permanent bailout errors as they
135 // are expected for some OSR tests.
136 if (!GraalCompilerOptions.CompilationBailoutAsFailure.hasBeenSet(options)) {
137 goptions = new OptionValues(options, GraalCompilerOptions.CompilationBailoutAsFailure, false);
138 }
139 // ensure eager resolving
140 StructuredGraph graph = parseEager(method, AllowAssumptions.YES, goptions);
141 DebugContext debug = graph.getDebug();
142 int bci = getBackedgeBCI(debug, method);
143 assert bci != -1;
144 compile(debug, method, bci);
145 }
146
147 protected enum ReturnValue {
148 SUCCESS,
149 FAILURE,
150 SIDE
151 }
152
153 public GraalOSRTestBase() {
154 super();
155 }
156
157 public GraalOSRTestBase(Class<? extends Architecture> arch) {
|