use of com.oracle.svm.core.classinitialization.ClassInitializationInfo 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.classinitialization.ClassInitializationInfo in project graal by oracle.
the class ClassInitializationFeature method initializeSafeDelayedClasses.
/**
* Initializes all classes that are considered delayed by the system. Classes specified by the
* user will not be delayed.
*/
private Set<Class<?>> initializeSafeDelayedClasses(TypeInitializerGraph initGraph) {
Set<Class<?>> provenSafe = new HashSet<>();
classInitializationSupport.setConfigurationSealed(false);
classInitializationSupport.classesWithKind(RUN_TIME).stream().filter(t -> metaAccess.optionalLookupJavaType(t).isPresent()).filter(t -> metaAccess.lookupJavaType(t).isReachable()).filter(t -> classInitializationSupport.canBeProvenSafe(t)).forEach(c -> {
AnalysisType type = metaAccess.lookupJavaType(c);
if (!initGraph.isUnsafe(type)) {
classInitializationSupport.forceInitializeHosted(c, "proven safe to initialize", true);
/*
* See if initialization worked--it can fail due to implicit
* exceptions.
*/
if (!classInitializationSupport.shouldInitializeAtRuntime(c)) {
provenSafe.add(c);
ClassInitializationInfo initializationInfo = type.getClassInitializer() == null ? ClassInitializationInfo.NO_INITIALIZER_INFO_SINGLETON : ClassInitializationInfo.INITIALIZED_INFO_SINGLETON;
DynamicHub hub = ((SVMHost) universe.hostVM()).dynamicHub(type);
hub.setClassInitializationInfo(initializationInfo);
universe.getHeapScanner().rescanField(hub, dynamicHubClassInitializationInfoField);
}
}
});
return provenSafe;
}
use of com.oracle.svm.core.classinitialization.ClassInitializationInfo in project graal by oracle.
the class DynamicHubInitializer method buildClassInitializationInfo.
private void buildClassInitializationInfo(ImageHeapScanner heapScanner, AnalysisType type, DynamicHub hub) {
ClassInitializationInfo info;
if (hostVM.getClassInitializationSupport().shouldInitializeAtRuntime(type)) {
info = buildRuntimeInitializationInfo(type);
} else {
assert type.isInitialized();
info = type.getClassInitializer() == null ? ClassInitializationInfo.NO_INITIALIZER_INFO_SINGLETON : ClassInitializationInfo.INITIALIZED_INFO_SINGLETON;
}
hub.setClassInitializationInfo(info);
heapScanner.rescanField(hub, dynamicHubClassInitializationInfoField);
}
Aggregations