本文整理匯總了Java中jdk.vm.ci.meta.ProfilingInfo類的典型用法代碼示例。如果您正苦於以下問題:Java ProfilingInfo類的具體用法?Java ProfilingInfo怎麽用?Java ProfilingInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProfilingInfo類屬於jdk.vm.ci.meta包,在下文中一共展示了ProfilingInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compileGraph
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
@SuppressWarnings("try")
private CompilationResult compileGraph(ResolvedJavaMethod resolvedMethod, StructuredGraph graph, DebugContext debug) {
try (DebugContext.Scope s = debug.scope("AOTCompileMethod")) {
ProfilingInfo profilingInfo = DefaultProfilingInfo.get(TriState.FALSE);
final boolean isImmutablePIC = true;
CompilationIdentifier id = new CompilationIdentifier() {
@Override
public String toString(Verbosity verbosity) {
return resolvedMethod.getName();
}
};
CompilationResult compilationResult = new CompilationResult(id, isImmutablePIC);
return GraalCompiler.compileGraph(graph, resolvedMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, profilingInfo, getSuites(), getLirSuites(),
compilationResult, CompilationResultBuilderFactory.Default);
} catch (Throwable e) {
main.handleError(resolvedMethod, e, " (compiling graph)");
}
return null;
}
示例2: testTypeProfile
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
private void testTypeProfile(String testSnippet, int bci) {
ResolvedJavaType stringType = getMetaAccess().lookupJavaType(String.class);
ResolvedJavaType stringBuilderType = getMetaAccess().lookupJavaType(StringBuilder.class);
ProfilingInfo info = profile(testSnippet, "ABC");
JavaTypeProfile typeProfile = info.getTypeProfile(bci);
Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA);
Assert.assertEquals(1, typeProfile.getTypes().length);
Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType());
Assert.assertEquals(1.0, typeProfile.getTypes()[0].getProbability(), DELTA);
continueProfiling(testSnippet, new StringBuilder());
typeProfile = info.getTypeProfile(bci);
Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA);
Assert.assertEquals(2, typeProfile.getTypes().length);
Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType());
Assert.assertEquals(stringBuilderType, typeProfile.getTypes()[1].getType());
Assert.assertEquals(0.5, typeProfile.getTypes()[0].getProbability(), DELTA);
Assert.assertEquals(0.5, typeProfile.getTypes()[1].getProbability(), DELTA);
resetProfile(testSnippet);
typeProfile = info.getTypeProfile(bci);
Assert.assertNull(typeProfile);
}
示例3: testNullSeen
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
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));
}
示例4: profile
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
private ProfilingInfo profile(boolean resetProfile, int executions, String methodName, Object... args) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);
Assert.assertTrue(javaMethod.isStatic());
if (resetProfile) {
javaMethod.reprofile();
}
for (int i = 0; i < executions; ++i) {
try {
invoke(javaMethod, null, args);
} catch (Throwable e) {
Assert.fail("method should not throw an exception: " + e.toString());
}
}
ProfilingInfo info = javaMethod.getProfilingInfo();
// The execution counts are low so force maturity
info.setMature();
return info;
}
示例5: getProfilingInfo
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
@Override
public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
ProfilingInfo info;
if (Option.UseProfilingInformation.getBoolean() && methodData == null) {
long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset);
if (metaspaceMethodData != 0) {
methodData = new HotSpotMethodData(metaspaceMethodData, this);
String methodDataFilter = Option.TraceMethodDataFilter.getString();
if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) {
System.out.println(methodData.toString());
}
}
}
if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
// Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
// case of a deoptimization.
info = DefaultProfilingInfo.get(TriState.FALSE);
} else {
info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
}
return info;
}
示例6: getProfilingInfo
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
@Override
public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
ProfilingInfo info;
if (methodData == null) {
long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset);
if (metaspaceMethodData != 0) {
methodData = new HotSpotMethodData(metaspaceMethodData, this);
String methodDataFilter = Option.TraceMethodDataFilter.getString();
if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) {
System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":");
System.out.println(methodData.toString());
}
}
}
if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
// Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
// case of a deoptimization.
info = DefaultProfilingInfo.get(TriState.FALSE);
} else {
info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
}
return info;
}
示例7: Request
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
/**
* @param graph the graph to be compiled
* @param installedCodeOwner the method the compiled code will be associated with once
* installed. This argument can be null.
* @param providers
* @param backend
* @param graphBuilderSuite
* @param optimisticOpts
* @param profilingInfo
* @param suites
* @param lirSuites
* @param compilationResult
* @param factory
*/
public Request(StructuredGraph graph, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, PhaseSuite<HighTierContext> graphBuilderSuite,
OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) {
this.graph = graph;
this.installedCodeOwner = installedCodeOwner;
this.providers = providers;
this.backend = backend;
this.graphBuilderSuite = graphBuilderSuite;
this.optimisticOpts = optimisticOpts;
this.profilingInfo = profilingInfo;
this.suites = suites;
this.lirSuites = lirSuites;
this.compilationResult = compilationResult;
this.factory = factory;
}
示例8: emitFrontEnd
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
/**
* Builds the graph, optimizes it.
*/
@SuppressWarnings("try")
public static void emitFrontEnd(Providers providers, TargetProvider target, StructuredGraph graph, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts,
ProfilingInfo profilingInfo, Suites suites) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("FrontEnd"); DebugCloseable a = FrontEnd.start(debug)) {
HighTierContext highTierContext = new HighTierContext(providers, graphBuilderSuite, optimisticOpts);
if (graph.start().next() == null) {
graphBuilderSuite.apply(graph, highTierContext);
new DeadCodeEliminationPhase(DeadCodeEliminationPhase.Optionality.Optional).apply(graph);
debug.dump(DebugContext.BASIC_LEVEL, graph, "After parsing");
} else {
debug.dump(DebugContext.INFO_LEVEL, graph, "initial state");
}
suites.getHighTier().apply(graph, highTierContext);
graph.maybeCompress();
debug.dump(DebugContext.BASIC_LEVEL, graph, "After high tier");
MidTierContext midTierContext = new MidTierContext(providers, target, optimisticOpts, profilingInfo);
suites.getMidTier().apply(graph, midTierContext);
graph.maybeCompress();
debug.dump(DebugContext.BASIC_LEVEL, graph, "After mid tier");
LowTierContext lowTierContext = new LowTierContext(providers, target);
suites.getLowTier().apply(graph, lowTierContext);
debug.dump(DebugContext.BASIC_LEVEL, graph, "After low tier");
debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "Final HIR schedule");
} catch (Throwable e) {
throw debug.handle(e);
} finally {
graph.checkCancellation();
}
}
示例9: previousLowLevelGraphSize
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
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;
}
示例10: getProfilingInfo
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
/**
* Gets the profiling info for a given method that is or will be part of this graph, taking into
* account {@link #useProfilingInfo()}.
*/
public ProfilingInfo getProfilingInfo(ResolvedJavaMethod m) {
if (useProfilingInfo && m != null) {
return m.getProfilingInfo();
} else {
return DefaultProfilingInfo.get(TriState.UNKNOWN);
}
}
示例11: testBranchTakenProbability
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
@Test
public void testBranchTakenProbability() {
ProfilingInfo info = profile("branchProbabilitySnippet", 0);
Assert.assertEquals(0.0, info.getBranchTakenProbability(1), DELTA);
Assert.assertEquals(N, info.getExecutionCount(1));
Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA);
Assert.assertEquals(0, info.getExecutionCount(8));
info = profile("branchProbabilitySnippet", 1);
Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA);
Assert.assertEquals(N, info.getExecutionCount(1));
Assert.assertEquals(0.0, info.getBranchTakenProbability(8), DELTA);
Assert.assertEquals(N, info.getExecutionCount(8));
info = profile("branchProbabilitySnippet", 2);
Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA);
Assert.assertEquals(N, info.getExecutionCount(1));
Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA);
Assert.assertEquals(N, info.getExecutionCount(8));
continueProfiling(3 * N, "branchProbabilitySnippet", 0);
Assert.assertEquals(0.25, info.getBranchTakenProbability(1), DELTA);
Assert.assertEquals(4 * N, info.getExecutionCount(1));
Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA);
Assert.assertEquals(N, info.getExecutionCount(8));
resetProfile("branchProbabilitySnippet");
Assert.assertEquals(-1.0, info.getBranchTakenProbability(1), DELTA);
Assert.assertEquals(0, info.getExecutionCount(1));
Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA);
Assert.assertEquals(0, info.getExecutionCount(8));
}
示例12: testSwitchProbabilities
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
@Test
public void testSwitchProbabilities() {
ProfilingInfo info = profile("switchProbabilitySnippet", 0);
Assert.assertArrayEquals(new double[]{1.0, 0.0, 0.0}, info.getSwitchProbabilities(1), DELTA);
info = profile("switchProbabilitySnippet", 1);
Assert.assertArrayEquals(new double[]{0.0, 1.0, 0.0}, info.getSwitchProbabilities(1), DELTA);
info = profile("switchProbabilitySnippet", 2);
Assert.assertArrayEquals(new double[]{0.0, 0.0, 1.0}, info.getSwitchProbabilities(1), DELTA);
resetProfile("switchProbabilitySnippet");
Assert.assertNull(info.getSwitchProbabilities(1));
}
示例13: compileHelper
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
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;
}
示例14: OptimisticOptimizations
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
public OptimisticOptimizations(ProfilingInfo info, OptionValues options) {
this.enabledOpts = EnumSet.noneOf(Optimization.class);
enabledOpts.add(Optimization.UseExceptionProbabilityForOperations);
addOptimization(options, info, DeoptimizationReason.UnreachedCode, Optimization.RemoveNeverExecutedCode);
addOptimization(options, info, DeoptimizationReason.TypeCheckedInliningViolated, Optimization.UseTypeCheckedInlining);
addOptimization(options, info, DeoptimizationReason.OptimizedTypeCheckViolated, Optimization.UseTypeCheckHints);
addOptimization(options, info, DeoptimizationReason.NotCompiledExceptionHandler, Optimization.UseExceptionProbability);
addOptimization(options, info, DeoptimizationReason.LoopLimitCheck, Optimization.UseLoopLimitChecks);
}
示例15: runSanityTest
import jdk.vm.ci.meta.ProfilingInfo; //導入依賴的package包/類
private static void runSanityTest(Method aMethod) {
System.out.println(aMethod);
HotSpotResolvedJavaMethod method = CTVMUtilities
.getResolvedMethod(aMethod);
ProfilingInfo startProfile = method.getProfilingInfo();
Asserts.assertFalse(startProfile.isMature(), aMethod
+ " : profiling info is mature in the beginning");
// make interpreter to profile this method
try {
Object obj = aMethod.getDeclaringClass().newInstance();
for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
aMethod.invoke(obj);
}
} catch (ReflectiveOperationException e) {
throw new Error("TEST BUG : " + e.getMessage(), e);
}
ProfilingInfo compProfile = method.getProfilingInfo();
Asserts.assertNE(startProfile.toString(), compProfile.toString(),
String.format("%s : profiling info wasn't changed after "
+ "%d invocations",
aMethod, CompilerWhiteBoxTest.THRESHOLD));
Asserts.assertTrue(compProfile.isMature(),
String.format("%s is not mature after %d invocations",
aMethod, CompilerWhiteBoxTest.THRESHOLD));
CompilerToVMHelper.reprofile(method);
ProfilingInfo reprofiledProfile = method.getProfilingInfo();
Asserts.assertNE(startProfile.toString(), reprofiledProfile.toString(),
aMethod + " : profiling info wasn't changed after reprofiling");
Asserts.assertNE(compProfile.toString(), reprofiledProfile.toString(),
aMethod + " : profiling info didn't change after reprofile");
Asserts.assertFalse(reprofiledProfile.isMature(), aMethod
+ " : profiling info is mature after reprofiling");
}