52910
|
1 |
/*
|
58877
|
2 |
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
52910
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
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 |
|
|
24 |
|
|
25 |
package org.graalvm.compiler.replacements.arraycopy;
|
|
26 |
|
|
27 |
import static jdk.internal.vm.compiler.word.LocationIdentity.any;
|
|
28 |
|
|
29 |
import org.graalvm.compiler.graph.NodeClass;
|
|
30 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
31 |
import org.graalvm.compiler.nodes.NamedLocationIdentity;
|
|
32 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
33 |
import org.graalvm.compiler.nodes.spi.Lowerable;
|
|
34 |
import org.graalvm.compiler.nodes.spi.LoweringTool;
|
|
35 |
import org.graalvm.compiler.replacements.nodes.BasicArrayCopyNode;
|
|
36 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
|
37 |
|
|
38 |
@NodeInfo
|
|
39 |
public final class ArrayCopyNode extends BasicArrayCopyNode implements Lowerable {
|
|
40 |
|
|
41 |
public static final NodeClass<ArrayCopyNode> TYPE = NodeClass.create(ArrayCopyNode.class);
|
|
42 |
|
54084
|
43 |
protected final boolean forceAnyLocation;
|
52910
|
44 |
|
|
45 |
public ArrayCopyNode(int bci, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) {
|
54084
|
46 |
this(bci, src, srcPos, dst, dstPos, length, false);
|
|
47 |
}
|
|
48 |
|
|
49 |
public ArrayCopyNode(int bci, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length, boolean forceAnyLocation) {
|
52910
|
50 |
super(TYPE, src, srcPos, dst, dstPos, length, null, bci);
|
54084
|
51 |
this.forceAnyLocation = forceAnyLocation;
|
|
52 |
if (!forceAnyLocation) {
|
|
53 |
elementKind = ArrayCopySnippets.Templates.selectComponentKind(this);
|
|
54 |
} else {
|
|
55 |
assert elementKind == null;
|
|
56 |
}
|
52910
|
57 |
}
|
|
58 |
|
|
59 |
@Override
|
58877
|
60 |
public LocationIdentity getKilledLocationIdentity() {
|
54084
|
61 |
if (!forceAnyLocation && elementKind == null) {
|
52910
|
62 |
elementKind = ArrayCopySnippets.Templates.selectComponentKind(this);
|
|
63 |
}
|
|
64 |
if (elementKind != null) {
|
|
65 |
return NamedLocationIdentity.getArrayLocation(elementKind);
|
|
66 |
}
|
|
67 |
return any();
|
|
68 |
}
|
|
69 |
|
|
70 |
@Override
|
|
71 |
public void lower(LoweringTool tool) {
|
|
72 |
tool.getLowerer().lower(this, tool);
|
|
73 |
}
|
54084
|
74 |
|
|
75 |
public boolean killsAnyLocation() {
|
|
76 |
return forceAnyLocation;
|
|
77 |
}
|
52910
|
78 |
}
|