From 8cd97653d9abc8168cbbb35d99d8c1e23b54972d Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Tue, 1 Jun 2021 14:53:13 +0200 Subject: [PATCH] svm: remove SubstrateArraysCopyOfSnippets The SubstrateVM specific intrinsic for Arrays.copyOf is no longer needed as we can now deal with the graphs the compiler produces. There is no more good reason to keep maintaining this code. --- .../core/graal/jdk/JDKIntrinsicsFeature.java | 2 - .../core/graal/jdk/SubstrateArraysCopyOf.java | 79 ---------- .../graal/jdk/SubstrateArraysCopyOfNode.java | 85 ---------- .../jdk/SubstrateArraysCopyOfSnippets.java | 147 ------------------ ...ubstrateArraysCopyOfWithExceptionNode.java | 126 --------------- .../flow/SVMMethodTypeFlowBuilder.java | 4 - .../SubstrateGraphBuilderPlugins.java | 46 ------ 7 files changed, 489 deletions(-) delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOf.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfNode.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfSnippets.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfWithExceptionNode.java diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java index 9eee1ae530c8..62a3f0e4fb10 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java @@ -54,7 +54,6 @@ final class JDKIntrinsicsFeature implements GraalFeature { public void registerForeignCalls(RuntimeConfiguration runtimeConfig, Providers providers, SnippetReflectionProvider snippetReflection, SubstrateForeignCallsProvider foreignCalls, boolean hosted) { ArraycopySnippets.registerForeignCalls(providers, foreignCalls); SubstrateObjectCloneSnippets.registerForeignCalls(providers, foreignCalls); - SubstrateArraysCopyOfSnippets.registerForeignCalls(providers, foreignCalls); } @Override @@ -64,7 +63,6 @@ public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues o Map, NodeLoweringProvider> lowerings, boolean hosted) { new ArraycopySnippets(options, factories, providers, snippetReflection, lowerings); SubstrateObjectCloneSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings); - SubstrateArraysCopyOfSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOf.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOf.java deleted file mode 100644 index 289cf7bc7659..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOf.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.graal.jdk; - -import java.util.Arrays; - -import org.graalvm.compiler.core.common.type.ObjectStamp; -import org.graalvm.compiler.core.common.type.Stamp; -import org.graalvm.compiler.core.common.type.StampFactory; -import org.graalvm.compiler.nodes.ConstantNode; -import org.graalvm.compiler.nodes.ValueNode; -import org.graalvm.compiler.nodes.spi.Lowerable; -import org.graalvm.compiler.nodes.spi.VirtualizableAllocation; -import org.graalvm.compiler.nodes.spi.VirtualizerTool; -import org.graalvm.compiler.nodes.util.GraphUtil; -import org.graalvm.compiler.nodes.virtual.VirtualArrayNode; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Interface for SubstrateVM nodes implementing {@link Arrays#copyOf}. - */ -public interface SubstrateArraysCopyOf extends Lowerable, VirtualizableAllocation { - - ValueNode getOriginal(); - - ValueNode getOriginalLength(); - - ValueNode getNewObjectArrayType(); - - ValueNode getNewLength(); - - static Stamp computeStamp(Stamp result) { - if (result instanceof ObjectStamp) { - return result.join(StampFactory.objectNonNull()); - } - return result; - } - - @Override - default void virtualize(VirtualizerTool tool) { - if (!getNewObjectArrayType().isConstant()) { - /* - * This is an object array copy. If the new array type is not a constant then it cannot - * be virtualized. - */ - return; - } - - /* from index is always 0 for Arrays.copyOf. */ - ValueNode from = ConstantNode.forInt(0); - ResolvedJavaType newComponentType = tool.getConstantReflection().asJavaType(getNewObjectArrayType().asConstant()).getComponentType(); - GraphUtil.virtualizeArrayCopy(tool, getOriginal(), getOriginalLength(), getNewLength(), from, newComponentType, JavaKind.Object, asNode().graph(), - (componentType, length) -> new VirtualArrayNode(componentType, length)); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfNode.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfNode.java deleted file mode 100644 index e8a3179bc1ca..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfNode.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.graal.jdk; - -import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_64; - -import org.graalvm.compiler.core.common.type.Stamp; -import org.graalvm.compiler.graph.NodeClass; -import org.graalvm.compiler.nodeinfo.NodeInfo; -import org.graalvm.compiler.nodeinfo.NodeSize; -import org.graalvm.compiler.nodes.DeoptimizingFixedWithNextNode; -import org.graalvm.compiler.nodes.ValueNode; - -/** - * Implementation for substrate Arrays.copyOf(). It is currently used only to intrinsify copying of - * Object arrays (no primitive arrays). - */ -@NodeInfo(cycles = CYCLES_64, size = NodeSize.SIZE_64) -public final class SubstrateArraysCopyOfNode extends DeoptimizingFixedWithNextNode implements SubstrateArraysCopyOf { - public static final NodeClass TYPE = NodeClass.create(SubstrateArraysCopyOfNode.class); - - @Input ValueNode original; - @Input ValueNode originalLength; - @Input ValueNode newLength; - /** The type of the array copy. */ - @Input ValueNode newObjectArrayType; - - /** - * The stamp is conservative. The concrete type will be loaded from newTypeObject. - */ - public SubstrateArraysCopyOfNode(@InjectedNodeParameter Stamp stamp, ValueNode original, ValueNode originaLength, ValueNode newLength, ValueNode newArrayType) { - super(TYPE, SubstrateArraysCopyOf.computeStamp(stamp)); - this.original = original; - this.originalLength = originaLength; - this.newLength = newLength; - this.newObjectArrayType = newArrayType; - } - - @Override - public ValueNode getOriginal() { - return original; - } - - @Override - public ValueNode getOriginalLength() { - return originalLength; - } - - @Override - public ValueNode getNewObjectArrayType() { - return newObjectArrayType; - } - - @Override - public ValueNode getNewLength() { - return newLength; - } - - @Override - public boolean canDeoptimize() { - return true; - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfSnippets.java deleted file mode 100644 index 9f6a88045404..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfSnippets.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.graal.jdk; - -import java.util.Map; - -import org.graalvm.compiler.api.replacements.Snippet; -import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; -import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor; -import org.graalvm.compiler.debug.DebugHandlersFactory; -import org.graalvm.compiler.graph.Node; -import org.graalvm.compiler.graph.Node.ConstantNodeParameter; -import org.graalvm.compiler.graph.Node.NodeIntrinsic; -import org.graalvm.compiler.nodes.NodeView; -import org.graalvm.compiler.nodes.PiArrayNode; -import org.graalvm.compiler.nodes.StructuredGraph; -import org.graalvm.compiler.nodes.extended.ForeignCallNode; -import org.graalvm.compiler.nodes.extended.ForeignCallWithExceptionNode; -import org.graalvm.compiler.nodes.spi.LoweringTool; -import org.graalvm.compiler.options.OptionValues; -import org.graalvm.compiler.phases.util.Providers; -import org.graalvm.compiler.replacements.SnippetTemplate; -import org.graalvm.compiler.replacements.SnippetTemplate.Arguments; -import org.graalvm.compiler.replacements.SnippetTemplate.SnippetInfo; -import org.graalvm.compiler.replacements.Snippets; - -import com.oracle.svm.core.JavaMemoryUtil; -import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; -import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; -import com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets; -import com.oracle.svm.core.graal.snippets.SubstrateTemplates; -import com.oracle.svm.core.hub.DynamicHub; -import com.oracle.svm.core.hub.LayoutEncoding; -import com.oracle.svm.core.snippets.KnownIntrinsics; -import com.oracle.svm.core.snippets.SnippetRuntime; -import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; -import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; - -public final class SubstrateArraysCopyOfSnippets extends SubstrateTemplates implements Snippets { - private static final SubstrateForeignCallDescriptor ARRAYS_COPY_OF = SnippetRuntime.findForeignCall(SubstrateArraysCopyOfSnippets.class, "doArraysCopyOf", true); - private static final SubstrateForeignCallDescriptor[] FOREIGN_CALLS = new SubstrateForeignCallDescriptor[]{ARRAYS_COPY_OF}; - - public static void registerForeignCalls(Providers providers, SubstrateForeignCallsProvider foreignCalls) { - foreignCalls.register(providers, FOREIGN_CALLS); - } - - @SuppressWarnings("unused") - public static void registerLowerings(OptionValues options, Iterable factories, Providers providers, SnippetReflectionProvider snippetReflection, - Map, NodeLoweringProvider> lowerings) { - new SubstrateArraysCopyOfSnippets(options, factories, providers, snippetReflection, lowerings); - } - - @SubstrateForeignCallTarget(stubCallingConvention = false) - private static Object doArraysCopyOf(DynamicHub hub, Object original, int originalLength, int newLength) { - // The allocation will throw a NegativeArraySizeException if necessary. - Object newArray = java.lang.reflect.Array.newInstance(DynamicHub.toClass(hub.getComponentHub()), newLength); - - int layoutEncoding = hub.getLayoutEncoding(); - int copiedLength = originalLength < newLength ? originalLength : newLength; - if (LayoutEncoding.isObjectArray(layoutEncoding)) { - DynamicHub originalHub = KnownIntrinsics.readHub(original); - if (originalHub == hub || DynamicHub.toClass(hub).isAssignableFrom(DynamicHub.toClass(originalHub))) { - JavaMemoryUtil.copyObjectArrayForward(original, 0, newArray, 0, copiedLength, layoutEncoding); - } else { - JavaMemoryUtil.copyObjectArrayForwardWithStoreCheck(original, 0, newArray, 0, copiedLength); - } - } else { - JavaMemoryUtil.copyPrimitiveArrayForward(original, 0, newArray, 0, copiedLength, layoutEncoding); - } - - // All elements beyond copiedLength were already zeroed by the allocation. - return newArray; - } - - @NodeIntrinsic(value = ForeignCallNode.class) - private static native Object callArraysCopyOf(@ConstantNodeParameter ForeignCallDescriptor descriptor, Class hub, Object original, int originalLength, int newLength); - - @Snippet - public static Object arraysCopyOfSnippet(DynamicHub hub, Object original, int originalLength, int newLength) { - Object result = callArraysCopyOf(ARRAYS_COPY_OF, DynamicHub.toClass(hub), original, originalLength, newLength); - return PiArrayNode.piArrayCastToSnippetReplaceeStamp(result, newLength); - } - - private SubstrateArraysCopyOfSnippets(OptionValues options, Iterable factories, Providers providers, SnippetReflectionProvider snippetReflection, - Map, NodeLoweringProvider> lowerings) { - super(options, factories, providers, snippetReflection); - - ArraysCopyOfLowering arraysCopyOfLowering = new ArraysCopyOfLowering(); - lowerings.put(SubstrateArraysCopyOfNode.class, arraysCopyOfLowering); - ArraysCopyOfWithExceptionLowering arraysCopyOfWithExceptionLowering = new ArraysCopyOfWithExceptionLowering(); - lowerings.put(SubstrateArraysCopyOfWithExceptionNode.class, arraysCopyOfWithExceptionLowering); - } - - protected class ArraysCopyOfLowering implements NodeLoweringProvider { - private final SnippetInfo arraysCopyOf = snippet(SubstrateArraysCopyOfSnippets.class, "arraysCopyOfSnippet", SubstrateAllocationSnippets.ALLOCATION_LOCATIONS); - - @Override - public void lower(SubstrateArraysCopyOfNode node, LoweringTool tool) { - if (node.graph().getGuardsStage() != StructuredGraph.GuardsStage.AFTER_FSA) { - return; - } - - Arguments args = new Arguments(arraysCopyOf, node.graph().getGuardsStage(), tool.getLoweringStage()); - args.add("hub", node.getNewObjectArrayType()); - args.add("original", node.getOriginal()); - args.add("originalLength", node.getOriginalLength()); - args.add("newLength", node.getNewLength()); - - template(node, args).instantiate(providers.getMetaAccess(), node, SnippetTemplate.DEFAULT_REPLACER, args); - } - } - - protected class ArraysCopyOfWithExceptionLowering implements NodeLoweringProvider { - - @Override - public void lower(SubstrateArraysCopyOfWithExceptionNode node, LoweringTool tool) { - StructuredGraph graph = node.graph(); - ForeignCallWithExceptionNode call = graph - .add(new ForeignCallWithExceptionNode(ARRAYS_COPY_OF, node.getNewObjectArrayType(), node.getOriginal(), node.getOriginalLength(), node.getNewLength())); - call.setBci(node.bci()); - call.setStamp(node.stamp(NodeView.DEFAULT)); - graph.replaceWithExceptionSplit(node, call); - } - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfWithExceptionNode.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfWithExceptionNode.java deleted file mode 100644 index bcda9627830d..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateArraysCopyOfWithExceptionNode.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.graal.jdk; - -import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_64; - -import org.graalvm.compiler.core.common.type.Stamp; -import org.graalvm.compiler.graph.NodeClass; -import org.graalvm.compiler.nodeinfo.InputType; -import org.graalvm.compiler.nodeinfo.NodeInfo; -import org.graalvm.compiler.nodeinfo.NodeSize; -import org.graalvm.compiler.nodes.AbstractBeginNode; -import org.graalvm.compiler.nodes.DeoptimizingNode; -import org.graalvm.compiler.nodes.FixedNode; -import org.graalvm.compiler.nodes.FrameState; -import org.graalvm.compiler.nodes.ValueNode; -import org.graalvm.compiler.nodes.WithExceptionNode; -import org.graalvm.compiler.nodes.memory.SingleMemoryKill; -import org.graalvm.compiler.nodes.util.GraphUtil; -import org.graalvm.word.LocationIdentity; - -/** - * Implementation for substrate Arrays.copyOf() with an exception edge. It is currently used only to - * intrinsify copying of Object arrays (no primitive arrays). - */ -@NodeInfo(cycles = CYCLES_64, size = NodeSize.SIZE_64) -public final class SubstrateArraysCopyOfWithExceptionNode extends WithExceptionNode implements SubstrateArraysCopyOf, DeoptimizingNode.DeoptBefore, SingleMemoryKill { - public static final NodeClass TYPE = NodeClass.create(SubstrateArraysCopyOfWithExceptionNode.class); - - @OptionalInput(InputType.State) protected FrameState stateBefore; - @Input ValueNode original; - @Input ValueNode originalLength; - @Input ValueNode newLength; - /** The type of the array copy. */ - @Input ValueNode newObjectArrayType; - int bci; - - /** - * The stamp is conservative. The concrete type will be loaded from newTypeObject. - */ - public SubstrateArraysCopyOfWithExceptionNode(@InjectedNodeParameter Stamp stamp, ValueNode original, ValueNode originaLength, ValueNode newLength, ValueNode newArrayType, int bci) { - super(TYPE, SubstrateArraysCopyOf.computeStamp(stamp)); - this.original = original; - this.originalLength = originaLength; - this.newLength = newLength; - this.newObjectArrayType = newArrayType; - this.bci = bci; - } - - @Override - public ValueNode getOriginal() { - return original; - } - - @Override - public ValueNode getOriginalLength() { - return originalLength; - } - - @Override - public ValueNode getNewObjectArrayType() { - return newObjectArrayType; - } - - @Override - public ValueNode getNewLength() { - return newLength; - } - - @Override - public boolean canDeoptimize() { - return true; - } - - @Override - public FrameState stateBefore() { - return stateBefore; - } - - @Override - public void setStateBefore(FrameState state) { - updateUsages(stateBefore, state); - stateBefore = state; - } - - int bci() { - return bci; - } - - @Override - public LocationIdentity getKilledLocationIdentity() { - return LocationIdentity.any(); - } - - @Override - public FixedNode replaceWithNonThrowing() { - SubstrateArraysCopyOfNode plainArrayCopy = this.asNode().graph().add(new SubstrateArraysCopyOfNode(stamp, getOriginal(), getOriginalLength(), getNewLength(), getNewObjectArrayType())); - plainArrayCopy.setStateBefore(stateBefore()); - AbstractBeginNode oldException = exceptionEdge(); - graph().replaceSplitWithFixed(this, plainArrayCopy, this.next()); - GraphUtil.killCFG(oldException); - return plainArrayCopy; - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/flow/SVMMethodTypeFlowBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/flow/SVMMethodTypeFlowBuilder.java index 7c7a1a5016ae..8e58cd0a2bdc 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/flow/SVMMethodTypeFlowBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/flow/SVMMethodTypeFlowBuilder.java @@ -46,7 +46,6 @@ import com.oracle.graal.pointsto.meta.AnalysisField; import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.graal.pointsto.typestate.TypeState; -import com.oracle.svm.core.graal.jdk.SubstrateArraysCopyOf; import com.oracle.svm.core.graal.thread.CompareAndSetVMThreadLocalNode; import com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode; import com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode; @@ -211,9 +210,6 @@ protected void delegateNodeProcessing(FixedNode n, MethodTypeFlowBuilder.TypeFlo } else if (n instanceof CompareAndSetVMThreadLocalNode) { CompareAndSetVMThreadLocalNode node = (CompareAndSetVMThreadLocalNode) n; storeVMThreadLocal(state, node, node.getUpdate()); - } else if (n instanceof SubstrateArraysCopyOf) { - SubstrateArraysCopyOf node = (SubstrateArraysCopyOf) n; - processArraysCopyOf(n, node.getOriginal(), node.getNewObjectArrayType(), state); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java index df4e8a676a1b..58163a7a78b9 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java @@ -43,9 +43,7 @@ import org.graalvm.compiler.core.common.CompressEncoding; import org.graalvm.compiler.core.common.type.AbstractObjectStamp; import org.graalvm.compiler.core.common.type.IntegerStamp; -import org.graalvm.compiler.core.common.type.Stamp; import org.graalvm.compiler.core.common.type.StampFactory; -import org.graalvm.compiler.core.common.type.TypeReference; import org.graalvm.compiler.graph.Edges; import org.graalvm.compiler.graph.Node; import org.graalvm.compiler.graph.NodeList; @@ -62,14 +60,12 @@ import org.graalvm.compiler.nodes.calc.NarrowNode; import org.graalvm.compiler.nodes.calc.ZeroExtendNode; import org.graalvm.compiler.nodes.extended.BytecodeExceptionNode; -import org.graalvm.compiler.nodes.extended.GetClassNode; import org.graalvm.compiler.nodes.extended.LoadHubNode; import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration; -import org.graalvm.compiler.nodes.java.ArrayLengthNode; import org.graalvm.compiler.nodes.java.DynamicNewInstanceNode; import org.graalvm.compiler.nodes.java.InstanceOfDynamicNode; import org.graalvm.compiler.nodes.java.NewArrayNode; @@ -115,7 +111,6 @@ import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.graal.GraalEdgeUnsafePartition; import com.oracle.svm.core.graal.jdk.ObjectCloneWithExceptionNode; -import com.oracle.svm.core.graal.jdk.SubstrateArraysCopyOfWithExceptionNode; import com.oracle.svm.core.graal.nodes.DeoptEntryNode; import com.oracle.svm.core.graal.nodes.FarReturnNode; import com.oracle.svm.core.graal.nodes.LazyConstantNode; @@ -188,7 +183,6 @@ public static void registerInvocationPlugins(AnnotationSubstitutionProcessor ann registerUnsafePlugins(metaAccess, plugins, snippetReflection, parsingReason); registerKnownIntrinsicsPlugins(plugins); registerStackValuePlugins(snippetReflection, plugins); - registerArraysPlugins(plugins); registerArrayPlugins(plugins, snippetReflection, parsingReason); registerClassPlugins(plugins, snippetReflection); registerEdgesPlugins(metaAccess, plugins); @@ -724,46 +718,6 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec }); } - private static void registerArraysPlugins(InvocationPlugins plugins) { - - Registration r = new Registration(plugins, Arrays.class).setAllowOverwrite(true); - - r.register2("copyOf", Object[].class, int.class, new InvocationPlugin() { - @Override - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength) { - ValueNode nonNullOriginal = b.nullCheckedValue(original); - - /* Get the class from the original node. */ - GetClassNode originalArrayType = b.add(new GetClassNode(original.stamp(NodeView.DEFAULT), nonNullOriginal)); - - ValueNode originalLength = b.add(ArrayLengthNode.create(nonNullOriginal, b.getConstantReflection())); - Stamp stamp = b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp().join(nonNullOriginal.stamp(NodeView.DEFAULT)); - - b.addPush(JavaKind.Object, new SubstrateArraysCopyOfWithExceptionNode(stamp, nonNullOriginal, originalLength, newLength, originalArrayType, b.bci())); - return true; - } - }); - - r.register3("copyOf", Object[].class, int.class, Class.class, new InvocationPlugin() { - @Override - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength, ValueNode newArrayType) { - Stamp stamp; - if (newArrayType.isConstant()) { - ResolvedJavaType newType = b.getConstantReflection().asJavaType(newArrayType.asConstant()); - stamp = StampFactory.objectNonNull(TypeReference.createExactTrusted(newType)); - } else { - stamp = b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp(); - } - - ValueNode nonNullOriginal = b.nullCheckedValue(original); - ValueNode originalLength = b.add(ArrayLengthNode.create(nonNullOriginal, b.getConstantReflection())); - b.addPush(JavaKind.Object, new SubstrateArraysCopyOfWithExceptionNode(stamp, nonNullOriginal, originalLength, newLength, newArrayType, b.bci())); - return true; - } - }); - - } - private static void registerKnownIntrinsicsPlugins(InvocationPlugins plugins) { Registration r = new Registration(plugins, KnownIntrinsics.class); r.register0("heapBase", new InvocationPlugin() {