# HG changeset patch # User Tom Rodriguez # Date 1436400560 25200 # Node ID 911105865ffcff422a7081adbe59a26e55df720f # Parent b18b92bcf0a28ce99f1e59d1430f350e312689fd Add extra context to ArrayCopySlowPathNode to ensure deduplication is safe diff -r b18b92bcf0a2 -r 911105865ffc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySlowPathNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySlowPathNode.java Wed Jul 08 11:34:18 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySlowPathNode.java Wed Jul 08 17:09:20 2015 -0700 @@ -40,20 +40,30 @@ private final SnippetTemplate.SnippetInfo snippet; - public ArrayCopySlowPathNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, SnippetTemplate.SnippetInfo snippet) { + /** + * Extra context for the slow path snippet. + */ + private final Object argument; + + public ArrayCopySlowPathNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, SnippetTemplate.SnippetInfo snippet, Object argument) { super(TYPE, src, srcPos, dest, destPos, length, elementKind, BytecodeFrame.INVALID_FRAMESTATE_BCI); assert StampTool.isPointerNonNull(src) && StampTool.isPointerNonNull(dest) : "must have been null checked"; this.snippet = snippet; + this.argument = argument; } @NodeIntrinsic public static native void arraycopy(Object nonNullSrc, int srcPos, Object nonNullDest, int destPos, int length, @ConstantNodeParameter Kind elementKind, - @ConstantNodeParameter SnippetTemplate.SnippetInfo snippet); + @ConstantNodeParameter SnippetTemplate.SnippetInfo snippet, @ConstantNodeParameter Object argument); public SnippetTemplate.SnippetInfo getSnippet() { return snippet; } + public Object getArgument() { + return argument; + } + @Override public LocationIdentity getLocationIdentity() { if (elementKind != null) { diff -r b18b92bcf0a2 -r 911105865ffc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java Wed Jul 08 11:34:18 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java Wed Jul 08 17:09:20 2015 -0700 @@ -166,7 +166,8 @@ * underlying type is really an array type. */ @Snippet - public static void arraycopySlowPathIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter Kind elementKind, @ConstantParameter SnippetInfo slowPath) { + public static void arraycopySlowPathIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter Kind elementKind, @ConstantParameter SnippetInfo slowPath, + @ConstantParameter Object slowPathArgument) { Object nonNullSrc = GraalDirectives.guardingNonNull(src); Object nonNullDest = GraalDirectives.guardingNonNull(dest); KlassPointer srcHub = loadHub(nonNullSrc); @@ -180,7 +181,7 @@ nonZeroLengthDynamicCounter.inc(); nonZeroLengthDynamicCopiedCounter.add(length); } - ArrayCopySlowPathNode.arraycopy(nonNullSrc, srcPos, nonNullDest, destPos, length, elementKind, slowPath); + ArrayCopySlowPathNode.arraycopy(nonNullSrc, srcPos, nonNullDest, destPos, length, elementKind, slowPath, slowPathArgument); } @Snippet @@ -414,6 +415,7 @@ Kind componentKind = selectComponentKind(arraycopy); SnippetInfo snippetInfo = null; SnippetInfo slowPathSnippetInfo = null; + Object slowPathArgument = null; if (arraycopy.getLength().isConstant() && arraycopy.getLength().asJavaConstant().asLong() == 0) { snippetInfo = arraycopyZeroLengthIntrinsicSnippet; @@ -422,6 +424,7 @@ if (shouldUnroll(arraycopy.getLength())) { snippetInfo = arraycopySlowPathIntrinsicSnippet; slowPathSnippetInfo = arraycopyUnrolledWorkSnippet; + slowPathArgument = arraycopy.getLength().asJavaConstant().asInt(); } } else { if (componentKind == Kind.Object) { @@ -432,6 +435,7 @@ if (srcComponentType != null && destComponentType != null && !srcComponentType.isPrimitive() && !destComponentType.isPrimitive()) { snippetInfo = arraycopySlowPathIntrinsicSnippet; slowPathSnippetInfo = checkcastArraycopyWorkSnippet; + slowPathArgument = LocationIdentity.any(); /* * Because this snippet has to use Sysytem.arraycopy as a slow path, we must * pretend to kill any() so clear the componentKind. @@ -451,6 +455,7 @@ if (predictedKind == Kind.Object) { snippetInfo = arraycopySlowPathIntrinsicSnippet; slowPathSnippetInfo = arraycopyPredictedObjectWorkSnippet; + slowPathArgument = predictedKind; componentKind = null; } else { snippetInfo = arraycopyPredictedExactIntrinsicSnippet; @@ -470,6 +475,8 @@ if (snippetInfo == arraycopySlowPathIntrinsicSnippet) { args.addConst("elementKind", componentKind != null ? componentKind : Kind.Illegal); args.addConst("slowPath", slowPathSnippetInfo); + assert slowPathArgument != null; + args.addConst("slowPathArgument", slowPathArgument); } else if (snippetInfo == arraycopyExactIntrinsicSnippet || snippetInfo == arraycopyPredictedExactIntrinsicSnippet) { assert componentKind != null; args.addConst("elementKind", componentKind); @@ -492,7 +499,7 @@ args.add("nonNullDest", arraycopy.getDestination()); args.add("destPos", arraycopy.getDestinationPosition()); if (snippetInfo == arraycopyUnrolledWorkSnippet) { - args.addConst("length", arraycopy.getLength().asJavaConstant().asInt()); + args.addConst("length", ((Integer) arraycopy.getArgument()).intValue()); args.addConst("elementKind", arraycopy.getElementKind()); } else { args.add("length", arraycopy.getLength());