Skip to content
Open
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 @@ -74,29 +74,33 @@ public final class InvokeNode extends AbstractMemoryCheckpoint implements Invoke
protected int bci;
protected boolean polymorphic;
protected InlineControl inlineControl;
protected final LocationIdentity identity;
/**
* The location killed by the invoke. Typically, it will be {@link LocationIdentity#any()}, but
* an interprocedural analysis can provide more precise location.
*/
protected LocationIdentity killedLocationIdentity;
private boolean isInOOMETry;
private boolean sideEffect;

public InvokeNode(CallTargetNode callTarget, int bci) {
this(callTarget, bci, callTarget.returnStamp().getTrustedStamp());
}

public InvokeNode(CallTargetNode callTarget, int bci, LocationIdentity identity) {
this(callTarget, bci, callTarget.returnStamp().getTrustedStamp(), identity);
public InvokeNode(CallTargetNode callTarget, int bci, LocationIdentity killedLocationIdentity) {
this(callTarget, bci, callTarget.returnStamp().getTrustedStamp(), killedLocationIdentity);
}

public InvokeNode(CallTargetNode callTarget, int bci, Stamp stamp) {
this(callTarget, bci, stamp, LocationIdentity.any());
}

public InvokeNode(CallTargetNode callTarget, int bci, Stamp stamp, LocationIdentity identity) {
public InvokeNode(CallTargetNode callTarget, int bci, Stamp stamp, LocationIdentity killedLocationIdentity) {
super(TYPE, stamp);
this.callTarget = callTarget;
this.bci = bci;
this.polymorphic = false;
this.inlineControl = InlineControl.Normal;
this.identity = identity;
this.killedLocationIdentity = killedLocationIdentity;
this.sideEffect = super.hasSideEffect();
}

Expand Down Expand Up @@ -146,7 +150,11 @@ public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {

@Override
public LocationIdentity getKilledLocationIdentity() {
return identity;
return killedLocationIdentity;
}

public void setKilledLocationIdentity(LocationIdentity identity) {
this.killedLocationIdentity = identity;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

import java.util.Map;

import org.graalvm.word.LocationIdentity;

import jdk.graal.compiler.core.common.type.Stamp;
import jdk.graal.compiler.graph.IterableNodeType;
import jdk.graal.compiler.graph.Node;
Expand All @@ -49,8 +51,6 @@
import jdk.graal.compiler.nodes.spi.SimplifierTool;
import jdk.graal.compiler.nodes.spi.UncheckedInterfaceProvider;
import jdk.graal.compiler.nodes.util.GraphUtil;
import org.graalvm.word.LocationIdentity;

import jdk.vm.ci.code.BytecodeFrame;

// @formatter:off
Expand All @@ -70,6 +70,12 @@ public final class InvokeWithExceptionNode extends WithExceptionNode implements
protected boolean polymorphic;
protected InlineControl inlineControl;
private boolean isInOOMETry;
/**
* The location killed by the invoke. Typically, it will be {@link LocationIdentity#any()}, but
* an interprocedural analysis can provide more precise location.
*/
private LocationIdentity killedLocationIdentity = LocationIdentity.any();
private boolean sideEffect = true;

public InvokeWithExceptionNode(CallTargetNode callTarget, AbstractBeginNode exceptionEdge, int bci) {
super(TYPE, callTarget.returnStamp().getTrustedStamp());
Expand Down Expand Up @@ -158,12 +164,20 @@ public void setStateAfter(FrameState stateAfter) {

@Override
public boolean hasSideEffect() {
return true;
return sideEffect;
}

public void setSideEffect(boolean withSideEffects) {
this.sideEffect = withSideEffects;
}

@Override
public LocationIdentity getKilledLocationIdentity() {
return LocationIdentity.any();
return killedLocationIdentity;
}

public void setKilledLocationIdentity(LocationIdentity killedLocationIdentity) {
this.killedLocationIdentity = killedLocationIdentity;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,13 @@ public ParameterNode getParameter(int index) {
return null;
}

/**
* Returns an iterable for looping over all {@link Invoke}s that are associated with
* {@link MethodCallTargetNode}s. Note that since the internal iteration is based on
* {@link MethodCallTargetNode}s, it <b>does not</b> cover other kinds of invokes in the graph.
* If accessing all invokes is necessary for correctness, use a loop over all nodes with
* {@link #getNodes()} and an {@code instanceof} check instead.
*/
public Iterable<Invoke> getInvokes() {
final Iterator<MethodCallTargetNode> callTargets = getNodes(MethodCallTargetNode.TYPE).iterator();
return new Iterable<>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*/
package jdk.graal.compiler.nodes.spi;

import jdk.graal.compiler.nodes.memory.MemoryKill;
import org.graalvm.word.LocationIdentity;

public interface MemoryEdgeProxy extends Proxy, MemoryKill {
import jdk.graal.compiler.nodes.memory.SingleMemoryKill;

public interface MemoryEdgeProxy extends Proxy, SingleMemoryKill {

LocationIdentity getLocationIdentity();
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public void cleanupAfterAnalysis() {
@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.print(out, "features_time_ms", processFeaturesTimer.getTotalTimeMs());
StatisticsPrinter.print(out, "total_analysis_time_ms", analysisTimer.getTotalTimeMs());

StatisticsPrinter.printLast(out, "total_memory_bytes", analysisTimer.getTotalMemory());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ protected CompletionExecutor.Timing getTiming() {

@Override
public void printTimerStatistics(PrintWriter out) {
StatisticsPrinter.print(out, "typeflow_time_ms", typeFlowTimer.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());
StatisticsPrinter.print(out, "typeflow_time_ms", typeFlowTimer.getTotalTimeMs());
StatisticsPrinter.print(out, "verify_time_ms", verifyHeapTimer.getTotalTimeMs());
StatisticsPrinter.print(out, "features_time_ms", processFeaturesTimer.getTotalTimeMs());
StatisticsPrinter.print(out, "total_analysis_time_ms", analysisTimer.getTotalTimeMs());

StatisticsPrinter.printLast(out, "total_memory_bytes", analysisTimer.getTotalMemory());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void stop() {
}

/** Get timer total time in milliseconds. */
public double getTotalTime() {
return totalTime / 1000000d;
public double getTotalTimeMs() {
return totalTime / 1_000_000d;
}

/** Get total VM memory in bytes. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
*/
package com.oracle.graal.pointsto.util;

import com.oracle.graal.pointsto.reports.StatisticsPrinter;
import com.oracle.svm.util.ImageBuildStatistics;
import jdk.graal.compiler.debug.GraalError;
import org.graalvm.nativeimage.ImageSingletons;

import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.graal.pointsto.reports.StatisticsPrinter;
import com.oracle.svm.util.ImageBuildStatistics;

import jdk.graal.compiler.debug.GraalError;

public class TimerCollection implements ImageBuildStatistics.TimerCollectionPrinter {

public static TimerCollection singleton() {
Expand Down Expand Up @@ -102,7 +104,7 @@ public void printTimerStats(PrintWriter out) {
Iterator<Timer> it = this.timers.values().iterator();
while (it.hasNext()) {
Timer timer = it.next();
StatisticsPrinter.print(out, timer.getName() + "_time", ((int) timer.getTotalTime()));
StatisticsPrinter.print(out, timer.getName() + "_time", ((int) timer.getTotalTimeMs()));
if (it.hasNext()) {
StatisticsPrinter.print(out, timer.getName() + "_memory", timer.getTotalMemory());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
import java.util.function.BooleanSupplier;
import java.util.function.Function;

import com.oracle.svm.core.imagelayer.LayeredImageOptions;
import com.oracle.svm.hosted.reflect.ReflectionFeature;
import org.graalvm.collections.EconomicSet;
import org.graalvm.collections.Pair;
import org.graalvm.nativeimage.ImageInfo;
Expand Down Expand Up @@ -160,6 +158,7 @@
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.image.ImageHeapLayouter;
import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport;
import com.oracle.svm.core.imagelayer.LayeredImageOptions;
import com.oracle.svm.core.jdk.ServiceCatalogSupport;
import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonSupport;
import com.oracle.svm.core.meta.MethodOffset;
Expand Down Expand Up @@ -201,6 +200,7 @@
import com.oracle.svm.hosted.analysis.ReachabilityTracePrinter;
import com.oracle.svm.hosted.analysis.SVMAnalysisMetaAccess;
import com.oracle.svm.hosted.analysis.SubstrateUnsupportedFeatures;
import com.oracle.svm.hosted.analysis.tesa.TesaEngine;
import com.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor;
import com.oracle.svm.hosted.c.CAnnotationProcessorCache;
import com.oracle.svm.hosted.c.CConstantValueSupportImpl;
Expand Down Expand Up @@ -253,6 +253,8 @@
import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin;
import com.oracle.svm.hosted.phases.VerifyDeoptLIRFrameStatesPhase;
import com.oracle.svm.hosted.phases.VerifyNoGuardsPhase;
import com.oracle.svm.hosted.pltgot.PLTGOTOptions;
import com.oracle.svm.hosted.reflect.ReflectionFeature;
import com.oracle.svm.hosted.reflect.proxy.ProxyRenamingSubstitutionProcessor;
import com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins;
import com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor;
Expand Down Expand Up @@ -594,6 +596,15 @@ protected void doRun(Map<Method, CEntryPointData> entryPoints, JavaMainSupport j
new UniverseBuilder(aUniverse, bb.getMetaAccess(), hUniverse, hMetaAccess, HostedConfiguration.instance().createStrengthenGraphs(bb, hUniverse),
bb.getUnsupportedFeatures()).build(debug);

if (TesaEngine.enabled()) {
/*
* Fixed-point loops are started after universe building, because the initial
* state for each method is computed after strengthen graphs, which is executed
* in UniverseBuilder.
*/
TesaEngine.get().runFixedPointLoops(bb);
}

BuildPhaseProvider.markHostedUniverseBuilt();
ClassInitializationSupport classInitializationSupport = bb.getHostVM().getClassInitializationSupport();
SubstratePlatformConfigurationProvider platformConfig = getPlatformConfig(hMetaAccess);
Expand Down Expand Up @@ -825,6 +836,16 @@ protected boolean runPointsToAnalysis(String imageName, OptionValues options, De
HostedImageLayerBuildingSupport.singleton().getWriter().initializeExternalValues();
}
}
if (TesaEngine.enabled()) {
/*
* Seal the TESA engine, prevent more analyses from being registered.
* Technically, we could currently allow registrations even during the
* Feature#beforeUniverseBuilding callbacks. But we are intentionally being
* stricter about registrations in case we would like to perform some TESA steps
* already during or immediately after PTA in the future.
*/
TesaEngine.get().seal();
}
}

try (ReporterClosable _ = ProgressReporter.singleton().printAnalysis(bb.getUniverse(), nativeLibraries.getLibraries())) {
Expand Down Expand Up @@ -881,6 +902,10 @@ protected boolean runPointsToAnalysis(String imageName, OptionValues options, De
bb.getUnsupportedFeatures().report(bb);
bb.checkUserLimitations();

if (TesaEngine.enabled()) {
TesaEngine.get().saveCallGraph(bb);
}

bb.afterAnalysis();
} catch (UnsupportedFeatureException ufe) {
throw FallbackFeature.reportAsFallback(ufe);
Expand Down Expand Up @@ -1056,6 +1081,18 @@ protected void setupNativeImage(OptionValues options, Map<Method, CEntryPointDat

bb = createBigBang(debug, options, aUniverse, aMetaAccess, aProviders, annotationSubstitutions);
aUniverse.setBigBang(bb);
if (TesaEngine.Options.TransitiveEffectSummaryAnalysis.getValue()) {
/*
* Tesa only works in ClosedTypeWorld. PLTGOT seems to create memory kills
* unseen by TESA.
*/
if (SubstrateOptions.useClosedTypeWorld() && !PLTGOTOptions.EnablePLTGOT.getValue()) {
TesaEngine engine = new TesaEngine();
ImageSingletons.add(TesaEngine.class, engine);
/* Register the engine in ImageBuildStatistics for reporting. */
ImageSingletons.add(ImageBuildStatistics.TesaPrinter.class, engine);
}
}
if (imageLayerLoader != null) {
imageLayerLoader.initNodeClassMap();
}
Expand Down
Loading