Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ea5fc1c
create AbstractAnalysisEngine taking care of the generic static analy…
d-kozak Sep 14, 2021
a6395fb
introduce a new project for reachability analysis
d-kozak Sep 14, 2021
7f506f6
introduce AbstractReachabilityAnalysis
d-kozak Sep 14, 2021
d28a05a
implement the first part of reachability analysis methods
d-kozak Sep 14, 2021
c159c90
continue implementing the reachability analysis
d-kozak Sep 15, 2021
eda4706
continue implementing the reachability analysis, WIP
d-kozak Sep 23, 2021
0bbbd40
more fixes
d-kozak Sep 28, 2021
bd5a928
implementation in progress
d-kozak Oct 1, 2021
c3de5ad
implementation in progress
d-kozak Oct 5, 2021
5d14085
implementation in progress
d-kozak Oct 6, 2021
584c2f4
revert unnecessary changes in AnalysisParsedGraph
d-kozak Oct 7, 2021
efdc71c
cleanup
d-kozak Oct 7, 2021
6efa42d
more cleanup
d-kozak Oct 7, 2021
1bd030c
more cleanup
d-kozak Oct 8, 2021
fb14e11
differentiate between marking fields as read or written
d-kozak Oct 11, 2021
050122d
add functionality from NativeImagePointsToAnalysis into NativeImageRe…
d-kozak Oct 11, 2021
e18fe7e
analyze the snippet graphs
d-kozak Oct 11, 2021
8755ba9
wip
d-kozak Oct 12, 2021
c2f78f3
use AnalysisType.forAllSuperTypes when handling instantiation to ensu…
d-kozak Oct 14, 2021
fa4b470
handle CopyOf and CopyOfRange nodes
d-kozak Oct 15, 2021
2e9010c
handle embedded FrameStates
d-kozak Oct 15, 2021
07c8f01
cleanup
d-kozak Oct 15, 2021
baad44a
add uninterruptible annotations to RegisterDumper and UContextRegiste…
d-kozak Oct 15, 2021
fb5500a
add timers for object scanning and reachability
d-kozak Oct 18, 2021
c0a6156
use a proper fixpoint iteration in ReachabilityAnalysis.finish
d-kozak Oct 18, 2021
addcdee
extra compilation dumps
d-kozak Oct 19, 2021
7a002cf
add foreign calls to method summaries
d-kozak Oct 19, 2021
5c0c565
add timer for getting method summaries
d-kozak Oct 19, 2021
2a6cd03
fixes after rebase
d-kozak Oct 19, 2021
7b71240
switch the default to reachability to run the gates
d-kozak Oct 19, 2021
6dba8b5
resolve style issues
d-kozak Oct 20, 2021
99d14b4
fix various style issues
d-kozak Oct 22, 2021
3dc7feb
various fixes
d-kozak Oct 25, 2021
0715285
refactor NativeImageReachabilityAnalysis to reduce code redundancy
d-kozak Nov 2, 2021
6e4a695
method summaries WIP
d-kozak Nov 23, 2021
47d41d5
temporarily disable type initializer graph
d-kozak Nov 23, 2021
88165c7
fix after rebase
d-kozak Nov 23, 2021
b953920
temporarily update AMD64LinuxUContextRegisterDumper
d-kozak Nov 29, 2021
5c9b6bf
various fixes
d-kozak Dec 1, 2021
501990b
style fixes
d-kozak Dec 1, 2021
6c8c0e9
temporal logging
d-kozak Dec 2, 2021
36900bc
temporal extra loop in the analysis
d-kozak Dec 2, 2021
5f161ec
dump stats
d-kozak Dec 2, 2021
3a5df67
remove debug dumps
d-kozak Dec 3, 2021
98f49fd
try reducing max number of threads to 4
d-kozak Dec 3, 2021
abf985c
try reducing max number of threads to 1
d-kozak Dec 3, 2021
d5c0712
try not throwing the exception in SubstrateAllocationSnippets
d-kozak Dec 3, 2021
c5d6d36
dump summary info
d-kozak Dec 3, 2021
d8b8f0e
only dump one method
d-kozak Dec 3, 2021
a24b4ad
only dump one method - but with nodes
d-kozak Dec 4, 2021
21f927d
handle virtual instance and array nodes
d-kozak Dec 4, 2021
f9e744c
do not include virtual fields in summaries
d-kozak Dec 4, 2021
8e5f2a2
remove no longer necessary debug output
d-kozak Dec 4, 2021
5edeeac
temporarily allow com.oracle.svm.core.graal.snippets.DeoptHostedSnippets
d-kozak Dec 4, 2021
c1faf70
add missing uninterruptible annotation
d-kozak Dec 4, 2021
5c44879
add missing uninterruptible annotation
d-kozak Dec 4, 2021
503b04a
add missing uninterruptible annotation
d-kozak Dec 4, 2021
66feaf0
add missing uninterruptible annotation
d-kozak Dec 4, 2021
4beade6
re-enable multiple threads
d-kozak Dec 4, 2021
ee19fac
fixes after rebase
d-kozak Dec 5, 2021
c0d3a98
temporarily disable @Uninterruptible and @RestrictHeapAccess checking
d-kozak Dec 5, 2021
ab22fe0
schedule the onTypInstantiated instead of running it in the same thread
d-kozak Dec 9, 2021
7e620df
switch off the new build output
d-kozak Dec 9, 2021
aed8948
fixes after rebase
d-kozak Jan 19, 2022
07bed08
wip
d-kozak Jan 24, 2022
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
17 changes: 16 additions & 1 deletion substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,28 @@
"workingSets": "SVM",
},


