1/*
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
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 */
23package org.graalvm.compiler.hotspot.nodes;
24
25import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_64;
26import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_64;
27
28import org.graalvm.compiler.graph.NodeClass;
29import org.graalvm.compiler.nodeinfo.NodeInfo;
30import org.graalvm.compiler.nodes.ValueNode;
31import org.graalvm.compiler.nodes.memory.address.AddressNode;
32
33/**
34 * The {@code G1ReferentFieldReadBarrier} is added when a read access is performed to the referent
35 * field of a {@link java.lang.ref.Reference} object (through a {@code LoadFieldNode} or an
36 * {@code UnsafeLoadNode}). The return value of the read is passed to the snippet implementing the
37 * read barrier and consequently is added to the SATB queue if the concurrent marker is enabled.
38 */
39@NodeInfo(cycles = CYCLES_64, size = SIZE_64)
40public final class G1ReferentFieldReadBarrier extends ObjectWriteBarrier {
41    public static final NodeClass<G1ReferentFieldReadBarrier> TYPE = NodeClass.create(G1ReferentFieldReadBarrier.class);
42
43    protected final boolean doLoad;
44
45    public G1ReferentFieldReadBarrier(AddressNode address, ValueNode expectedObject, boolean doLoad) {
46        super(TYPE, address, expectedObject, true);
47        this.doLoad = doLoad;
48    }
49
50    public ValueNode getExpectedObject() {
51        return getValue();
52    }
53
54    public boolean doLoad() {
55        return doLoad;
56    }
57}
58