Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,26 @@ public final void setDescriptor(OptionDescriptor descriptor) {

/**
* Returns the descriptor for this option, if it has been set by
* {@link #setDescriptor(OptionDescriptor)}.
* {@link #setDescriptor(OptionDescriptor)}. As descriptors are loaded lazily, this method will
* return {@code null} if the descriptors have not been loaded. Use {@link #loadDescriptor}
* instead to ensure a non-null descriptor is returned if available.
*/
public final OptionDescriptor getDescriptor() {
return descriptor;
}

/**
* Returns the descriptor for this option, triggering loading of descriptors if this descriptor
* is null. Note that it's still possible for this method to return null if this option does not
* have a descriptor created by a service loader.
*/
public final OptionDescriptor loadDescriptor() {
if (descriptor == null) {
Lazy.init();
}
return descriptor;
}

/**
* Checks that a descriptor exists for this key after triggering loading of descriptors.
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ By default, the build process tries to only use free memory (to avoid memory pre
If less than 8GB of memory are free, the build process falls back to use 85% of total memory.
Therefore, consider freeing up memory if your machine is slow during a build, for example, by closing applications that you do not need.

By default, the build process uses all available CPU cores to maximize speed.
By default, the build process uses all available processors to maximize speed, but not more than 32 threads.
Use the `--parallelism` option to set the number of threads explicitly (for example, `--parallelism=4`).
Use fewer threads to reduce load on your system as well as memory consumption (at the cost of a slower build process).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ForkJoinPool;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
Expand All @@ -52,7 +51,6 @@

import com.oracle.graal.pointsto.AnalysisObjectScanningObserver;
import com.oracle.graal.pointsto.AnalysisPolicy;
import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.api.PointstoOptions;
import com.oracle.graal.pointsto.flow.context.bytecode.BytecodeSensitiveAnalysisPolicy;
import com.oracle.graal.pointsto.heap.HeapSnapshotVerifier;
Expand Down Expand Up @@ -135,7 +133,6 @@ private PointsToAnalyzer(String mainEntryClass, OptionValues options) {
SnippetReflectionProvider snippetReflection = originalProviders.getSnippetReflection();
MetaAccessProvider originalMetaAccess = originalProviders.getMetaAccess();
debugContext = new DebugContext.Builder(options, new GraalDebugHandlersFactory(snippetReflection)).build();
ForkJoinPool executor = PointsToAnalysis.createExecutor(debugContext, Math.min(Runtime.getRuntime().availableProcessors(), 32));
StandaloneHost standaloneHost = new StandaloneHost(options, analysisClassLoader);
int wordSize = getWordSize();
AnalysisPolicy analysisPolicy = PointstoOptions.AllocationSiteSensitiveHeap.getValue(options) ? new BytecodeSensitiveAnalysisPolicy(options)
Expand All @@ -154,7 +151,8 @@ private PointsToAnalyzer(String mainEntryClass, OptionValues options) {
originalProviders.getPlatformConfigurationProvider(), aMetaAccessExtensionProvider, originalProviders.getLoopsDataProvider());
standaloneHost.initializeProviders(aProviders);
analysisName = getAnalysisName(mainEntryClass);
bigbang = new StandalonePointsToAnalysis(options, aUniverse, standaloneHost, aMetaAccess, snippetReflection, aConstantReflection, aProviders.getWordTypes(), executor, new TimerCollection());
bigbang = new StandalonePointsToAnalysis(options, aUniverse, standaloneHost, aMetaAccess, snippetReflection, aConstantReflection, aProviders.getWordTypes(), debugContext,
new TimerCollection());
standaloneHost.setImageName(analysisName);
aUniverse.setBigBang(bigbang);
ImageHeap heap = new ImageHeap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;

import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.api.HostVM;
Expand All @@ -43,17 +38,18 @@
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.util.TimerCollection;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;
import jdk.vm.ci.meta.ConstantReflectionProvider;

public class StandalonePointsToAnalysis extends PointsToAnalysis {
private final Set<AnalysisMethod> addedClinits = ConcurrentHashMap.newKeySet();

public StandalonePointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostVM hostVM,
AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes,
ForkJoinPool executorService, TimerCollection timerCollection) {
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, executorService, new UnsupportedFeatures(), timerCollection,
true);
public StandalonePointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostVM hostVM, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, DebugContext debugContext, TimerCollection timerCollection) {
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, new UnsupportedFeatures(), debugContext, timerCollection, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Function;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
Expand Down Expand Up @@ -101,7 +100,7 @@ public abstract class AbstractAnalysisEngine implements BigBang {

@SuppressWarnings("this-escape")
public AbstractAnalysisEngine(OptionValues options, AnalysisUniverse universe, HostVM hostVM, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, ForkJoinPool executorService, UnsupportedFeatures unsupportedFeatures,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, UnsupportedFeatures unsupportedFeatures, DebugContext debugContext,
TimerCollection timerCollection) {
this.options = options;
this.universe = universe;
Expand All @@ -110,7 +109,7 @@ public AbstractAnalysisEngine(OptionValues options, AnalysisUniverse universe, H
this.metaAccess = metaAccess;
this.analysisPolicy = universe.analysisPolicy();
this.hostVM = hostVM;
this.executor = new CompletionExecutor(this, executorService);
this.executor = new CompletionExecutor(debugContext, this);
this.unsupportedFeatures = unsupportedFeatures;

this.processFeaturesTimer = timerCollection.get(TimerCollection.Registry.FEATURES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,11 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
import java.util.function.Consumer;
import java.util.stream.StreamSupport;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.core.common.SuppressFBWarnings;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.Indent;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.graph.NodeList;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;

import com.oracle.graal.pointsto.api.HostVM;
import com.oracle.graal.pointsto.api.PointstoOptions;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatures;
Expand Down Expand Up @@ -84,8 +73,14 @@
import com.oracle.graal.pointsto.util.TimerCollection;
import com.oracle.svm.common.meta.MultiMethod;
import com.oracle.svm.util.ClassUtil;
import com.oracle.svm.util.ImageGeneratorThreadMarker;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.Indent;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.graph.NodeList;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;
import jdk.vm.ci.meta.ConstantReflectionProvider;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
Expand All @@ -111,9 +106,9 @@ public abstract class PointsToAnalysis extends AbstractAnalysisEngine {

@SuppressWarnings("this-escape")
public PointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostVM hostVM, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, ForkJoinPool executorService, UnsupportedFeatures unsupportedFeatures, TimerCollection timerCollection,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, UnsupportedFeatures unsupportedFeatures, DebugContext debugContext, TimerCollection timerCollection,
boolean strengthenGraalGraphs) {
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, executorService, unsupportedFeatures, timerCollection);
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, unsupportedFeatures, debugContext, timerCollection);
this.typeFlowTimer = timerCollection.createTimer("(typeflow)");

this.strengthenGraalGraphs = strengthenGraalGraphs;
Expand Down Expand Up @@ -537,16 +532,6 @@ public boolean doTypeflow() throws InterruptedException {
return didSomeWork;
}

@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "ForkJoinPool does support null for the exception handler.")
public static ForkJoinPool createExecutor(DebugContext debug, int numberOfThreads) {
ForkJoinPool.ForkJoinWorkerThreadFactory factory = debugThreadFactory(debug.areScopesEnabled() || debug.areMetricsEnabled() ? debug : null);
return new ForkJoinPool(numberOfThreads, factory, null, false);
}

private static ForkJoinPool.ForkJoinWorkerThreadFactory debugThreadFactory(DebugContext debug) {
return pool -> new SubstrateWorkerThread(pool, debug);
}

@Override
public void onTypeInstantiated(AnalysisType type, AnalysisType.UsageKind usageKind) {
/* Register the type as instantiated with all its super types. */
Expand Down Expand Up @@ -735,21 +720,4 @@ public void print() {
System.out.println();
}
}

