001/* 002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.hotspot.replacements.arraycopy; 024 025import static jdk.internal.jvmci.meta.LocationIdentity.*; 026import jdk.internal.jvmci.meta.*; 027 028import com.oracle.graal.compiler.common.type.*; 029import com.oracle.graal.graph.*; 030import com.oracle.graal.nodeinfo.*; 031import com.oracle.graal.nodes.*; 032import com.oracle.graal.nodes.extended.*; 033import com.oracle.graal.nodes.memory.*; 034import com.oracle.graal.nodes.spi.*; 035 036@NodeInfo 037public class ArrayCopyUnrollNode extends ArrayRangeWriteNode implements MemoryCheckpoint.Single, Lowerable, MemoryAccess { 038 039 public static final NodeClass<ArrayCopyUnrollNode> TYPE = NodeClass.create(ArrayCopyUnrollNode.class); 040 041 @Input protected ValueNode src; 042 @Input protected ValueNode srcPos; 043 @Input protected ValueNode dest; 044 @Input protected ValueNode destPos; 045 @Input protected ValueNode length; 046 047 private Kind elementKind; 048 049 private int unrolledLength; 050 051 @OptionalInput(InputType.Memory) private MemoryNode lastLocationAccess; 052 053 public ArrayCopyUnrollNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, int unrolledLength, Kind elementKind) { 054 super(TYPE, StampFactory.forKind(Kind.Void)); 055 this.src = src; 056 this.srcPos = srcPos; 057 this.dest = dest; 058 this.destPos = destPos; 059 this.length = length; 060 this.unrolledLength = unrolledLength; 061 assert elementKind != null && elementKind != Kind.Illegal; 062 this.elementKind = elementKind; 063 } 064 065 public ValueNode getSource() { 066 return src; 067 } 068 069 public ValueNode getSourcePosition() { 070 return srcPos; 071 } 072 073 public ValueNode getDestination() { 074 return dest; 075 } 076 077 public ValueNode getDestinationPosition() { 078 return destPos; 079 } 080 081 @Override 082 public ValueNode getLength() { 083 return length; 084 } 085 086 @Override 087 public ValueNode getArray() { 088 return dest; 089 } 090 091 @Override 092 public ValueNode getIndex() { 093 return destPos; 094 } 095 096 @Override 097 public boolean isObjectArray() { 098 return elementKind == Kind.Object; 099 } 100 101 @Override 102 public boolean isInitialization() { 103 return false; 104 } 105 106 @NodeIntrinsic 107 public static native void arraycopy(Object nonNullSrc, int srcPos, Object nonNullDest, int destPos, int length, @ConstantNodeParameter int unrolledLength, @ConstantNodeParameter Kind elementKind); 108 109 public int getUnrollLength() { 110 return unrolledLength; 111 } 112 113 public Kind getElementKind() { 114 return elementKind; 115 } 116 117 @Override 118 public LocationIdentity getLocationIdentity() { 119 if (elementKind != null) { 120 return NamedLocationIdentity.getArrayLocation(elementKind); 121 } 122 return any(); 123 } 124 125 @Override 126 public void lower(LoweringTool tool) { 127 tool.getLowerer().lower(this, tool); 128 } 129 130 public MemoryNode getLastLocationAccess() { 131 return lastLocationAccess; 132 } 133 134 public void setLastLocationAccess(MemoryNode lla) { 135 updateUsagesInterface(lastLocationAccess, lla); 136 lastLocationAccess = lla; 137 } 138}