AbstractDeoptimizeNode.java revision 12657:6ef01bd40ce2
1/* 2 * Copyright (c) 2013, 2013, 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.nodes; 24 25import static org.graalvm.compiler.nodeinfo.InputType.State; 26import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN; 27import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_UNKNOWN; 28 29import org.graalvm.compiler.core.common.type.StampFactory; 30import org.graalvm.compiler.graph.IterableNodeType; 31import org.graalvm.compiler.graph.NodeClass; 32import org.graalvm.compiler.nodeinfo.NodeInfo; 33 34import jdk.vm.ci.meta.MetaAccessProvider; 35 36/** 37 * This node represents an unconditional explicit request for immediate deoptimization. 38 * 39 * After this node, execution will continue using a fallback execution engine (such as an 40 * interpreter) at the position described by the {@link #stateBefore() deoptimization state}. 41 */ 42// @formatter:off 43@NodeInfo(cycles = CYCLES_UNKNOWN, 44 cyclesRationale = "The cycles for a deopt are as high as possible as we continue execution in the interpreter, " + 45 "but they pollute the cost model, thus we do not care about their cycles.", 46 size = SIZE_UNKNOWN, 47 sizeRationale = "Deopts carry the meta information necessary to map the state back in the interpreter, but they pollute the cost model," + 48 "thus we do not care about their size.") 49// @formatter:on 50public abstract class AbstractDeoptimizeNode extends ControlSinkNode implements IterableNodeType, DeoptimizingNode.DeoptBefore { 51 52 public static final NodeClass<AbstractDeoptimizeNode> TYPE = NodeClass.create(AbstractDeoptimizeNode.class); 53 @OptionalInput(State) FrameState stateBefore; 54 55 protected AbstractDeoptimizeNode(NodeClass<? extends AbstractDeoptimizeNode> c, FrameState stateBefore) { 56 super(c, StampFactory.forVoid()); 57 this.stateBefore = stateBefore; 58 } 59 60 @Override 61 public boolean canDeoptimize() { 62 return true; 63 } 64 65 @Override 66 public FrameState stateBefore() { 67 return stateBefore; 68 } 69 70 @Override 71 public void setStateBefore(FrameState f) { 72 updateUsages(stateBefore, f); 73 stateBefore = f; 74 } 75 76 public abstract ValueNode getActionAndReason(MetaAccessProvider metaAccess); 77 78 public abstract ValueNode getSpeculation(MetaAccessProvider metaAccess); 79} 80