@Override public void lower(FloatingNode node, LoweringTool tool) { InstanceOfNode instanceOfNode = (InstanceOfNode) node; if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) { if (instanceOfNode.allowsNull()) { StructuredGraph graph = instanceOfNode.graph(); ValueNode object = instanceOfNode.getValue(); LogicNode newTypeCheck = graph.addOrUniqueWithInputs(InstanceOfNode.create(instanceOfNode.type(), object, instanceOfNode.profile(), instanceOfNode.getAnchor())); LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, GraalDirectives.UNLIKELY_PROBABILITY); instanceOfNode.replaceAndDelete(newNode); } return; } VMError.guarantee(!instanceOfNode.allowsNull(), "must be lowered before"); super.lower(node, tool); }
protected LogicNode createInstanceOfAllowNull(TypeReference type, ValueNode object, JavaTypeProfile profile) { return InstanceOfNode.createAllowNull(type, object, profile, createAnchor(profile)); }
public static LogicNode createAllowNull(TypeReference type, ValueNode object, JavaTypeProfile profile, AnchoringNode anchor) { if (StampTool.isPointerNonNull(object)) { return create(type, object, profile, anchor); } return createHelper(StampFactory.object(type), object, profile, anchor); }
@Override public TriState implies(boolean thisNegated, LogicNode other) { if (other instanceof InstanceOfNode) { InstanceOfNode instanceOfNode = (InstanceOfNode) other; if (instanceOfNode.getValue() == getValue()) { if (thisNegated) { // !X => Y if (this.getCheckedStamp().meet(instanceOfNode.getCheckedStamp()).equals(this.getCheckedStamp())) { return TriState.get(false); } } else { // X => Y if (instanceOfNode.getCheckedStamp().meet(this.getCheckedStamp()).equals(instanceOfNode.getCheckedStamp())) { return TriState.get(true); } } } } return super.implies(thisNegated, other); } }
ObjectStamp newStamp = (ObjectStamp) strengthen(node.getCheckedStamp()); if (newStamp != null) { node.replaceAndDelete(graph.addOrUniqueWithInputs(InstanceOfNode.createHelper(newStamp, node.getValue(), node.profile(), node.getAnchor())));
@Override protected Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool tool) { InstanceOfNode node = (InstanceOfNode) replacer.instanceOf; TypeReference typeReference = node.type(); SharedType type = (SharedType) typeReference.getType(); int fromTypeID = type.getInstanceOfFromTypeID(); int numTypeIDs = type.getInstanceOfNumTypeIDs(); VMError.guarantee(!node.allowsNull(), "must be lowered before"); Arguments args = new Arguments(typeEqualityTest, node.graph().getGuardsStage(), tool.getLoweringStage()); args.add("object", node.getValue()); args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); Arguments args = new Arguments(instanceOfDynamic, node.graph().getGuardsStage(), tool.getLoweringStage()); args.add("type", type.getHub()); args.add("object", node.getValue()); args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); Arguments args = new Arguments(instanceOf, node.graph().getGuardsStage(), tool.getLoweringStage()); args.add("object", node.getValue()); args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); Arguments args = new Arguments(instanceOfBitTest, node.graph().getGuardsStage(), tool.getLoweringStage()); args.add("object", node.getValue()); args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue);
if (replacer.instanceOf instanceof InstanceOfNode) { InstanceOfNode instanceOf = (InstanceOfNode) replacer.instanceOf; ValueNode object = instanceOf.getValue(); Assumptions assumptions = instanceOf.graph().getAssumptions(); OptionValues localOptions = instanceOf.getOptions(); JavaTypeProfile profile = instanceOf.profile(); if (GeneratePIC.getValue(localOptions)) { TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.type(), profile, assumptions, TypeCheckMinProfileHitProbability.getValue(localOptions), TypeCheckMaxHints.getValue(localOptions)); final HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) instanceOf.type().getType(); ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), type.klass(), providers.getMetaAccess(), instanceOf.graph()); StructuredGraph graph = instanceOf.graph(); if (hintInfo.hintHitProbability >= 1.0 && hintInfo.exact == null) { Hints hints = createHints(hintInfo, providers.getMetaAccess(), false, graph);
ValueNode object = instanceOf.getValue(); TypeReference typeReference = instanceOf.type(); AnalysisType type = (AnalysisType) instanceOf.type().getType(); FilterTypeFlow filterFlow = new FilterTypeFlow(source, type, typeReference.isExact(), isTrue, !isTrue ^ instanceOf.allowsNull()); methodFlow.addMiscEntry(filterFlow); return filterFlow;
protected LogicNode createInstanceOf(TypeReference type, ValueNode object) { return InstanceOfNode.create(type, object); }
private static LogicNode findSynonym(Assumptions assumptions, ConstantReflectionProvider constantReflection, ValueNode forMirror, ValueNode forObject, boolean allowNull, boolean exact) { if (forMirror.isConstant()) { ResolvedJavaType t = constantReflection.asJavaType(forMirror.asConstant()); if (t != null) { if (t.isPrimitive()) { if (allowNull) { return IsNullNode.create(forObject); } else { return LogicConstantNode.contradiction(); } } else { TypeReference type = exact ? TypeReference.createExactTrusted(t) : TypeReference.createTrusted(assumptions, t); if (allowNull) { return InstanceOfNode.createAllowNull(type, forObject, null, null); } else { return InstanceOfNode.create(type, forObject); } } } } return null; }
if (b instanceof IsNullNode) { IsNullNode isNullNode = (IsNullNode) b; if (isNullNode.getValue() == instanceOfA.getValue()) { debug.log("Can swap instanceof and isnull if"); return true; if (instanceOfA.getValue() == instanceOfB.getValue() && !instanceOfA.type().getType().isInterface() && !instanceOfB.type().getType().isInterface() && !instanceOfA.type().getType().isAssignableFrom(instanceOfB.type().getType()) && !instanceOfB.type().getType().isAssignableFrom(instanceOfA.type().getType())) { debug.log("Can swap instanceof for types %s and %s", instanceOfA.type(), instanceOfB.type()); return true;
TypeReference typeRef = inst.type(); value.setStamp(new ObjectStamp(typeRef.getType(), typeRef.isExact(), !inst.allowsNull(), false)); } else { assert node instanceof IsNullNode;
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; assert type() != null; }
if (n instanceof InstanceOfNode) { InstanceOfNode instanceOf = (InstanceOfNode) n; markFieldsUsedInComparison(instanceOf.getValue()); } else if (n instanceof ObjectEqualsNode) { ObjectEqualsNode compareNode = (ObjectEqualsNode) n;
public static LogicNode create(TypeReference type, ValueNode object, JavaTypeProfile profile, AnchoringNode anchor) { return createHelper(StampFactory.objectNonNull(type), object, profile, anchor); }
public static LogicNode create(TypeReference type, ValueNode object) { return create(type, object, null, null); }
private static ValueNode createCheckcast(HostedGraphKit graphKit, ValueNode value, ResolvedJavaType type, boolean nonNull) { TypeReference typeRef = TypeReference.createTrusted(graphKit.getAssumptions(), type); LogicNode condition; if (nonNull) { condition = graphKit.append(InstanceOfNode.create(typeRef, value)); } else { condition = graphKit.append(InstanceOfNode.createAllowNull(typeRef, value, null, null)); } graphKit.startIf(condition, BranchProbabilityNode.FAST_PATH_PROBABILITY); graphKit.thenPart(); PiNode ret = graphKit.createPiNode(value, StampFactory.object(typeRef, nonNull)); graphKit.elsePart(); throwFailedCast(graphKit, type, value); graphKit.endIf(); return ret; }
if (graph.getSpeculationLog().maySpeculate(reason) && osrLocal instanceof OSRLocalNode && value.getStackKind().equals(JavaKind.Object) && !narrowedStamp.isUnrestricted()) { LogicNode check = graph.addOrUniqueWithInputs(InstanceOfNode.createHelper((ObjectStamp) narrowedStamp, osrLocal, null, null)); SpeculationLog.Speculation constant = graph.getSpeculationLog().speculate(reason); FixedGuardNode guard = graph.add(new FixedGuardNode(check, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, constant, false));