本文整理汇总了Java中jdk.vm.ci.meta.JavaTypeProfile类的典型用法代码示例。如果您正苦于以下问题:Java JavaTypeProfile类的具体用法?Java JavaTypeProfile怎么用?Java JavaTypeProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaTypeProfile类属于jdk.vm.ci.meta包,在下文中一共展示了JavaTypeProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTypeProfile
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的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);
}
示例2: createNonInlinedInvoke
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected Invoke createNonInlinedInvoke(boolean withExceptionEdge, int invokeBci, ValueNode[] invokeArgs, ResolvedJavaMethod targetMethod,
InvokeKind invokeKind, JavaKind resultType, JavaType returnType, JavaTypeProfile profile) {
StampPair returnStamp = graphBuilderConfig.getPlugins().getOverridingStamp(this, returnType, false);
if (returnStamp == null) {
returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
}
MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, invokeArgs, returnStamp, profile));
Invoke invoke = createNonInlinedInvoke(withExceptionEdge, invokeBci, callTarget, resultType);
for (InlineInvokePlugin plugin : graphBuilderConfig.getPlugins().getInlineInvokePlugins()) {
plugin.notifyNotInlined(this, targetMethod, invoke);
}
return invoke;
}
示例3: adjustProfileForInvocationPlugin
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
/**
* Adjusts the profile for an indirect invocation of a virtual method for which there is an
* intrinsic. The adjustment made by this method is to remove all types from the profile that do
* not override {@code targetMethod}.
*
* @param profile the profile to adjust
* @param targetMethod the virtual method for which there is an intrinsic
* @return the adjusted profile or the original {@code profile} object if no adjustment was made
*/
protected JavaTypeProfile adjustProfileForInvocationPlugin(JavaTypeProfile profile, ResolvedJavaMethod targetMethod) {
if (profile.getTypes().length > 0) {
List<ProfiledType> retained = new ArrayList<>();
double notRecordedProbability = profile.getNotRecordedProbability();
for (ProfiledType ptype : profile.getTypes()) {
if (!ptype.getType().resolveMethod(targetMethod, method.getDeclaringClass()).equals(targetMethod)) {
retained.add(ptype);
} else {
notRecordedProbability += ptype.getProbability();
}
}
if (!retained.isEmpty()) {
if (retained.size() != profile.getTypes().length) {
return new JavaTypeProfile(profile.getNullSeen(), notRecordedProbability, retained.toArray(new ProfiledType[retained.size()]));
}
} else {
return new JavaTypeProfile(profile.getNullSeen(), notRecordedProbability, new ProfiledType[0]);
}
}
return profile;
}
示例4: createTypeProfile
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
private JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile<ResolvedJavaType> profile) {
if (profile.entries <= 0 || profile.totalCount <= 0) {
return null;
}
ProfiledType[] ptypes = new ProfiledType[profile.entries];
double totalProbability = 0.0;
for (int i = 0; i < profile.entries; i++) {
double p = profile.counts[i];
p = p / profile.totalCount;
totalProbability += p;
ptypes[i] = new ProfiledType(profile.items[i], p);
}
Arrays.sort(ptypes);
double notRecordedTypeProbability = profile.entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth;
return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes);
}
示例5: createTypeProfile
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
private static JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile<ResolvedJavaType> profile) {
if (profile.entries <= 0 || profile.totalCount <= 0) {
return null;
}
ProfiledType[] ptypes = new ProfiledType[profile.entries];
double totalProbability = 0.0;
for (int i = 0; i < profile.entries; i++) {
double p = profile.counts[i];
p = p / profile.totalCount;
totalProbability += p;
ptypes[i] = new ProfiledType(profile.items[i], p);
}
Arrays.sort(ptypes);
double notRecordedTypeProbability = profile.entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth;
return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes);
}
示例6: createNonInlinedInvoke
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected Invoke createNonInlinedInvoke(ValueNode[] args, ResolvedJavaMethod targetMethod, InvokeKind invokeKind,
JavaKind resultType, JavaType returnType, InlineInfo inlineInfo, JavaTypeProfile profile) {
StampPair returnStamp = graphBuilderConfig.getPlugins().getOverridingStamp(this, returnType, false);
if (returnStamp == null) {
returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
}
MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnStamp, profile));
Invoke invoke = createNonInlinedInvoke(callTarget, resultType, inlineInfo);
for (InlineInvokePlugin plugin : graphBuilderConfig.getPlugins().getInlineInvokePlugins()) {
plugin.notifyNotInlined(this, targetMethod, invoke);
}
return invoke;
}
示例7: replaceProfile
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
@Override
protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) {
InstanceOfNode ion = graph.getNodes().filter(InstanceOfNode.class).first();
if (ion != null) {
ion.setProfile(profile, graph.start());
}
}
示例8: profile
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected JavaTypeProfile profile(TriState nullSeen, Class<?>... types) {
if (types.length == 0) {
return null;
}
ProfiledType[] ptypes = new ProfiledType[types.length];
for (int i = 0; i < types.length; i++) {
ptypes[i] = new ProfiledType(getMetaAccess().lookupJavaType(types[i]), 1.0D / types.length);
}
return new JavaTypeProfile(nullSeen, 0.0D, ptypes);
}
示例9: test
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected void test(String name, JavaTypeProfile profile, Object... args) {
assert currentProfile == null;
currentProfile = profile;
try {
super.test(name, args);
} finally {
currentProfile = null;
}
}
示例10: handleCheckCast
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
@Override
public boolean handleCheckCast(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) {
if (!wordTypes.isWord(type)) {
if (object.getStackKind() != JavaKind.Object) {
throw bailout(b, "Cannot cast a word value to a non-word type: " + type.toJavaName(true));
}
return false;
}
if (object.getStackKind() != wordTypes.getWordKind()) {
throw bailout(b, "Cannot cast a non-word value to a word type: " + type.toJavaName(true));
}
b.push(JavaKind.Object, object);
return true;
}
示例11: handleInstanceOf
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
@Override
public boolean handleInstanceOf(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) {
if (wordTypes.isWord(type)) {
throw bailout(b, "Cannot use instanceof for word a type: " + type.toJavaName(true));
} else if (object.getStackKind() != JavaKind.Object) {
throw bailout(b, "Cannot use instanceof on a word value: " + type.toJavaName(true));
}
return false;
}
示例12: InstanceOfNode
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected InstanceOfNode(NodeClass<? extends InstanceOfNode> c, ObjectStamp checkedStamp, ValueNode object, JavaTypeProfile profile, AnchoringNode anchor) {
super(c, object);
this.checkedStamp = checkedStamp;
this.profile = profile;
this.anchor = anchor;
assert (profile == null) || (anchor != null) : "profiles must be anchored";
assert checkedStamp != null;
}
示例13: createHelper
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
public static LogicNode createHelper(ObjectStamp checkedStamp, ValueNode object, JavaTypeProfile profile, AnchoringNode anchor) {
LogicNode synonym = findSynonym(checkedStamp, object);
if (synonym != null) {
return synonym;
} else {
return new InstanceOfNode(checkedStamp, object, profile, anchor);
}
}
示例14: makeHints
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
private static Hint[] makeHints(TypeReference targetType, JavaTypeProfile profile, double minHintHitProbability, int maxHints, Double[] hitProbability) {
double hitProb = 0.0d;
Hint[] hintsBuf = NO_HINTS;
if (profile != null) {
double notRecordedTypes = profile.getNotRecordedProbability();
ProfiledType[] ptypes = profile.getTypes();
if (notRecordedTypes < (1D - minHintHitProbability) && ptypes != null && ptypes.length > 0) {
hintsBuf = new Hint[ptypes.length];
int hintCount = 0;
for (ProfiledType ptype : ptypes) {
if (targetType != null) {
ResolvedJavaType hintType = ptype.getType();
hintsBuf[hintCount++] = new Hint(hintType, targetType.getType().isAssignableFrom(hintType));
hitProb += ptype.getProbability();
}
if (hintCount == maxHints) {
break;
}
}
if (hitProb >= minHintHitProbability) {
if (hintsBuf.length != hintCount || hintCount > maxHints) {
hintsBuf = Arrays.copyOf(hintsBuf, Math.min(maxHints, hintCount));
}
} else {
hintsBuf = NO_HINTS;
hitProb = 0.0d;
}
}
}
hitProbability[0] = hitProb;
return hintsBuf;
}
示例15: createAnchor
import jdk.vm.ci.meta.JavaTypeProfile; //导入依赖的package包/类
protected AnchoringNode createAnchor(JavaTypeProfile profile) {
if (profile == null || profile.getNotRecordedProbability() > 0.0) {
return null;
} else {
return append(new ValueAnchorNode(null));
}
}