src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ZeroMemoryNode.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58533 46b0b7fe255c
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     1
/*
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     4
 *
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     8
 *
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    13
 * accompanied this code).
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    14
 *
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    18
 *
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    21
 * questions.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    22
 */
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    23
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    24
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    25
package org.graalvm.compiler.replacements.nodes;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    26
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    27
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_8;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    28
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_8;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    29
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    30
import org.graalvm.compiler.core.common.type.StampFactory;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    31
import org.graalvm.compiler.graph.NodeClass;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    32
import org.graalvm.compiler.nodeinfo.InputType;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    33
import org.graalvm.compiler.nodeinfo.NodeInfo;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    34
import org.graalvm.compiler.nodes.ValueNode;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    35
import org.graalvm.compiler.nodes.memory.FixedAccessNode;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    36
import org.graalvm.compiler.nodes.memory.address.AddressNode;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    37
import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    38
import org.graalvm.compiler.nodes.spi.LIRLowerable;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    39
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    40
import org.graalvm.compiler.word.Word;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    41
import jdk.internal.vm.compiler.word.LocationIdentity;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    42
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    43
/**
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    44
 * Zeros a chunk of memory.
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    45
 */
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    46
@NodeInfo(nameTemplate = "ZeroMemory#{p#location/s}", allowedUsageTypes = {InputType.Memory}, cycles = CYCLES_8, size = SIZE_8)
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    47
public class ZeroMemoryNode extends FixedAccessNode implements LIRLowerable {
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    48
    public static final NodeClass<ZeroMemoryNode> TYPE = NodeClass.create(ZeroMemoryNode.class);
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    49
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    50
    @Input ValueNode length;
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    51
    private final boolean isAligned;
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    52
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    53
    public ZeroMemoryNode(ValueNode address, ValueNode length, boolean isAligned, LocationIdentity locationIdentity) {
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    54
        this(OffsetAddressNode.create(address), length, isAligned, locationIdentity, BarrierType.NONE);
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    55
    }
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    56
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    57
    public ZeroMemoryNode(AddressNode address, ValueNode length, boolean isAligned, LocationIdentity locationIdentity, BarrierType type) {
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    58
        super(TYPE, address, locationIdentity, StampFactory.forVoid(), type);
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    59
        this.length = length;
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    60
        this.isAligned = isAligned;
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    61
    }
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    62
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    63
    @Override
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    64
    public void generate(NodeLIRBuilderTool gen) {
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    65
        gen.getLIRGeneratorTool().emitZeroMemory(gen.operand(getAddress()), gen.operand(length), isAligned);
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    66
    }
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    67
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    68
    @Override
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    69
    public boolean canNullCheck() {
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    70
        return false;
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    71
    }
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    72
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    73
    @NodeIntrinsic
58533
46b0b7fe255c 8231973: Update Graal
dlong
parents: 58299
diff changeset
    74
    public static native void zero(Word address, long length, @ConstantNodeParameter boolean isAligned, @ConstantNodeParameter LocationIdentity locationIdentity);
54724
62f373a53296 8222665: Update Graal
jwilhelm
parents:
diff changeset
    75
}