private static class SubstrateWorkerThread extends ForkJoinWorkerThread
implements ImageGeneratorThreadMarker {
private final DebugContext debug;

SubstrateWorkerThread(ForkJoinPool pool, DebugContext debug) {
super(pool);
this.debug = debug;
}

@Override
protected void onTermination(Throwable exception) {
if (debug != null) {
debug.closeDumpHandlers(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@
import static com.oracle.graal.pointsto.ObjectScanner.ScanReason;

import java.util.Objects;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Consumer;

import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.options.OptionKey;
import jdk.graal.compiler.options.OptionType;

import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.ObjectScanner;
import com.oracle.graal.pointsto.ObjectScanner.ReusableSet;
Expand All @@ -46,6 +41,10 @@
import com.oracle.graal.pointsto.util.CompletionExecutor;
import com.oracle.svm.util.LogUtils;

import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.options.OptionKey;
import jdk.graal.compiler.options.OptionType;
import jdk.vm.ci.meta.JavaConstant;

public class HeapSnapshotVerifier {
Expand Down Expand Up @@ -74,8 +73,8 @@ public HeapSnapshotVerifier(BigBang bb, ImageHeap imageHeap, ImageHeapScanner sc
verbosity = Options.HeapVerifierVerbosity.getValue(bb.getOptions());
}

public boolean checkHeapSnapshot(UniverseMetaAccess metaAccess, ForkJoinPool threadPool, String stage) {
CompletionExecutor executor = new CompletionExecutor(bb, threadPool);
public boolean checkHeapSnapshot(DebugContext debug, UniverseMetaAccess metaAccess, String stage) {
CompletionExecutor executor = new CompletionExecutor(debug, bb);
executor.init();
return checkHeapSnapshot(metaAccess, executor, stage, false);
}
Expand Down
Loading