use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.
the class LIRNativeImageCodeCache method layoutMethods.
@SuppressWarnings("try")
@Override
public void layoutMethods(DebugContext debug, String imageName, BigBang bb, ForkJoinPool threadPool) {
try (Indent indent = debug.logAndIndent("layout methods")) {
// Assign a location to all methods.
assert codeCacheSize == 0;
HostedMethod firstMethod = null;
for (Entry<HostedMethod, CompilationResult> entry : compilations.entrySet()) {
HostedMethod method = entry.getKey();
if (firstMethod == null) {
firstMethod = method;
}
CompilationResult compilation = entry.getValue();
compilationsByStart.put(codeCacheSize, compilation);
method.setCodeAddressOffset(codeCacheSize);
codeCacheSize = NumUtil.roundUp(codeCacheSize + compilation.getTargetCodeSize(), SubstrateOptions.codeAlignment());
}
buildRuntimeMetadata(new MethodPointer(firstMethod), WordFactory.unsigned(codeCacheSize));
}
}
use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.
the class ReflectionFeature method register.
private CFunctionPointer register(ResolvedJavaMethod method) {
AnalysisMethod aMethod = method instanceof AnalysisMethod ? (AnalysisMethod) method : analysisAccess.getUniverse().lookup(method);
analysisAccess.registerAsCompiled(aMethod);
return new MethodPointer(aMethod);
}
use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.
the class DynamicHubInitializer method buildRuntimeInitializationInfo.
private ClassInitializationInfo buildRuntimeInitializationInfo(AnalysisType type) {
assert !type.isInitialized();
try {
/*
* Check if there are any linking errors. This method throws an error even if linking
* already failed in a previous attempt.
*/
type.link();
} catch (VerifyError e) {
/* Synthesize a VerifyError to be thrown at run time. */
AnalysisMethod throwVerifyError = metaAccess.lookupJavaMethod(ExceptionSynthesizer.throwExceptionMethod(VerifyError.class));
registerAsCompiled(throwVerifyError);
return new ClassInitializationInfo(new MethodPointer(throwVerifyError));
} catch (Throwable t) {
/*
* All other linking errors will be reported as NoClassDefFoundError when initialization
* is attempted at run time.
*/
return ClassInitializationInfo.FAILED_INFO_SINGLETON;
}
/*
* Now we now that there are no linking errors, we can register the class initialization
* information.
*/
assert type.isLinked();
CFunctionPointer classInitializerFunction = null;
AnalysisMethod classInitializer = type.getClassInitializer();
if (classInitializer != null) {
assert classInitializer.getCode() != null;
registerAsCompiled(classInitializer);
classInitializerFunction = new MethodPointer(classInitializer);
}
return new ClassInitializationInfo(classInitializerFunction);
}
use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.
the class CEntryPointCallStubFeature method registerJavaStubForMethod.
public AnalysisMethod registerJavaStubForMethod(AnalysisMethod method) {
return methodToJavaStub.compute(method, (key, existingValue) -> {
AnalysisMethod value = existingValue;
if (value == null) {
assert !bb.getUniverse().sealed();
AnalysisMethod nativeStub = registerStubForMethod(method, () -> CEntryPointData.create(method));
CFunctionPointer nativeStubAddress = new MethodPointer(nativeStub);
String stubName = SubstrateUtil.uniqueShortName(method);
ResolvedJavaType holderClass = bb.getMetaAccess().lookupJavaType(IsolateLeaveStub.class).getWrapped();
CEntryPointJavaCallStubMethod stub = new CEntryPointJavaCallStubMethod(method.getWrapped(), stubName, holderClass, nativeStubAddress);
value = bb.getUniverse().lookup(stub);
}
return value;
});
}
use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.
the class DeoptimizationFeature method beforeCompilation.
@Override
public void beforeCompilation(BeforeCompilationAccess a) {
CompilationAccessImpl config = (CompilationAccessImpl) a;
config.registerAsImmutable(ImageSingletons.lookup(DeoptimizationSupport.class));
HostedMetaAccess metaAccess = config.getMetaAccess();
DeoptimizationSupport.setDeoptStubPointer(new MethodPointer(metaAccess.lookupJavaMethod(deoptStubMethod)));
}
Aggregations