< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/arraycopy/CheckcastArrayCopyCallNode.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 //JaCoCo Exclude
  24 package org.graalvm.compiler.hotspot.replacements.arraycopy;
  25 
  26 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN;
  27 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_UNKNOWN;
  28 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset;
  29 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale;


  30 
  31 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;

  32 import org.graalvm.compiler.core.common.type.StampFactory;
  33 import org.graalvm.compiler.graph.NodeClass;
  34 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
  35 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  36 import org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode;
  37 import org.graalvm.compiler.nodeinfo.InputType;
  38 import org.graalvm.compiler.nodeinfo.NodeInfo;
  39 import org.graalvm.compiler.nodes.ConstantNode;
  40 import org.graalvm.compiler.nodes.FixedWithNextNode;
  41 import org.graalvm.compiler.nodes.StructuredGraph;
  42 import org.graalvm.compiler.nodes.ValueNode;
  43 import org.graalvm.compiler.nodes.calc.AddNode;
  44 import org.graalvm.compiler.nodes.calc.IntegerConvertNode;
  45 import org.graalvm.compiler.nodes.calc.LeftShiftNode;
  46 import org.graalvm.compiler.nodes.extended.ForeignCallNode;
  47 import org.graalvm.compiler.nodes.memory.AbstractMemoryCheckpoint;
  48 import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
  49 import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode;
  50 import org.graalvm.compiler.nodes.spi.Lowerable;
  51 import org.graalvm.compiler.nodes.spi.LoweringTool;


  97         return dest;
  98     }
  99 
 100     public ValueNode getDestinationPosition() {
 101         return destPos;
 102     }
 103 
 104     public ValueNode getLength() {
 105         return length;
 106     }
 107 
 108     public boolean isUninit() {
 109         return uninit;
 110     }
 111 
 112     private ValueNode computeBase(ValueNode base, ValueNode pos) {
 113         FixedWithNextNode basePtr = graph().add(new GetObjectAddressNode(base));
 114         graph().addBeforeFixed(this, basePtr);
 115 
 116         int shift = CodeUtil.log2(getArrayIndexScale(JavaKind.Object));
 117         ValueNode scaledIndex = graph().unique(new LeftShiftNode(pos, ConstantNode.forInt(shift, graph())));
 118         ValueNode offset = graph().unique(new AddNode(scaledIndex, ConstantNode.forInt(getArrayBaseOffset(JavaKind.Object), graph())));

 119         return graph().unique(new OffsetAddressNode(basePtr, offset));
 120     }
 121 
 122     @Override
 123     public void lower(LoweringTool tool) {
 124         if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
 125             ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupCheckcastArraycopyDescriptor(isUninit());
 126             StructuredGraph graph = graph();
 127             ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
 128             ValueNode destAddr = computeBase(getDestination(), getDestinationPosition());
 129             ValueNode len = getLength();
 130             if (len.stamp().getStackKind() != runtime.getTarget().wordJavaKind) {
 131                 len = IntegerConvertNode.convert(len, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph());
 132             }
 133             ForeignCallNode call = graph.add(new ForeignCallNode(runtime.getHostBackend().getForeignCalls(), desc, srcAddr, destAddr, len, superCheckOffset, destElemKlass));
 134             call.setStateAfter(stateAfter());
 135             graph.replaceFixedWithFixed(this, call);
 136         }
 137     }
 138 


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 //JaCoCo Exclude
  24 package org.graalvm.compiler.hotspot.replacements.arraycopy;
  25 


  26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset;
  27 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale;
  28 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN;
  29 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_UNKNOWN;
  30 
  31 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
  32 import org.graalvm.compiler.core.common.type.PrimitiveStamp;
  33 import org.graalvm.compiler.core.common.type.StampFactory;
  34 import org.graalvm.compiler.graph.NodeClass;
  35 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
  36 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  37 import org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode;
  38 import org.graalvm.compiler.nodeinfo.InputType;
  39 import org.graalvm.compiler.nodeinfo.NodeInfo;
  40 import org.graalvm.compiler.nodes.ConstantNode;
  41 import org.graalvm.compiler.nodes.FixedWithNextNode;
  42 import org.graalvm.compiler.nodes.StructuredGraph;
  43 import org.graalvm.compiler.nodes.ValueNode;
  44 import org.graalvm.compiler.nodes.calc.AddNode;
  45 import org.graalvm.compiler.nodes.calc.IntegerConvertNode;
  46 import org.graalvm.compiler.nodes.calc.LeftShiftNode;
  47 import org.graalvm.compiler.nodes.extended.ForeignCallNode;
  48 import org.graalvm.compiler.nodes.memory.AbstractMemoryCheckpoint;
  49 import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
  50 import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode;
  51 import org.graalvm.compiler.nodes.spi.Lowerable;
  52 import org.graalvm.compiler.nodes.spi.LoweringTool;


  98         return dest;
  99     }
 100 
 101     public ValueNode getDestinationPosition() {
 102         return destPos;
 103     }
 104 
 105     public ValueNode getLength() {
 106         return length;
 107     }
 108 
 109     public boolean isUninit() {
 110         return uninit;
 111     }
 112 
 113     private ValueNode computeBase(ValueNode base, ValueNode pos) {
 114         FixedWithNextNode basePtr = graph().add(new GetObjectAddressNode(base));
 115         graph().addBeforeFixed(this, basePtr);
 116 
 117         int shift = CodeUtil.log2(getArrayIndexScale(JavaKind.Object));
 118         ValueNode extendedPos = IntegerConvertNode.convert(pos, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph());
 119         ValueNode scaledIndex = graph().unique(new LeftShiftNode(extendedPos, ConstantNode.forInt(shift, graph())));
 120         ValueNode offset = graph().unique(new AddNode(scaledIndex, ConstantNode.forIntegerBits(PrimitiveStamp.getBits(scaledIndex.stamp()), getArrayBaseOffset(JavaKind.Object), graph())));
 121         return graph().unique(new OffsetAddressNode(basePtr, offset));
 122     }
 123 
 124     @Override
 125     public void lower(LoweringTool tool) {
 126         if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
 127             ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupCheckcastArraycopyDescriptor(isUninit());
 128             StructuredGraph graph = graph();
 129             ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
 130             ValueNode destAddr = computeBase(getDestination(), getDestinationPosition());
 131             ValueNode len = getLength();
 132             if (len.stamp().getStackKind() != runtime.getTarget().wordJavaKind) {
 133                 len = IntegerConvertNode.convert(len, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph());
 134             }
 135             ForeignCallNode call = graph.add(new ForeignCallNode(runtime.getHostBackend().getForeignCalls(), desc, srcAddr, destAddr, len, superCheckOffset, destElemKlass));
 136             call.setStateAfter(stateAfter());
 137             graph.replaceFixedWithFixed(this, call);
 138         }
 139     }
 140 
< prev index next >