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