use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class MonitorDeoptTest method run0.
@Test
public void run0() throws Throwable {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod("test");
StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
removeLoopSafepoint(graph);
CompilationResult compilationResult = compile(javaMethod, graph);
final InstalledCode installedCode = getBackend().createDefaultInstalledCode(graph.getDebug(), javaMethod, compilationResult);
final Monitor monitor = new Monitor();
Thread controlThread = new Thread(new Runnable() {
@Override
public void run() {
try {
// Wait for thread to reach RUNNING_GRAAL and then invalidate the code
monitor.invalidate(installedCode);
// wait for the main thread to continue running in the interpreter
monitor.waitState(State.RUNNING_INTERPRETER);
// terminate the main thread
monitor.setState(State.TERMINATED);
} catch (InterruptedException e) {
}
}
});
controlThread.start();
boolean result = test(monitor);
Assert.assertTrue(result);
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class UnsafeVirtualizationTest method testPartialEscapeReadElimination.
public void testPartialEscapeReadElimination(String snippet, boolean canonicalizeBefore, Object... args) {
assert AF1Offset % 8 == 0 : "First of the two int-fields must be 8-byte aligned";
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
OptionValues options = graph.getOptions();
PhaseContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
if (canonicalizeBefore) {
canonicalizer.apply(graph, context);
}
Result r = executeExpected(method, null, args);
new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
try {
InstalledCode code = getCode(method, graph);
Object result = code.executeVarargs(args);
assertEquals(r, new Result(result, null));
} catch (Throwable e) {
assertFalse(true, e.toString());
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class VerifyDebugUsageTest method testDebugUsageClass.
@SuppressWarnings("try")
private static void testDebugUsageClass(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyDebugUsage().apply(graph, context);
}
}
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class VerifyVirtualizableTest method testVirtualizableEffects.
@SuppressWarnings("try")
private static void testVirtualizableEffects(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyVirtualizableUsage().apply(graph, context);
}
}
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class CompiledMethodTest method test3.
@Test
public void test3() {
final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod");
InstalledCode compiledMethod = getCode(javaMethod);
try {
Object result = compiledMethod.executeVarargs("1", "2", "3");
Assert.assertEquals("1 2 3", result);
} catch (InvalidInstalledCodeException t) {
Assert.fail("method invalidated");
}
}
Aggregations