src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/arraycopy/ArrayCopyNode.java
author dlong
Thu, 31 Oct 2019 16:54:16 -0700
changeset 58877 aec7bf35d6f5
parent 54084 84f10bbf993f
permissions -rw-r--r--
8233273: Update Graal Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     1
/*
58877
aec7bf35d6f5 8233273: Update Graal
dlong
parents: 54084
diff changeset
     2
 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     4
 *
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     7
 * published by the Free Software Foundation.
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     8
 *
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    13
 * accompanied this code).
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    14
 *
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    18
 *
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    21
 * questions.
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    22
 */
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    23
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    24
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    25
package org.graalvm.compiler.replacements.arraycopy;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    26
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    27
import static jdk.internal.vm.compiler.word.LocationIdentity.any;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    28
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    29
import org.graalvm.compiler.graph.NodeClass;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    30
import org.graalvm.compiler.nodeinfo.NodeInfo;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    31
import org.graalvm.compiler.nodes.NamedLocationIdentity;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    32
import org.graalvm.compiler.nodes.ValueNode;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    33
import org.graalvm.compiler.nodes.spi.Lowerable;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    34
import org.graalvm.compiler.nodes.spi.LoweringTool;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    35
import org.graalvm.compiler.replacements.nodes.BasicArrayCopyNode;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    36
import jdk.internal.vm.compiler.word.LocationIdentity;
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    37
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    38
@NodeInfo
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    39
public final class ArrayCopyNode extends BasicArrayCopyNode implements Lowerable {
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    40
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    41
    public static final NodeClass<ArrayCopyNode> TYPE = NodeClass.create(ArrayCopyNode.class);
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    42
54084
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    43
    protected final boolean forceAnyLocation;
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    44
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    45
    public ArrayCopyNode(int bci, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) {
54084
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    46
        this(bci, src, srcPos, dst, dstPos, length, false);
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    47
    }
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    48
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    49
    public ArrayCopyNode(int bci, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length, boolean forceAnyLocation) {
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    50
        super(TYPE, src, srcPos, dst, dstPos, length, null, bci);
54084
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    51
        this.forceAnyLocation = forceAnyLocation;
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    52
        if (!forceAnyLocation) {
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    53
            elementKind = ArrayCopySnippets.Templates.selectComponentKind(this);
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    54
        } else {
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    55
            assert elementKind == null;
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    56
        }
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    57
    }
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    58
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    59
    @Override
58877
aec7bf35d6f5 8233273: Update Graal
dlong
parents: 54084
diff changeset
    60
    public LocationIdentity getKilledLocationIdentity() {
54084
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    61
        if (!forceAnyLocation && elementKind == null) {
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    62
            elementKind = ArrayCopySnippets.Templates.selectComponentKind(this);
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    63
        }
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    64
        if (elementKind != null) {
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    65
            return NamedLocationIdentity.getArrayLocation(elementKind);
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    66
        }
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    67
        return any();
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    68
    }
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    69
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    70
    @Override
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    71
    public void lower(LoweringTool tool) {
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    72
        tool.getLowerer().lower(this, tool);
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    73
    }
54084
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    74
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    75
    public boolean killsAnyLocation() {
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    76
        return forceAnyLocation;
84f10bbf993f 8218074: Update Graal
jwilhelm
parents: 52910
diff changeset
    77
    }
52910
583fd71c47d6 8214023: Update Graal
dlong
parents:
diff changeset
    78
}