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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -58,4 +58,6 @@ public interface RuntimeReflectionSupport extends ReflectionRegistry {
int getReflectionMethodsCount();

int getReflectionFieldsCount();

boolean requiresProcessing();
}
1 change: 1 addition & 0 deletions substratevm/ci_includes/gate.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ builds += [
}
${labsjdk-ce-17} ${svm-common-gate} ${svm-common-windows-jdk17} ${svmUnittest} {
name: "gate-svm-windows-basics"
timelimit: "1:30:00"
run: [
${svm-cmd-gate} ["build,helloworld,test,svmjunit"]
]
Expand Down
8 changes: 8 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@
"jdk.internal.module",
"sun.text.spi",
"jdk.internal.reflect",
"sun.util.cldr",
"sun.util.locale"
],
"jdk.internal.vm.ci" : [
"jdk.vm.ci.runtime",
Expand Down Expand Up @@ -736,6 +738,7 @@
"sun.reflect.annotation",
"sun.reflect.generics.repository",
"jdk.internal.reflect",
"sun.reflect.generics.scope"
],
"jdk.internal.vm.ci" : [
"jdk.vm.ci.code",
Expand Down Expand Up @@ -1178,7 +1181,9 @@
"sun.reflect.generics.reflectiveObjects",
"sun.reflect.generics.repository",
"sun.reflect.generics.tree",
"sun.reflect.generics.scope",
"sun.util.calendar",
"sun.util.locale",
"sun.security.jca",
"sun.security.util",
"sun.security.provider",
Expand All @@ -1187,6 +1192,7 @@
"sun.reflect.generics.repository",
"jdk.internal.org.objectweb.asm",
"sun.util.locale.provider",
"sun.util.cldr",
"sun.util.resources",
"sun.invoke.util",
"sun.net",
Expand Down Expand Up @@ -1478,6 +1484,8 @@
"exports" : [
"com.oracle.graal.pointsto",
"com.oracle.graal.pointsto.api",
"com.oracle.graal.pointsto.heap",
"com.oracle.graal.pointsto.heap.value",
"com.oracle.graal.pointsto.reports",
"com.oracle.graal.pointsto.constraints",
"com.oracle.graal.pointsto.util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,7 @@ default void onFieldAccessed(AnalysisField field) {
default void onTypeInstantiated(AnalysisType type, UsageKind usageKind) {
}

@SuppressWarnings("unused")
default void onTypeInitialized(AnalysisType type) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.graal.pointsto.ObjectScanner.ReusableSet;
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 @@ -128,7 +127,7 @@ public abstract class PointsToAnalysis implements BigBang {
private final CompletionExecutor.Timing timing;

public final Timer typeFlowTimer;
public final Timer checkObjectsTimer;
public final Timer verifyHeapTimer;
public final Timer processFeaturesTimer;
public final Timer analysisTimer;

Expand All @@ -142,7 +141,7 @@ public PointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostedP
this.hostVM = hostVM;
String imageName = hostVM.getImageName();
this.typeFlowTimer = new Timer(imageName, "(typeflow)", false);
this.checkObjectsTimer = new Timer(imageName, "(objects)", false);
this.verifyHeapTimer = new Timer(imageName, "(verify)", false);
this.processFeaturesTimer = new Timer(imageName, "(features)", false);
this.analysisTimer = new Timer(imageName, "analysis", true);

Expand Down Expand Up @@ -194,14 +193,14 @@ public Timer getProcessFeaturesTimer() {
@Override
public void printTimers() {
typeFlowTimer.print();
checkObjectsTimer.print();
verifyHeapTimer.print();
processFeaturesTimer.print();
}

@Override
public void printTimerStatistics(PrintWriter out) {
StatisticsPrinter.print(out, "typeflow_time_ms", typeFlowTimer.getTotalTime());
StatisticsPrinter.print(out, "objects_time_ms", checkObjectsTimer.getTotalTime());
StatisticsPrinter.print(out, "verify_time_ms", verifyHeapTimer.getTotalTime());
StatisticsPrinter.print(out, "features_time_ms", processFeaturesTimer.getTotalTime());
StatisticsPrinter.print(out, "total_analysis_time_ms", analysisTimer.getTotalTime());

Expand Down Expand Up @@ -323,13 +322,15 @@ public void cleanupAfterAnalysis() {
allSynchronizedTypeFlow = null;
unsafeLoads = null;
unsafeStores = null;
scannedObjects = null;

ConstantObjectsProfiler.constantTypes.clear();

universe.getTypes().forEach(AnalysisType::cleanupAfterAnalysis);
universe.getFields().forEach(AnalysisField::cleanupAfterAnalysis);
universe.getMethods().forEach(AnalysisMethod::cleanupAfterAnalysis);

universe.getHeapScanner().cleanupAfterAnalysis();
universe.getHeapVerifier().cleanupAfterAnalysis();
}

@Override
Expand Down Expand Up @@ -570,10 +571,6 @@ public ConstantFieldProvider getConstantFieldProvider() {
return providers.getConstantFieldProvider();
}

public CompletionExecutor getExecutor() {
return executor;
}

@Override
public void checkUserLimitations() {
}
Expand Down Expand Up @@ -630,26 +627,9 @@ public void postTask(final DebugContextRunnable task) {
public boolean finish() throws InterruptedException {
try (Indent indent = debug.logAndIndent("starting analysis in BigBang.finish")) {
universe.setAnalysisDataValid(false);
boolean didSomeWork = false;

int numTypes;
do {
didSomeWork |= doTypeflow();

/*
* Check if the object graph introduces any new types, which leads to new operations
* being posted.
*/
assert executor.getPostedOperations() == 0;
numTypes = universe.getTypes().size();
try (StopTimer t = checkObjectsTimer.start()) {
// track static fields
checkObjectGraph();
}
} while (executor.getPostedOperations() != 0 || numTypes != universe.getTypes().size());

boolean didSomeWork = doTypeflow();
assert executor.getPostedOperations() == 0;
universe.setAnalysisDataValid(true);

return didSomeWork;
}
}
Expand All @@ -668,39 +648,11 @@ public boolean doTypeflow() throws InterruptedException {
return didSomeWork;
}

private ReusableSet scannedObjects = new ReusableSet();

@SuppressWarnings("try")
private void checkObjectGraph() throws InterruptedException {
scannedObjects.reset();
// scan constants
boolean isParallel = PointstoOptions.ScanObjectsParallel.getValue(options);
ObjectScanner objectScanner = new AnalysisObjectScanner(this, isParallel ? executor : null, scannedObjects);
checkObjectGraph(objectScanner);
if (isParallel) {
executor.start();
objectScanner.scanBootImageHeapRoots(null, null);
executor.complete();
executor.shutdown();
executor.init(timing);
} else {
objectScanner.scanBootImageHeapRoots(null, null);
}
}

@Override
public HeapScanningPolicy scanningPolicy() {
return heapScanningPolicy;
}

/**
* Traverses the object graph to discover references to new types.
*
* @param objectScanner
*/
protected void checkObjectGraph(ObjectScanner objectScanner) {
}

@Override
public HostVM getHostVM() {
return hostVM;
Expand Down Expand Up @@ -744,8 +696,9 @@ public void runAnalysis(DebugContext debugContext, Function<AnalysisUniverse, Bo
"The analysis itself %s find a change in type states in the last iteration.",
numIterations, analysisChanged ? "DID" : "DID NOT"));
}

/* Allow features to change the universe. */
/*
* Allow features to change the universe.
*/
int numTypes = universe.getTypes().size();
int numMethods = universe.getMethods().size();
int numFields = universe.getFields().size();
Expand All @@ -754,12 +707,35 @@ public void runAnalysis(DebugContext debugContext, Function<AnalysisUniverse, Bo
throw AnalysisError.shouldNotReachHere(
"When a feature makes more types, methods, or fields reachable, it must require another analysis iteration via DuringAnalysisAccess.requireAnalysisIteration()");
}
return;
/*
* Manual rescanning doesn't explicitly require analysis iterations, but it can
* insert some pending operations.
*/
boolean pendingOperations = executor.getPostedOperations() > 0;
if (pendingOperations) {
System.out.println("Found pending operations, continuing analysis.");
continue;
}
/* Outer analysis loop is done. Check if heap verification modifies analysis. */
if (!analysisModified()) {
return;
}
}
}
}
}

@SuppressWarnings("try")
private boolean analysisModified() throws InterruptedException {
boolean analysisModified;
try (StopTimer ignored = verifyHeapTimer.start()) {
analysisModified = universe.getHeapVerifier().requireAnalysisIteration(executor);
}
/* Initialize for the next iteration. */
executor.init(timing);
return analysisModified;
}

@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);
Expand Down
Loading