use of com.oracle.svm.core.option.HostedOptionValues in project graal by oracle.
the class NativeImageGenerator method run.
/**
* Executes the image build. Only one image can be built with this generator.
*/
public void run(Map<Method, CEntryPointData> entryPoints, Method mainEntryPoint, JavaMainSupport javaMainSupport, String imageName, AbstractBootImage.NativeImageKind k, SubstitutionProcessor harnessSubstitutions, ForkJoinPool compilationExecutor, ForkJoinPool analysisExecutor, EconomicSet<String> allOptionNames) {
try {
if (!buildStarted.compareAndSet(false, true)) {
throw UserError.abort("An image build has already been performed with this generator.");
}
int maxConcurrentThreads = NativeImageOptions.getMaximumNumberOfConcurrentThreads(new OptionValues(optionProvider.getHostedValues()));
this.imageBuildPool = createForkJoinPool(maxConcurrentThreads);
imageBuildPool.submit(() -> {
try {
ImageSingletons.add(HostedOptionValues.class, new HostedOptionValues(optionProvider.getHostedValues()));
ImageSingletons.add(RuntimeOptionValues.class, new RuntimeOptionValues(optionProvider.getRuntimeValues(), allOptionNames));
doRun(entryPoints, mainEntryPoint, javaMainSupport, imageName, k, harnessSubstitutions, compilationExecutor, analysisExecutor);
} finally {
try {
/*
* Make sure we clean up after ourselves even in the case of an exception.
*/
if (deleteTempDirectory) {
deleteAll(tempDirectory());
}
featureHandler.forEachFeature(Feature::cleanup);
} catch (Throwable e) {
/*
* Suppress subsequent errors so that we unwind the original error brought
* us here.
*/
}
}
}).get();
} catch (InterruptedException | CancellationException e) {
System.out.println("Interrupted!");
throw new InterruptImageBuilding();
} catch (ExecutionException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else if (e.getCause() instanceof Error) {
throw (Error) e.getCause();
}
} finally {
shutdownPoolSafe();
}
}
Aggregations