1 /* 2 * Copyright (c) 2013, 2018, 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.nodes; 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.nodeinfo.InputType; 32 import org.graalvm.compiler.nodeinfo.NodeInfo; 33 import org.graalvm.compiler.nodes.DeoptimizingNode; 34 import org.graalvm.compiler.nodes.FrameState; 35 import org.graalvm.compiler.nodes.ValueNode; 36 import org.graalvm.compiler.nodes.memory.address.AddressNode; 37 38 @NodeInfo(cycles = CYCLES_64, size = SIZE_64) 39 public final class G1PreWriteBarrier extends ObjectWriteBarrier implements DeoptimizingNode.DeoptBefore { 40 41 public static final NodeClass<G1PreWriteBarrier> TYPE = NodeClass.create(G1PreWriteBarrier.class); 42 43 @OptionalInput(InputType.State) FrameState stateBefore; 44 protected final boolean nullCheck; 45 protected final boolean doLoad; 46 47 public G1PreWriteBarrier(AddressNode address, ValueNode expectedObject, boolean doLoad, boolean nullCheck) { 48 super(TYPE, address, expectedObject, true); 49 this.doLoad = doLoad; 50 this.nullCheck = nullCheck; 51 } 52 53 public ValueNode getExpectedObject() { 54 return getValue(); 55 } 56 57 public boolean doLoad() { 58 return doLoad; 59 } 60 61 public boolean getNullCheck() { 62 return nullCheck; 63 } 64 65 @Override 66 public boolean canDeoptimize() { 67 return nullCheck; 68 } 69 70 @Override 71 public FrameState stateBefore() { 72 return stateBefore; 73 } 74 75 @Override 76 public void setStateBefore(FrameState state) { 77 updateUsages(stateBefore, state); 78 stateBefore = state; 79 } 80 }