src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/PEReadEliminationClosure.java
changeset 48861 47f19ff9903c
parent 48190 25cfedf27edc
child 49873 26ebfe8ce852
equal deleted inserted replaced
48860:5bce1b7e7800 48861:47f19ff9903c
    27 
    27 
    28 import java.util.EnumMap;
    28 import java.util.EnumMap;
    29 import java.util.Iterator;
    29 import java.util.Iterator;
    30 import java.util.List;
    30 import java.util.List;
    31 
    31 
       
    32 import org.graalvm.collections.EconomicMap;
       
    33 import org.graalvm.collections.EconomicSet;
       
    34 import org.graalvm.collections.Equivalence;
       
    35 import org.graalvm.collections.MapCursor;
       
    36 import org.graalvm.collections.Pair;
    32 import org.graalvm.compiler.core.common.cfg.Loop;
    37 import org.graalvm.compiler.core.common.cfg.Loop;
    33 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
    38 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
    34 import org.graalvm.compiler.graph.Node;
    39 import org.graalvm.compiler.graph.Node;
    35 import org.graalvm.compiler.nodes.AbstractBeginNode;
    40 import org.graalvm.compiler.nodes.AbstractBeginNode;
    36 import org.graalvm.compiler.nodes.FieldLocationIdentity;
    41 import org.graalvm.compiler.nodes.FieldLocationIdentity;
    59 import org.graalvm.compiler.nodes.type.StampTool;
    64 import org.graalvm.compiler.nodes.type.StampTool;
    60 import org.graalvm.compiler.nodes.util.GraphUtil;
    65 import org.graalvm.compiler.nodes.util.GraphUtil;
    61 import org.graalvm.compiler.nodes.virtual.VirtualArrayNode;
    66 import org.graalvm.compiler.nodes.virtual.VirtualArrayNode;
    62 import org.graalvm.compiler.options.OptionValues;
    67 import org.graalvm.compiler.options.OptionValues;
    63 import org.graalvm.compiler.virtual.phases.ea.PEReadEliminationBlockState.ReadCacheEntry;
    68 import org.graalvm.compiler.virtual.phases.ea.PEReadEliminationBlockState.ReadCacheEntry;
    64 import org.graalvm.util.EconomicMap;
       
    65 import org.graalvm.util.EconomicSet;
       
    66 import org.graalvm.util.Equivalence;
       
    67 import org.graalvm.util.MapCursor;
       
    68 import org.graalvm.util.Pair;
       
    69 import org.graalvm.word.LocationIdentity;
    69 import org.graalvm.word.LocationIdentity;
    70 
    70 
    71 import jdk.vm.ci.meta.ConstantReflectionProvider;
    71 import jdk.vm.ci.meta.ConstantReflectionProvider;
    72 import jdk.vm.ci.meta.JavaConstant;
    72 import jdk.vm.ci.meta.JavaConstant;
    73 import jdk.vm.ci.meta.JavaKind;
    73 import jdk.vm.ci.meta.JavaKind;
   184             ResolvedJavaType type = StampTool.typeOrNull(load.object());
   184             ResolvedJavaType type = StampTool.typeOrNull(load.object());
   185             if (type != null && type.isArray()) {
   185             if (type != null && type.isArray()) {
   186                 JavaKind accessKind = load.accessKind();
   186                 JavaKind accessKind = load.accessKind();
   187                 JavaKind componentKind = type.getComponentType().getJavaKind();
   187                 JavaKind componentKind = type.getComponentType().getJavaKind();
   188                 long offset = load.offset().asJavaConstant().asLong();
   188                 long offset = load.offset().asJavaConstant().asLong();
   189                 int index = VirtualArrayNode.entryIndexForOffset(offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
   189                 int index = VirtualArrayNode.entryIndexForOffset(tool.getArrayOffsetProvider(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
   190                 ValueNode object = GraphUtil.unproxify(load.object());
   190                 ValueNode object = GraphUtil.unproxify(load.object());
   191                 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
   191                 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
   192                 ValueNode cachedValue = state.getReadCache(object, location, index, accessKind, this);
   192                 ValueNode cachedValue = state.getReadCache(object, location, index, accessKind, this);
   193                 assert cachedValue == null || load.stamp(NodeView.DEFAULT).isCompatible(cachedValue.stamp(NodeView.DEFAULT)) : "The RawLoadNode's stamp is not compatible with the cached value.";
   193                 assert cachedValue == null || load.stamp(NodeView.DEFAULT).isCompatible(cachedValue.stamp(NodeView.DEFAULT)) : "The RawLoadNode's stamp is not compatible with the cached value.";
   194                 if (cachedValue != null) {
   194                 if (cachedValue != null) {
   210             JavaKind componentKind = type.getComponentType().getJavaKind();
   210             JavaKind componentKind = type.getComponentType().getJavaKind();
   211             LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
   211             LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
   212             if (store.offset().isConstant()) {
   212             if (store.offset().isConstant()) {
   213                 long offset = store.offset().asJavaConstant().asLong();
   213                 long offset = store.offset().asJavaConstant().asLong();
   214                 boolean overflowAccess = isOverflowAccess(accessKind, componentKind);
   214                 boolean overflowAccess = isOverflowAccess(accessKind, componentKind);
   215                 int index = overflowAccess ? -1 : VirtualArrayNode.entryIndexForOffset(offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
   215                 int index = overflowAccess ? -1 : VirtualArrayNode.entryIndexForOffset(tool.getArrayOffsetProvider(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
   216                 return processStore(store, store.object(), location, index, accessKind, overflowAccess, store.value(), state, effects);
   216                 return processStore(store, store.object(), location, index, accessKind, overflowAccess, store.value(), state, effects);
   217             } else {
   217             } else {
   218                 processIdentity(state, location);
   218                 processIdentity(state, location);
   219             }
   219             }
   220         } else {
   220         } else {