"com.oracle.graal.reachability": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"com.oracle.graal.pointsto",
],
"checkstyle": "com.oracle.svm.core",
"javaCompliance": "11+",
"annotationProcessors": [
"compiler:GRAAL_PROCESSOR",
],
"workingSets": "SVM",
},

"com.oracle.svm.hosted": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"com.oracle.objectfile",
"com.oracle.svm.core",
"com.oracle.graal.pointsto",
"com.oracle.graal.reachability"
],
"requires" : [
"java.desktop",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/*
* Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.graal.pointsto;

import com.oracle.graal.pointsto.api.HostVM;
import com.oracle.graal.pointsto.api.PointstoOptions;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatures;
import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.reports.StatisticsPrinter;
import com.oracle.graal.pointsto.util.CompletionExecutor;
import com.oracle.graal.pointsto.util.Timer;
import jdk.vm.ci.meta.ConstantReflectionProvider;
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.nodes.spi.Replacements;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.printer.GraalDebugHandlersFactory;

import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ForkJoinPool;

public abstract class AbstractAnalysisEngine implements BigBang {

private final Boolean extendedAsserts;
private final Timer processFeaturesTimer;
private final Timer analysisTimer;
protected final Timer checkObjectsTimer;
protected final Timer reachabilityTimer;
protected final AnalysisMetaAccess metaAccess;
private final HostedProviders providers;
protected final HostVM hostVM;
protected final ForkJoinPool executorService;
private final Runnable heartbeatCallback;
protected final UnsupportedFeatures unsupportedFeatures;
protected final DebugContext debug;
protected final OptionValues options;
protected final AnalysisUniverse universe;
private final List<DebugHandlersFactory> debugHandlerFactories;
private final HeapScanningPolicy heapScanningPolicy;
private final Replacements replacements;
protected final CompletionExecutor executor;
protected final AnalysisTiming timing;

public AbstractAnalysisEngine(OptionValues options, AnalysisUniverse universe, HostedProviders providers, HostVM hostVM, ForkJoinPool executorService, Runnable heartbeatCallback,
UnsupportedFeatures unsupportedFeatures) {
this.options = options;
this.universe = universe;
this.debugHandlerFactories = Collections.singletonList(new GraalDebugHandlersFactory(providers.getSnippetReflection()));
this.debug = new org.graalvm.compiler.debug.DebugContext.Builder(options, debugHandlerFactories).build();
this.metaAccess = (AnalysisMetaAccess) providers.getMetaAccess();
this.providers = providers;
this.hostVM = hostVM;
this.executorService = executorService;
this.executor = new CompletionExecutor(this, executorService, heartbeatCallback);
// todo specify timing via option
this.timing = null;
this.executor.init(timing);
this.heartbeatCallback = heartbeatCallback;
this.unsupportedFeatures = unsupportedFeatures;
this.replacements = providers.getReplacements();

String imageName = hostVM.getImageName();
this.processFeaturesTimer = new Timer(imageName, "(features)", false);
this.checkObjectsTimer = new Timer(imageName, "(objects)", false);
this.reachabilityTimer = new Timer(imageName, "(reachability)", false);
this.analysisTimer = new Timer(imageName, "analysis", true);

this.extendedAsserts = PointstoOptions.ExtendedAsserts.getValue(options);

this.heapScanningPolicy = PointstoOptions.ExhaustiveHeapScan.getValue(options)
? HeapScanningPolicy.scanAll()
: HeapScanningPolicy.skipTypes(skippedHeapTypes());
}

@Override
public void cleanupAfterAnalysis() {
universe.getTypes().forEach(AnalysisType::cleanupAfterAnalysis);
universe.getFields().forEach(AnalysisField::cleanupAfterAnalysis);
universe.getMethods().forEach(AnalysisMethod::cleanupAfterAnalysis);
}

@Override
public Timer getAnalysisTimer() {
return analysisTimer;
}

@Override
public Timer getProcessFeaturesTimer() {
return processFeaturesTimer;
}

@Override
public void printTimers() {
reachabilityTimer.print();
checkObjectsTimer.print();
processFeaturesTimer.print();
}

@Override
public void printTimerStatistics(PrintWriter out) {
// todo print reachability here
StatisticsPrinter.print(out, "features_time_ms", processFeaturesTimer.getTotalTime());
StatisticsPrinter.print(out, "total_analysis_time_ms", analysisTimer.getTotalTime());

StatisticsPrinter.printLast(out, "total_memory_bytes", analysisTimer.getTotalMemory());
}

@Override
public AnalysisType[] skippedHeapTypes() {
return new AnalysisType[]{metaAccess.lookupJavaType(String.class)};
}

@Override
public boolean extendedAsserts() {
return extendedAsserts;
}

@Override
public OptionValues getOptions() {
return options;
}

@Override
public Runnable getHeartbeatCallback() {
return heartbeatCallback;
}

@Override
public DebugContext getDebug() {
return debug;
}

@Override
public List<DebugHandlersFactory> getDebugHandlerFactories() {
return debugHandlerFactories;
}

@Override
public AnalysisPolicy analysisPolicy() {
return universe.analysisPolicy();
}

@Override
public AnalysisUniverse getUniverse() {
return universe;
}

@Override
public HostedProviders getProviders() {
return providers;
}

@Override
public AnalysisMetaAccess getMetaAccess() {
return metaAccess;
}

@Override
public UnsupportedFeatures getUnsupportedFeatures() {
return unsupportedFeatures;
}

@Override
public final SnippetReflectionProvider getSnippetReflectionProvider() {
return providers.getSnippetReflection();
}

@Override
public final ConstantReflectionProvider getConstantReflectionProvider() {
return providers.getConstantReflection();
}

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

@Override
public HostVM getHostVM() {
return hostVM;
}

protected void schedule(Runnable task) {
executor.execute((d) -> task.run());
}

@Override
public Replacements getReplacements() {
return replacements;
}

private class AnalysisTiming extends PointsToAnalysis.BucketTiming {

@Override
public void printHeader() {
super.printHeader();
System.out.println();
}

@Override
public void print() {
super.print();
System.out.println();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.graal.pointsto;

import com.oracle.graal.pointsto.api.HostVM;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatures;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.HostedProviders;
import org.graalvm.compiler.options.OptionValues;

import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.util.concurrent.ForkJoinPool;

import static jdk.vm.ci.common.JVMCIError.shouldNotReachHere;

public abstract class AbstractReachabilityAnalysis extends AbstractAnalysisEngine {
public AbstractReachabilityAnalysis(OptionValues options, AnalysisUniverse universe, HostedProviders providers, HostVM hostVM, ForkJoinPool executorService, Runnable heartbeatCallback,
UnsupportedFeatures unsupportedFeatures) {
super(options, universe, providers, hostVM, executorService, heartbeatCallback, unsupportedFeatures);
}

@Override
public AnalysisType addRootClass(Class<?> clazz, boolean addFields, boolean addArrayClass) {
AnalysisType type = metaAccess.lookupJavaType(clazz);
type.registerAsReachable();
return addRootClass(type, addFields, addArrayClass);
}

@Override
public AnalysisMethod addRootMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
try {
Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
return addRootMethod(method);
} catch (NoSuchMethodException ex) {
throw shouldNotReachHere(ex);
}
}

@Override
public AnalysisMethod addRootMethod(Executable method) {
AnalysisMethod aMethod = metaAccess.lookupJavaMethod(method);
addRootMethod(aMethod);
return aMethod;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,22 @@
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisType.UsageKind;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.util.Timer;

import jdk.vm.ci.meta.ConstantReflectionProvider;
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.nodes.spi.Replacements;
import org.graalvm.compiler.options.OptionValues;

import java.io.PrintWriter;
import java.util.List;
import java.util.function.Function;


/**
* Central static analysis interface that groups together the functionality of reachability analysis
Expand Down Expand Up @@ -104,6 +116,10 @@ public interface BigBang extends ReachabilityAnalysis, HeapScanning {

void runAnalysis(DebugContext debug, Function<AnalysisUniverse, Boolean> duringAnalysisAction) throws InterruptedException;

boolean strengthenGraalGraphs();

Replacements getReplacements();

/** You can blacklist certain callees here. */
@SuppressWarnings("unused")
default boolean isCallAllowed(PointsToAnalysis bb, AnalysisMethod caller, AnalysisMethod target, NodeSourcePosition srcPosition) {
Expand Down
Loading