本文整理汇总了Java中jdk.vm.ci.meta.DeoptimizationReason类的典型用法代码示例。如果您正苦于以下问题:Java DeoptimizationReason类的具体用法?Java DeoptimizationReason怎么用?Java DeoptimizationReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeoptimizationReason类属于jdk.vm.ci.meta包,在下文中一共展示了DeoptimizationReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test3
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@Test
public void test3() {
Assume.assumeTrue("Only works on jdk8 right now", Java8OrEarlier);
ResolvedJavaMethod method = getResolvedJavaMethod("test3Snippet");
for (int i = 0; i < 2; i++) {
Result actual;
boolean expectedCompiledCode = (method.getProfilingInfo().getDeoptimizationCount(DeoptimizationReason.NotCompiledExceptionHandler) != 0);
InstalledCode code = getCode(method, null, false, true, new OptionValues(getInitialOptions(), HighTier.Options.Inline, false));
assertTrue(code.isValid());
try {
actual = new Result(code.executeVarargs(false), null);
} catch (Exception e) {
actual = new Result(null, e);
}
assertTrue(i > 0 == expectedCompiledCode, "expect compiled code to stay around after the first iteration");
assertEquals(new Result(expectedCompiledCode, null), actual);
assertTrue(expectedCompiledCode == code.isValid());
}
}
示例2: runTest
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
protected void runTest(OptionValues options, Set<DeoptimizationReason> shouldNotDeopt, boolean bind, boolean noProfile, String name, Object... args) {
ResolvedJavaMethod method = getResolvedJavaMethod(name);
Object receiver = method.isStatic() ? null : this;
Result expect = executeExpected(method, receiver, args);
if (noProfile) {
method.reprofile();
}
testAgainstExpected(options, method, expect, shouldNotDeopt, receiver, args);
if (args.length > 0 && bind) {
if (noProfile) {
method.reprofile();
}
this.argsToBind = args;
testAgainstExpected(options, method, expect, shouldNotDeopt, receiver, args);
this.argsToBind = null;
}
}
示例3: tryUseTrappingNullCheck
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
private static void tryUseTrappingNullCheck(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason, JavaConstant speculation, long implicitNullCheckLimit) {
if (deoptimizationReason != DeoptimizationReason.NullCheckException && deoptimizationReason != DeoptimizationReason.UnreachedCode) {
return;
}
if (speculation != null && !speculation.equals(JavaConstant.NULL_POINTER)) {
return;
}
if (predecessor instanceof AbstractMergeNode) {
AbstractMergeNode merge = (AbstractMergeNode) predecessor;
if (merge.phis().isEmpty()) {
for (AbstractEndNode end : merge.cfgPredecessors().snapshot()) {
checkPredecessor(deopt, end.predecessor(), deoptimizationReason, implicitNullCheckLimit);
}
}
} else if (predecessor instanceof AbstractBeginNode) {
checkPredecessor(deopt, predecessor, deoptimizationReason, implicitNullCheckLimit);
}
}
示例4: checkPredecessor
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
private static void checkPredecessor(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason, long implicitNullCheckLimit) {
Node current = predecessor;
AbstractBeginNode branch = null;
while (current instanceof AbstractBeginNode) {
branch = (AbstractBeginNode) current;
if (branch.anchored().isNotEmpty()) {
// some input of the deopt framestate is anchored to this branch
return;
}
current = current.predecessor();
}
if (current instanceof IfNode) {
IfNode ifNode = (IfNode) current;
if (branch != ifNode.trueSuccessor()) {
return;
}
LogicNode condition = ifNode.condition();
if (condition instanceof IsNullNode) {
replaceWithTrappingNullCheck(deopt, ifNode, condition, deoptimizationReason, implicitNullCheckLimit);
}
}
}
示例5: createGuard
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@Override
public GuardingNode createGuard(FixedNode before, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, JavaConstant speculation, boolean negated) {
StructuredGraph graph = before.graph();
if (OptEliminateGuards.getValue(graph.getOptions())) {
for (Node usage : condition.usages()) {
if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage) && ((GuardNode) usage).isNegated() == negated) {
return (GuardNode) usage;
}
}
}
if (!condition.graph().getGuardsStage().allowsFloatingGuards()) {
FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, deoptReason, action, speculation, negated));
graph.addBeforeFixed(before, fixedGuard);
DummyGuardHandle handle = graph.add(new DummyGuardHandle(fixedGuard));
fixedGuard.lower(this);
GuardingNode result = handle.getGuard();
handle.safeDelete();
return result;
} else {
GuardNode newGuard = graph.unique(new GuardNode(condition, guardAnchor, deoptReason, action, negated, speculation));
if (OptEliminateGuards.getValue(graph.getOptions())) {
activeGuards.markAndGrow(newGuard);
}
return newGuard;
}
}
示例6: canonical
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
private static ValueNode canonical(LoadFieldNode loadFieldNode, StampPair stamp, ValueNode forObject, ResolvedJavaField field,
ConstantFieldProvider constantFields, ConstantReflectionProvider constantReflection,
OptionValues options, MetaAccessProvider metaAccess, boolean canonicalizeReads, boolean allUsagesAvailable) {
LoadFieldNode self = loadFieldNode;
if (canonicalizeReads && metaAccess != null) {
ConstantNode constant = asConstant(constantFields, constantReflection, metaAccess, options, forObject, field);
if (constant != null) {
return constant;
}
if (allUsagesAvailable) {
PhiNode phi = asPhi(constantFields, constantReflection, metaAccess, options, forObject,
field, stamp.getTrustedStamp());
if (phi != null) {
return phi;
}
}
}
if (self != null && !field.isStatic() && forObject.isNullConstant()) {
return new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException);
}
if (self == null) {
self = new LoadFieldNode(stamp, forObject, field);
}
return self;
}
示例7: simplify
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@Override
public void simplify(SimplifierTool tool) {
if (hasNoUsages()) {
Stamp lengthStamp = length().stamp();
if (lengthStamp instanceof IntegerStamp) {
IntegerStamp lengthIntegerStamp = (IntegerStamp) lengthStamp;
if (lengthIntegerStamp.isPositive()) {
GraphUtil.removeFixedWithUnusedInputs(this);
return;
}
}
// Should be areFrameStatesAtSideEffects but currently SVM will complain about
// RuntimeConstraint
if (graph().getGuardsStage().allowsFloatingGuards()) {
LogicNode lengthNegativeCondition = CompareNode.createCompareNode(graph(), Condition.LT, length(), ConstantNode.forInt(0, graph()), tool.getConstantReflection());
// we do not have a non-deopting path for that at the moment so action=None.
FixedGuardNode guard = graph().add(new FixedGuardNode(lengthNegativeCondition, DeoptimizationReason.RuntimeConstraint, DeoptimizationAction.None, true));
graph().replaceFixedWithFixed(this, guard);
}
}
}
示例8: lower
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@Override
public void lower(LoweringTool tool) {
if (graph().getGuardsStage().allowsFloatingGuards()) {
/*
* Don't allow guards with action None and reason RuntimeConstraint to float. In cases
* where 2 guards are testing equivalent conditions they might be lowered at the same
* location. If the guard with the None action is lowered before the other guard then
* the code will be stuck repeatedly deoptimizing without invalidating the code.
* Conditional elimination will eliminate the guard if it's truly redundant in this
* case.
*/
if (getAction() != DeoptimizationAction.None || getReason() != DeoptimizationReason.RuntimeConstraint) {
ValueNode guard = tool.createGuard(this, getCondition(), getReason(), getAction(), getSpeculation(), isNegated()).asNode();
this.replaceAtUsages(guard);
graph().removeFixed(this);
}
} else {
lowerToIf().lower(tool);
}
}
示例9: checkLimits
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
private static void checkLimits(Object src, int srcPos, Object dest, int destPos, int length, Counters counters) {
if (probability(SLOW_PATH_PROBABILITY, srcPos < 0)) {
counters.checkAIOOBECounter.inc();
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
if (probability(SLOW_PATH_PROBABILITY, destPos < 0)) {
counters.checkAIOOBECounter.inc();
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
if (probability(SLOW_PATH_PROBABILITY, length < 0)) {
counters.checkAIOOBECounter.inc();
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
if (probability(SLOW_PATH_PROBABILITY, srcPos > ArrayLengthNode.arrayLength(src) - length)) {
counters.checkAIOOBECounter.inc();
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
if (probability(SLOW_PATH_PROBABILITY, destPos > ArrayLengthNode.arrayLength(dest) - length)) {
counters.checkAIOOBECounter.inc();
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
counters.checkSuccessCounter.inc();
}
示例10: arraycopyPredictedExactIntrinsic
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
/**
* This intrinsic is useful for the case where we know something statically about one of the
* inputs but not the other.
*/
@Snippet
public static void arraycopyPredictedExactIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter JavaKind elementKind,
@ConstantParameter SnippetCounter counter, @ConstantParameter SnippetCounter copiedCounter, @ConstantParameter Counters counters) {
Object nonNullSrc = GraalDirectives.guardingNonNull(src);
Object nonNullDest = GraalDirectives.guardingNonNull(dest);
KlassPointer srcHub = loadHub(nonNullSrc);
KlassPointer destHub = loadHub(nonNullDest);
if (probability(SLOW_PATH_PROBABILITY, srcHub != destHub)) {
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
checkLimits(nonNullSrc, srcPos, nonNullDest, destPos, length, counters);
counter.inc();
copiedCounter.add(length);
ArrayCopyCallNode.arraycopy(nonNullSrc, srcPos, nonNullDest, destPos, length, elementKind);
if (length == 0) {
counters.zeroLengthDynamicCounter.inc();
} else {
counters.nonZeroLengthDynamicCounter.inc();
counters.nonZeroLengthDynamicCopiedCounter.add(length);
}
}
示例11: insertDeoptimization
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
protected void insertDeoptimization(VirtualizerTool tool) {
/*
* Escape analysis does not allow insertion of a DeoptimizeNode. We work around this
* restriction by inserting an always-failing guard, which will be canonicalized to a
* DeoptimizeNode later on.
*/
LogicNode condition = LogicConstantNode.contradiction();
tool.addNode(condition);
JavaConstant speculation = graph().getSpeculationLog().speculate(frame.getIntrinsifyAccessorsSpeculation());
tool.addNode(new FixedGuardNode(condition, DeoptimizationReason.RuntimeConstraint, DeoptimizationAction.InvalidateReprofile, speculation, false));
if (getStackKind() == JavaKind.Void) {
tool.delete();
} else {
/*
* Even though all usages will be eventually dead, we need to provide a valid
* replacement value for now.
*/
ConstantNode unusedValue = ConstantNode.forConstant(JavaConstant.defaultForKind(getStackKind()), tool.getMetaAccessProvider());
tool.addNode(unusedValue);
tool.replaceWith(unusedValue);
}
}
示例12: lower
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
static void lower(LoweringTool tool, IntegerExactArithmeticNode node) {
if (node.asNode().graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
FloatingNode floatingNode = (FloatingNode) node;
FixedWithNextNode previous = tool.lastFixedNode();
FixedNode next = previous.next();
previous.setNext(null);
DeoptimizeNode deopt = floatingNode.graph().add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.ArithmeticException));
AbstractBeginNode normalBegin = floatingNode.graph().add(new BeginNode());
normalBegin.setNext(next);
IntegerExactArithmeticSplitNode split = node.createSplit(normalBegin, BeginNode.begin(deopt));
previous.setNext(split);
floatingNode.replaceAndDelete(split);
}
}
示例13: registerMethodHandleImplPlugins
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
private static void registerMethodHandleImplPlugins(InvocationPlugins plugins, SnippetReflectionProvider snippetReflection, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, "java.lang.invoke.MethodHandleImpl", bytecodeProvider);
r.register2("profileBoolean", boolean.class, int[].class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode result, ValueNode counters) {
if (result.isConstant()) {
b.push(JavaKind.Boolean, result);
return true;
}
if (counters.isConstant()) {
ValueNode newResult = result;
int[] ctrs = snippetReflection.asObject(int[].class, (JavaConstant) counters.asConstant());
if (ctrs != null && ctrs.length == 2) {
int falseCount = ctrs[0];
int trueCount = ctrs[1];
int totalCount = trueCount + falseCount;
if (totalCount == 0) {
b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter));
} else if (falseCount == 0 || trueCount == 0) {
boolean expected = falseCount == 0;
LogicNode condition = b.addWithInputs(
IntegerEqualsNode.create(b.getConstantReflection(), b.getMetaAccess(), b.getOptions(), null, result, b.add(ConstantNode.forBoolean(!expected))));
b.append(new FixedGuardNode(condition, DeoptimizationReason.UnreachedCode, DeoptimizationAction.InvalidateReprofile, true));
newResult = b.add(ConstantNode.forBoolean(expected));
} else {
// We cannot use BranchProbabilityNode here since there's no guarantee
// the result of MethodHandleImpl.profileBoolean() is used as the
// test in an `if` statement (as required by BranchProbabilityNode).
}
}
b.addPush(JavaKind.Boolean, newResult);
return true;
}
return false;
}
});
}
示例14: getLength
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@MethodSubstitution
public static int getLength(Object array) {
if (!array.getClass().isArray()) {
DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
}
return ArrayLengthNode.arrayLength(array);
}
示例15: emitDeoptimizeCaller
import jdk.vm.ci.meta.DeoptimizationReason; //导入依赖的package包/类
@Override
public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
Value actionAndReason = emitJavaConstant(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0));
Value nullValue = emitConstant(LIRKind.reference(AMD64Kind.QWORD), JavaConstant.NULL_POINTER);
moveDeoptValuesToThread(actionAndReason, nullValue);
append(new AMD64HotSpotDeoptimizeCallerOp());
}