# HG changeset patch # User Thomas Wuerthinger # Date 1376735128 -7200 # Node ID 4b3a6662deb1e1934c500cb5f703871f8c72b361 # Parent ca5054bbfcdd9d53ab24fecd1c79dbe781f7888a Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor. diff -r ca5054bbfcdd -r 4b3a6662deb1 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java Sat Aug 17 03:55:16 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java Sat Aug 17 12:25:28 2013 +0200 @@ -49,8 +49,8 @@ public class CheckCastDynamicSnippets implements Snippets { @Snippet - public static Object checkcastDynamic(Word hub, Object object, @ConstantParameter boolean checkNull) { - if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { + public static Object checkcastDynamic(Word hub, Object object) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); } else { BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); @@ -78,7 +78,6 @@ Arguments args = new Arguments(dynamic); args.add("hub", checkcast.hub()); args.add("object", object); - args.addConst("checkNull", !ObjectStamp.isObjectNonNull(object.stamp())); SnippetTemplate template = template(args); Debug.log("Lowering dynamic checkcast in %s: node=%s, template=%s, arguments=%s", graph, checkcast, template, args); diff -r ca5054bbfcdd -r 4b3a6662deb1 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Sat Aug 17 03:55:16 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Sat Aug 17 12:25:28 2013 +0200 @@ -79,8 +79,8 @@ */ @Snippet public static Object instanceofWithProfile(Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, - @ConstantParameter boolean checkNull, @ConstantParameter boolean nullSeen) { - if (probability(NOT_FREQUENT_PROBABILITY, checkNull && object == null)) { + @ConstantParameter boolean nullSeen) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); if (!nullSeen) { // See comment below for other deoptimization path; the @@ -113,8 +113,8 @@ * A test against a final type. */ @Snippet - public static Object instanceofExact(Object object, Word exactHub, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { - if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { + public static Object instanceofExact(Object object, Word exactHub, Object trueValue, Object falseValue) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); return falseValue; } @@ -132,8 +132,8 @@ * A test against a primary type. */ @Snippet - public static Object instanceofPrimary(Word hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { - if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { + public static Object instanceofPrimary(Word hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); return falseValue; } @@ -151,9 +151,8 @@ * A test against a restricted secondary type type. */ @Snippet - public static Object instanceofSecondary(Word hub, Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, - @ConstantParameter boolean checkNull) { - if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { + public static Object instanceofSecondary(Word hub, Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); return falseValue; } @@ -179,14 +178,13 @@ * Type test used when the type being tested against is not known at compile time. */ @Snippet - public static Object instanceofDynamic(Class mirror, Object object, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { - if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { + public static Object instanceofDynamic(Class mirror, Object object, Object trueValue, Object falseValue) { + if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { isNull.inc(); return falseValue; } - + BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); Word hub = loadWordFromObject(mirror, klassOffset()); - BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode); if (!checkUnknownSubType(hub, objectHub)) { return falseValue; @@ -242,7 +240,6 @@ } args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); - args.addConst("checkNull", !ObjectStamp.isObjectNonNull(object.stamp())); if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) { args.addConst("nullSeen", hintInfo.profile.getNullSeen() != TriState.FALSE); } @@ -258,7 +255,6 @@ args.add("object", object); args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); - args.addConst("checkNull", !ObjectStamp.isObjectNonNull(object.stamp())); return args; } }