use of org.graalvm.compiler.nodes.extended.GuardingNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerLoadIndexedNode.
protected void lowerLoadIndexedNode(LoadIndexedNode loadIndexed, LoweringTool tool) {
StructuredGraph graph = loadIndexed.graph();
ValueNode array = loadIndexed.array();
array = createNullCheckedValue(array, loadIndexed, tool);
JavaKind elementKind = loadIndexed.elementKind();
Stamp loadStamp = loadStamp(loadIndexed.stamp(NodeView.DEFAULT), elementKind);
GuardingNode boundsCheck = getBoundsCheck(loadIndexed, array, tool);
AddressNode address = createArrayIndexAddress(graph, array, elementKind, loadIndexed.index(), boundsCheck);
ReadNode memoryRead = graph.add(new ReadNode(address, NamedLocationIdentity.getArrayLocation(elementKind), loadStamp, BarrierType.NONE));
memoryRead.setGuard(boundsCheck);
ValueNode readValue = implicitLoadConvert(graph, elementKind, memoryRead);
loadIndexed.replaceAtUsages(readValue);
graph.replaceFixed(loadIndexed, memoryRead);
}
use of org.graalvm.compiler.nodes.extended.GuardingNode in project graal by oracle.
the class InstanceOfSnippets method instanceofExact.
/**
* A test against a final type.
*/
@Snippet
public static Object instanceofExact(Object object, KlassPointer exactHub, Object trueValue, Object falseValue, @ConstantParameter Counters counters) {
if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
counters.isNull.inc();
return falseValue;
}
GuardingNode anchorNode = SnippetAnchorNode.anchor();
KlassPointer objectHub = loadHubIntrinsic(PiNode.piCastNonNull(object, anchorNode));
if (probability(LIKELY_PROBABILITY, objectHub.notEqual(exactHub))) {
counters.exactMiss.inc();
return falseValue;
}
counters.exactHit.inc();
return trueValue;
}
use of org.graalvm.compiler.nodes.extended.GuardingNode in project graal by oracle.
the class InstanceOfSnippets method instanceofWithProfile.
/**
* A test against a set of hints derived from a profile with 100% precise coverage of seen
* types. This snippet deoptimizes on hint miss paths.
*/
@Snippet
public static Object instanceofWithProfile(Object object, @VarargsParameter KlassPointer[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, @ConstantParameter boolean nullSeen, @ConstantParameter Counters counters) {
if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
counters.isNull.inc();
if (!nullSeen) {
// See comment below for other deoptimization path; the
// same reasoning applies here.
DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated);
}
return falseValue;
}
GuardingNode anchorNode = SnippetAnchorNode.anchor();
KlassPointer objectHub = loadHubIntrinsic(PiNode.piCastNonNull(object, anchorNode));
// if we get an exact match: succeed immediately
ExplodeLoopNode.explodeLoop();
for (int i = 0; i < hints.length; i++) {
KlassPointer hintHub = hints[i];
boolean positive = hintIsPositive[i];
if (probability(LIKELY_PROBABILITY, hintHub.equal(objectHub))) {
counters.hintsHit.inc();
return positive ? trueValue : falseValue;
}
counters.hintsMiss.inc();
}
// This maybe just be a rare event but it might also indicate a phase change
// in the application. Ideally we want to use DeoptimizationAction.None for
// the former but the cost is too high if indeed it is the latter. As such,
// we defensively opt for InvalidateReprofile.
DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, OptimizedTypeCheckViolated);
return falseValue;
}
use of org.graalvm.compiler.nodes.extended.GuardingNode in project graal by oracle.
the class InstanceOfSnippets method instanceofDynamic.
/**
* Type test used when the type being tested against is not known at compile time.
*/
@Snippet
public static Object instanceofDynamic(KlassPointer hub, Object object, Object trueValue, Object falseValue, @ConstantParameter boolean allowNull, @ConstantParameter Counters counters) {
if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
counters.isNull.inc();
if (allowNull) {
return trueValue;
} else {
return falseValue;
}
}
GuardingNode anchorNode = SnippetAnchorNode.anchor();
KlassPointer nonNullObjectHub = loadHubIntrinsic(PiNode.piCastNonNull(object, anchorNode));
// The hub of a primitive type can be null => always return false in this case.
if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, !hub.isNull())) {
if (checkUnknownSubType(hub, nonNullObjectHub, counters)) {
return trueValue;
}
}
return falseValue;
}
use of org.graalvm.compiler.nodes.extended.GuardingNode in project graal by oracle.
the class InstanceOfSnippets method instanceofPrimary.
/**
* A test against a primary type.
*/
@Snippet
public static Object instanceofPrimary(KlassPointer hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue, @ConstantParameter Counters counters) {
if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
counters.isNull.inc();
return falseValue;
}
GuardingNode anchorNode = SnippetAnchorNode.anchor();
KlassPointer objectHub = loadHubIntrinsic(PiNode.piCastNonNull(object, anchorNode));
if (probability(NOT_LIKELY_PROBABILITY, objectHub.readKlassPointer(superCheckOffset, PRIMARY_SUPERS_LOCATION).notEqual(hub))) {
counters.displayMiss.inc();
return falseValue;
}
counters.displayHit.inc();
return trueValue;
}
Aggregations