< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/VirtualizerTool.java

Print this page




   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 package org.graalvm.compiler.nodes.spi;
  24 
  25 import java.util.List;
  26 
  27 import org.graalvm.compiler.debug.DebugContext;

  28 import org.graalvm.compiler.graph.Node;
  29 import org.graalvm.compiler.nodes.ValueNode;
  30 import org.graalvm.compiler.nodes.java.MonitorIdNode;
  31 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
  32 import org.graalvm.compiler.options.OptionValues;
  33 
  34 import jdk.vm.ci.meta.ConstantReflectionProvider;
  35 import jdk.vm.ci.meta.JavaConstant;
  36 import jdk.vm.ci.meta.JavaKind;
  37 import jdk.vm.ci.meta.MetaAccessProvider;
  38 
  39 /**
  40  * This tool can be used to query the current state (normal/virtualized/re-materialized) of values
  41  * and to describe the actions that would be taken for this state.
  42  *
  43  * See also {@link Virtualizable}.
  44  */
  45 public interface VirtualizerTool {
  46 
  47     /**


  74      * @param ensureVirtualized true if this object needs to stay virtual
  75      */
  76     void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, boolean ensureVirtualized);
  77 
  78     /**
  79      * Returns a VirtualObjectNode if the given value is aliased with a virtual object that is still
  80      * virtual, the materialized value of the given value is aliased with a virtual object that was
  81      * materialized, the replacement if the give value was replaced, otherwise the given value.
  82      *
  83      * Replacements via {@link #replaceWithValue(ValueNode)} are not immediately committed. This
  84      * method can be used to determine if a value was replaced by another one (e.g., a load field by
  85      * the loaded value).
  86      */
  87     ValueNode getAlias(ValueNode value);
  88 
  89     /**
  90      * Sets the entry (field or array element) with the given index in the virtualized object.
  91      *
  92      * @param index the index to be set.
  93      * @param value the new value for the given index.
  94      * @param unsafe if true, then mismatching value {@link JavaKind}s will be accepted.
  95      */
  96     void setVirtualEntry(VirtualObjectNode virtualObject, int index, ValueNode value, boolean unsafe);








  97 
  98     ValueNode getEntry(VirtualObjectNode virtualObject, int index);
  99 
 100     void addLock(VirtualObjectNode virtualObject, MonitorIdNode monitorId);
 101 
 102     MonitorIdNode removeLock(VirtualObjectNode virtualObject);
 103 
 104     void setEnsureVirtualized(VirtualObjectNode virtualObject, boolean ensureVirtualized);
 105 
 106     boolean getEnsureVirtualized(VirtualObjectNode virtualObject);
 107 
 108     // operations on the current node
 109 
 110     /**
 111      * Deletes the current node and replaces it with the given virtualized object.
 112      *
 113      * @param virtualObject the virtualized object that should replace the current node.
 114      */
 115     void replaceWithVirtual(VirtualObjectNode virtualObject);
 116 




   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 package org.graalvm.compiler.nodes.spi;
  24 
  25 import java.util.List;
  26 
  27 import org.graalvm.compiler.debug.DebugContext;
  28 import org.graalvm.compiler.debug.GraalError;
  29 import org.graalvm.compiler.graph.Node;
  30 import org.graalvm.compiler.nodes.ValueNode;
  31 import org.graalvm.compiler.nodes.java.MonitorIdNode;
  32 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
  33 import org.graalvm.compiler.options.OptionValues;
  34 
  35 import jdk.vm.ci.meta.ConstantReflectionProvider;
  36 import jdk.vm.ci.meta.JavaConstant;
  37 import jdk.vm.ci.meta.JavaKind;
  38 import jdk.vm.ci.meta.MetaAccessProvider;
  39 
  40 /**
  41  * This tool can be used to query the current state (normal/virtualized/re-materialized) of values
  42  * and to describe the actions that would be taken for this state.
  43  *
  44  * See also {@link Virtualizable}.
  45  */
  46 public interface VirtualizerTool {
  47 
  48     /**


  75      * @param ensureVirtualized true if this object needs to stay virtual
  76      */
  77     void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, boolean ensureVirtualized);
  78 
  79     /**
  80      * Returns a VirtualObjectNode if the given value is aliased with a virtual object that is still
  81      * virtual, the materialized value of the given value is aliased with a virtual object that was
  82      * materialized, the replacement if the give value was replaced, otherwise the given value.
  83      *
  84      * Replacements via {@link #replaceWithValue(ValueNode)} are not immediately committed. This
  85      * method can be used to determine if a value was replaced by another one (e.g., a load field by
  86      * the loaded value).
  87      */
  88     ValueNode getAlias(ValueNode value);
  89 
  90     /**
  91      * Sets the entry (field or array element) with the given index in the virtualized object.
  92      *
  93      * @param index the index to be set.
  94      * @param value the new value for the given index.
  95      * @param accessKind the kind of the store which might be different than
  96      *            {@link VirtualObjectNode#entryKind(int)}.
  97      * @return true if the operation was permitted
  98      */
  99     boolean setVirtualEntry(VirtualObjectNode virtualObject, int index, ValueNode value, JavaKind accessKind, long offset);
 100 
 101     default void setVirtualEntry(VirtualObjectNode virtualObject, int index, ValueNode value) {
 102         if (!setVirtualEntry(virtualObject, index, value, null, 0)) {
 103             throw new GraalError("unexpected failure when updating virtual entry");
 104         }
 105     }
 106 
 107     ValueNode getEntry(VirtualObjectNode virtualObject, int index);
 108 
 109     void addLock(VirtualObjectNode virtualObject, MonitorIdNode monitorId);
 110 
 111     MonitorIdNode removeLock(VirtualObjectNode virtualObject);
 112 
 113     void setEnsureVirtualized(VirtualObjectNode virtualObject, boolean ensureVirtualized);
 114 
 115     boolean getEnsureVirtualized(VirtualObjectNode virtualObject);
 116 
 117     // operations on the current node
 118 
 119     /**
 120      * Deletes the current node and replaces it with the given virtualized object.
 121      *
 122      * @param virtualObject the virtualized object that should replace the current node.
 123      */
 124     void replaceWithVirtual(VirtualObjectNode virtualObject);
 125 


< prev index next >