use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class HotSpotForeignCallLinkageImpl method finalizeAddress.
@Override
public void finalizeAddress(Backend backend) {
if (address == 0) {
assert checkStubCondition();
InstalledCode code = stub.getCode(backend);
EconomicSet<Register> destroyedRegisters = stub.getDestroyedCallerRegisters();
if (!destroyedRegisters.isEmpty()) {
AllocatableValue[] temporaryLocations = new AllocatableValue[destroyedRegisters.size()];
int i = 0;
for (Register reg : destroyedRegisters) {
temporaryLocations[i++] = reg.asValue();
}
temporaries = temporaryLocations;
}
address = code.getStart();
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class HotSpotStackIntrospectionTest method test.
private void test(String name) throws InvalidInstalledCodeException {
ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(getMethod(name));
Function<Void, Void> f = o -> {
stackIntrospection.iterateFrames(null, null, 0, frame -> {
if (frame.getMethod().equals(method)) {
frame.materializeVirtualObjects(true);
}
return null;
});
return null;
};
InstalledCode code = getCode(method);
code.executeVarargs(f);
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class HotSpotUnsafeSubstitutionTest method testSubstitution.
public void testSubstitution(String testMethodName, Class<?> holder, String methodName, Class<?>[] parameterTypes, Object receiver, Object[] args1, Object[] args2) {
ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName);
ResolvedJavaMethod originalMethod = getResolvedJavaMethod(holder, methodName, parameterTypes);
// Force compilation
InstalledCode code = getCode(testMethod);
assert code != null;
// Verify that the original method and the substitution produce the same value
Object expected = invokeSafe(originalMethod, receiver, args1);
Object actual = invokeSafe(testMethod, null, args2);
assertDeepEquals(expected, actual);
// Verify that the generated code and the original produce the same value
expected = invokeSafe(originalMethod, receiver, args1);
actual = executeVarargsSafe(code, args2);
assertDeepEquals(expected, actual);
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class GraalCompilerAssumptionsTest method testAssumption.
/**
* Checks the behavior of class loading on {@link Assumption invalidation}. {@code methodName}
* is compiled and the resulting graph is checked for {@code expectedAssumption}. The code is
* installed and optionally {@code classToLoad} is loaded. The class is assumed to be an inner
* class of the test class and the name of the class to load is constructed relative to that.
*
* @param methodName the method to compile
* @param expectedAssumption expected {@link Assumption} instance to find in graph
* @param classToLoad an optional class to load to trigger an invalidation check
* @param willInvalidate true if loading {@code classToLoad} should invalidate the method
*/
protected void testAssumption(String methodName, Assumption expectedAssumption, String classToLoad, boolean willInvalidate) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);
StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
assertTrue(!graph.getAssumptions().isEmpty());
checkGraph(expectedAssumption, graph);
CompilationResult compilationResult = compile(javaMethod, graph);
final InstalledCode installedCode = getBackend().createDefaultInstalledCode(graph.getDebug(), javaMethod, compilationResult);
assertTrue(installedCode.isValid());
if (classToLoad != null) {
String fullName = getClass().getName() + "$" + classToLoad;
try {
Class.forName(fullName);
} catch (ClassNotFoundException e) {
fail("Can't find class %s", fullName);
}
assertTrue(!willInvalidate == installedCode.isValid(), "method should be %s", willInvalidate ? "invalid" : "valid");
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class GraalCompilerTest method executeActual.
protected Result executeActual(OptionValues options, ResolvedJavaMethod method, Object receiver, Object... args) {
before(method);
Object[] executeArgs = argsWithReceiver(receiver, args);
checkArgs(method, executeArgs);
InstalledCode compiledMethod = getCode(method, options);
try {
return new Result(compiledMethod.executeVarargs(executeArgs), null);
} catch (Throwable e) {
return new Result(null, e);
} finally {
after();
}
}
Aggregations