use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.
the class AbstractInliningPolicy method previousLowLevelGraphSize.
protected static int previousLowLevelGraphSize(InlineInfo info) {
int size = 0;
for (int i = 0; i < info.numberOfMethods(); i++) {
ResolvedJavaMethod m = info.methodAt(i);
ProfilingInfo profile = info.graph().getProfilingInfo(m);
int compiledGraphSize = profile.getCompilerIRSize(StructuredGraph.class);
if (compiledGraphSize > 0) {
size += compiledGraphSize;
}
}
return size;
}
use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.
the class HotSpotGraalCompiler method compileHelper.
public CompilationResult compileHelper(CompilationResultBuilderFactory crbf, CompilationResult result, StructuredGraph graph, ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, OptionValues options) {
HotSpotBackend backend = graalRuntime.getHostBackend();
HotSpotProviders providers = backend.getProviders();
final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
Suites suites = getSuites(providers, options);
LIRSuites lirSuites = getLIRSuites(providers, options);
ProfilingInfo profilingInfo = useProfilingInfo ? method.getProfilingInfo(!isOSR, isOSR) : DefaultProfilingInfo.get(TriState.FALSE);
OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo, options);
/*
* Cut off never executed code profiles if there is code, e.g. after the osr loop, that is
* never executed.
*/
if (isOSR && !OnStackReplacementPhase.Options.DeoptAfterOSR.getValue(options)) {
optimisticOpts.remove(Optimization.RemoveNeverExecutedCode);
}
result.setEntryBCI(entryBCI);
boolean shouldDebugNonSafepoints = providers.getCodeCache().shouldDebugNonSafepoints();
PhaseSuite<HighTierContext> graphBuilderSuite = configGraphBuilderSuite(providers.getSuites().getDefaultGraphBuilderSuite(), shouldDebugNonSafepoints, isOSR);
GraalCompiler.compileGraph(graph, method, providers, backend, graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites, result, crbf);
if (!isOSR && useProfilingInfo) {
ProfilingInfo profile = profilingInfo;
profile.setCompilerIRSize(StructuredGraph.class, graph.getNodeCount());
}
return result;
}
use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.
the class ProfilingInfoTest method testNullSeen.
private void testNullSeen(String snippet) {
ProfilingInfo info = profile(snippet, 1);
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
continueProfiling(snippet, "ABC");
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
continueProfiling(snippet, new Object());
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
if (TriState.TRUE == info.getNullSeen(1)) {
// See the javadoc comment for ProfilingInfoTest.
continueProfiling(snippet, (Object) null);
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
continueProfiling(snippet, 0.0);
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
continueProfiling(snippet, new Object());
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
}
resetProfile(snippet);
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
}
use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.
the class InvokeGraal method compileAndInstallMethod.
/**
* The simplest way to compile a method, using the default behavior for everything.
*/
@SuppressWarnings("try")
protected InstalledCode compileAndInstallMethod(ResolvedJavaMethod method) {
/* Create a unique compilation identifier, visible in IGV. */
CompilationIdentifier compilationId = backend.getCompilationIdentifier(method);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
try (DebugContext.Scope s = debug.scope("compileAndInstallMethod", new DebugDumpScope(String.valueOf(compilationId), true))) {
/*
* The graph that is compiled. We leave it empty (no nodes added yet). This means that
* it will be filled according to the graphBuilderSuite defined below. We also specify
* that we want the compilation to make optimistic assumptions about runtime state such
* as the loaded class hierarchy.
*/
StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(method).compilationId(compilationId).build();
/*
* The phases used to build the graph. Usually this is just the GraphBuilderPhase. If
* the graph already contains nodes, it is ignored.
*/
PhaseSuite<HighTierContext> graphBuilderSuite = backend.getSuites().getDefaultGraphBuilderSuite();
/*
* The optimization phases that are applied to the graph. This is the main configuration
* point for Graal. Add or remove phases to customize your compilation.
*/
Suites suites = backend.getSuites().getDefaultSuites(options);
/*
* The low-level phases that are applied to the low-level representation.
*/
LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites(options);
/*
* We want Graal to perform all speculative optimistic optimizations, using the
* profiling information that comes with the method (collected by the interpreter) for
* speculation.
*/
OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL;
ProfilingInfo profilingInfo = graph.getProfilingInfo(method);
/* The default class and configuration for compilation results. */
CompilationResult compilationResult = new CompilationResult(graph.compilationId());
CompilationResultBuilderFactory factory = CompilationResultBuilderFactory.Default;
/* Invoke the whole Graal compilation pipeline. */
GraalCompiler.compileGraph(graph, method, providers, backend, graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites, compilationResult, factory);
/*
* Install the compilation result into the VM, i.e., copy the byte[] array that contains
* the machine code into an actual executable memory location.
*/
return backend.addInstalledCode(debug, method, asCompilationRequest(compilationId), compilationResult);
} catch (Throwable ex) {
throw debug.handle(ex);
}
}
use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.
the class GraalCompilerTest method executeActualCheckDeopt.
protected Result executeActualCheckDeopt(OptionValues options, ResolvedJavaMethod method, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) {
Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class);
ProfilingInfo profile = method.getProfilingInfo();
for (DeoptimizationReason reason : shouldNotDeopt) {
deoptCounts.put(reason, profile.getDeoptimizationCount(reason));
}
Result actual = executeActual(options, method, receiver, args);
// profile can change after execution
profile = method.getProfilingInfo();
for (DeoptimizationReason reason : shouldNotDeopt) {
Assert.assertEquals("wrong number of deopt counts for " + reason, (int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason));
}
return actual;
}
Aggregations