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.nodes; 26 27 import org.graalvm.compiler.nodes.spi.NodeWithState; 28 29 /** 30 * Interface implemented by nodes which may need {@linkplain FrameState deoptimization information}. 31 * <p> 32 * Sub-interfaces are used to specify exactly when the deoptimization can take place: 33 * {@linkplain DeoptBefore before}, {@linkplain DeoptAfter after}, and/or {@linkplain DeoptDuring 34 * during}. <br> 35 * Note that these sub-interfaces are not mutually exclusive so that nodes that may deoptimize at 36 * multiple times can be modeled. 37 */ 38 public interface DeoptimizingNode extends NodeWithState { 39 40 /** 41 * Determines if this node needs deoptimization information. 42 */ 43 boolean canDeoptimize(); 44 45 /** 46 * Interface for nodes that need a {@link FrameState} for deoptimizing to a point before their 47 * execution. 48 */ 49 public interface DeoptBefore extends DeoptimizingNode { 50 51 /** 52 * Sets the {@link FrameState} describing the program state before the execution of this 53 * node. 54 */ 55 void setStateBefore(FrameState state); 56 57 FrameState stateBefore(); 58 } 59 60 /** 61 * Interface for nodes that need a {@link FrameState} for deoptimizing to a point after their 62 * execution. 63 */ 64 public interface DeoptAfter extends DeoptimizingNode, StateSplit { 65 } 66 67 /** 68 * Interface for nodes that need a special {@link FrameState} for deoptimizing during their 69 * execution (e.g. {@link Invoke}). 70 */ 71 public interface DeoptDuring extends DeoptimizingNode, StateSplit { 72 73 FrameState stateDuring(); 74 75 /** 76 * Sets the {@link FrameState} describing the program state during the execution of this 77 * node. 78 */ 79 void setStateDuring(FrameState state); 80 81 /** 82 * Compute the {@link FrameState} describing the program state during the execution of this 83 * node from an input {@link FrameState} describing the program state after finishing the 84 * execution of this node. 85 */ 86 void computeStateDuring(FrameState stateAfter); 87 } 88 }