src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/ReplaceConstantNodesPhase.java
author iveresov
Fri, 02 Feb 2018 17:28:17 -0800
changeset 48861 47f19ff9903c
parent 47667 390896759aa2
child 49873 26ebfe8ce852
permissions -rw-r--r--
8194819: Update Graal Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     1
/*
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     4
 *
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     8
 *
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    13
 * accompanied this code).
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    14
 *
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    18
 *
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    21
 * questions.
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    22
 */
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    23
package org.graalvm.compiler.hotspot.phases.aot;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    24
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    25
import static org.graalvm.compiler.core.common.cfg.AbstractControlFlowGraph.strictlyDominates;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    26
import static org.graalvm.compiler.hotspot.nodes.aot.LoadMethodCountersNode.getLoadMethodCountersNodes;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    27
import static org.graalvm.compiler.nodes.ConstantNode.getConstantNodes;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    28
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    29
import java.util.HashSet;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    30
import java.util.List;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    31
48861
47f19ff9903c 8194819: Update Graal
iveresov
parents: 47667
diff changeset
    32
import org.graalvm.collections.EconomicMap;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    33
import org.graalvm.compiler.core.common.cfg.BlockMap;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    34
import org.graalvm.compiler.core.common.type.ObjectStamp;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    35
import org.graalvm.compiler.core.common.type.Stamp;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    36
import org.graalvm.compiler.core.common.type.StampFactory;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    37
import org.graalvm.compiler.debug.GraalError;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    38
import org.graalvm.compiler.graph.Node;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    39
import org.graalvm.compiler.graph.NodeMap;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    40
import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    41
import org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    42
import org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyFixedNode;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    43
import org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyNode;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    44
import org.graalvm.compiler.hotspot.nodes.aot.LoadMethodCountersNode;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    45
import org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode;
47667
390896759aa2 8187438: Update Graal
dlong
parents: 47216
diff changeset
    46
import org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    47
import org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    48
import org.graalvm.compiler.nodes.AbstractBeginNode;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    49
import org.graalvm.compiler.nodes.AbstractMergeNode;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    50
import org.graalvm.compiler.nodes.ConstantNode;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    51
import org.graalvm.compiler.nodes.FixedNode;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    52
import org.graalvm.compiler.nodes.FixedWithNextNode;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    53
import org.graalvm.compiler.nodes.FrameState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    54
import org.graalvm.compiler.nodes.LoopBeginNode;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    55
import org.graalvm.compiler.nodes.LoopExitNode;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    56
import org.graalvm.compiler.nodes.StateSplit;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    57
import org.graalvm.compiler.nodes.StructuredGraph;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    58
import org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    59
import org.graalvm.compiler.nodes.ValueNode;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    60
import org.graalvm.compiler.nodes.calc.FloatingNode;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    61
import org.graalvm.compiler.nodes.cfg.Block;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    62
import org.graalvm.compiler.phases.BasePhase;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    63
import org.graalvm.compiler.phases.graph.ReentrantNodeIterator;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    64
import org.graalvm.compiler.phases.graph.ReentrantNodeIterator.NodeIteratorClosure;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    65
import org.graalvm.compiler.phases.schedule.SchedulePhase;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    66
import org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    67
import org.graalvm.compiler.phases.tiers.PhaseContext;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    68
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    69
import jdk.vm.ci.code.BytecodeFrame;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    70
import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    71
import jdk.vm.ci.hotspot.HotSpotObjectConstant;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    72
import jdk.vm.ci.hotspot.HotSpotResolvedJavaType;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    73
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    74
import jdk.vm.ci.meta.Constant;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    75
import jdk.vm.ci.meta.ConstantReflectionProvider;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    76
import jdk.vm.ci.meta.ResolvedJavaType;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
    77
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    78
public class ReplaceConstantNodesPhase extends BasePhase<PhaseContext> {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    79
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    80
    private static final HashSet<Class<?>> builtIns = new HashSet<>();
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
    81
    private final boolean verifyFingerprints;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    82
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    83
    static {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    84
        builtIns.add(Boolean.class);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    85
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    86
        Class<?> characterCacheClass = Character.class.getDeclaredClasses()[0];
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    87
        assert "java.lang.Character$CharacterCache".equals(characterCacheClass.getName());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    88
        builtIns.add(characterCacheClass);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    89
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    90
        Class<?> byteCacheClass = Byte.class.getDeclaredClasses()[0];
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    91
        assert "java.lang.Byte$ByteCache".equals(byteCacheClass.getName());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    92
        builtIns.add(byteCacheClass);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    93
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    94
        Class<?> shortCacheClass = Short.class.getDeclaredClasses()[0];
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    95
        assert "java.lang.Short$ShortCache".equals(shortCacheClass.getName());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    96
        builtIns.add(shortCacheClass);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    97
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    98
        Class<?> integerCacheClass = Integer.class.getDeclaredClasses()[0];
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    99
        assert "java.lang.Integer$IntegerCache".equals(integerCacheClass.getName());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   100
        builtIns.add(integerCacheClass);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   101
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   102
        Class<?> longCacheClass = Long.class.getDeclaredClasses()[0];
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   103
        assert "java.lang.Long$LongCache".equals(longCacheClass.getName());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   104
        builtIns.add(longCacheClass);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   105
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   106
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   107
    private static boolean isReplacementNode(Node n) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   108
        // @formatter:off
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   109
        return n instanceof LoadConstantIndirectlyNode      ||
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   110
               n instanceof LoadConstantIndirectlyFixedNode ||
47667
390896759aa2 8187438: Update Graal
dlong
parents: 47216
diff changeset
   111
               n instanceof ResolveDynamicConstantNode      ||
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   112
               n instanceof ResolveConstantNode             ||
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   113
               n instanceof InitializeKlassNode;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   114
        // @formatter:on
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   115
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   116
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   117
    private static boolean anyUsagesNeedReplacement(ConstantNode node) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   118
        return node.usages().filter(n -> !isReplacementNode(n)).isNotEmpty();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   119
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   120
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   121
    private static boolean anyUsagesNeedReplacement(LoadMethodCountersNode node) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   122
        return node.usages().filter(n -> !(n instanceof ResolveMethodAndLoadCountersNode)).isNotEmpty();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   123
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   124
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   125
    private static boolean checkForBadFingerprint(HotSpotResolvedJavaType type) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   126
        if (type.isArray()) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   127
            if (type.getElementalType().isPrimitive()) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   128
                return false;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   129
            }
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   130
            return ((HotSpotResolvedObjectType) (type.getElementalType())).getFingerprint() == 0;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   131
        }
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   132
        return ((HotSpotResolvedObjectType) type).getFingerprint() == 0;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   133
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   134
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   135
    /**
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   136
     * Insert the replacement node into the graph. We may need to insert it into a place different
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   137
     * than the original {@link FloatingNode} since we need to make sure that replacement will have
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   138
     * a valid state assigned.
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   139
     *
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   140
     * @param graph
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   141
     * @param stateMapper
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   142
     * @param node
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   143
     * @param replacement
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   144
     */
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   145
    private static void insertReplacement(StructuredGraph graph, FrameStateMapperClosure stateMapper, FloatingNode node, FixedWithNextNode replacement) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   146
        FixedWithNextNode insertionPoint = findInsertionPoint(graph, stateMapper, node);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   147
        graph.addAfterFixed(insertionPoint, replacement);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   148
        stateMapper.addState(replacement, stateMapper.getState(insertionPoint));
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   149
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   150
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   151
    /**
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   152
     * Find a good place to insert a stateful fixed node that is above the given node. A good
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   153
     * insertion point should have a valid FrameState reaching it.
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   154
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   155
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   156
     * @param stateMapper
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   157
     * @param node start search from this node up
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   158
     * @return an insertion point
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   159
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   160
    private static FixedWithNextNode findInsertionPoint(StructuredGraph graph, FrameStateMapperClosure stateMapper, FloatingNode node) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   161
        FixedWithNextNode fixed = findFixedBeforeFloating(graph, node);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   162
        FixedWithNextNode result = findFixedWithValidState(graph, stateMapper, fixed);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   163
        return result;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   164
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   165
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   166
    /**
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   167
     * Find the first {@link FixedWithNextNode} that is currently scheduled before the given
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   168
     * floating node.
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   169
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   170
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   171
     * @param node start search from this node up
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   172
     * @return the first {@link FixedWithNextNode}
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   173
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   174
    private static FixedWithNextNode findFixedBeforeFloating(StructuredGraph graph, FloatingNode node) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   175
        ScheduleResult schedule = graph.getLastSchedule();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   176
        NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   177
        Block block = nodeToBlock.get(node);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   178
        BlockMap<List<Node>> blockToNodes = schedule.getBlockToNodesMap();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   179
        FixedWithNextNode result = null;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   180
        for (Node n : blockToNodes.get(block)) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   181
            if (n.equals(node)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   182
                break;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   183
            }
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   184
            if (n instanceof FixedWithNextNode) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   185
                result = (FixedWithNextNode) n;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   186
            }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   187
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   188
        assert result != null;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   189
        return result;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   190
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   191
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   192
    /**
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   193
     * Find first dominating {@link FixedWithNextNode} that has a valid state reaching it starting
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   194
     * from the given node.
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   195
     *
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   196
     * @param graph
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   197
     * @param stateMapper
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   198
     * @param node
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   199
     * @return {@link FixedWithNextNode} that we can use as an insertion point
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   200
     */
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   201
    private static FixedWithNextNode findFixedWithValidState(StructuredGraph graph, FrameStateMapperClosure stateMapper, FixedWithNextNode node) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   202
        ScheduleResult schedule = graph.getLastSchedule();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   203
        NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   204
        Block block = nodeToBlock.get(node);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   205
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   206
        Node n = node;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   207
        do {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   208
            if (isFixedWithValidState(stateMapper, n)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   209
                return (FixedWithNextNode) n;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   210
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   211
            while (n != block.getBeginNode()) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   212
                n = n.predecessor();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   213
                if (isFixedWithValidState(stateMapper, n)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   214
                    return (FixedWithNextNode) n;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   215
                }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   216
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   217
            block = block.getDominator();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   218
            if (block != null) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   219
                n = block.getEndNode();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   220
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   221
        } while (block != null);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   222
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   223
        return graph.start();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   224
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   225
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   226
    private static boolean isFixedWithValidState(FrameStateMapperClosure stateMapper, Node n) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   227
        if (n instanceof FixedWithNextNode) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   228
            FixedWithNextNode fixed = (FixedWithNextNode) n;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   229
            assert stateMapper.getState(fixed) != null;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   230
            if (!BytecodeFrame.isPlaceholderBci(stateMapper.getState(fixed).bci)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   231
                return true;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   232
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   233
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   234
        return false;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   235
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   236
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   237
    /**
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   238
     * Compute frame states for all fixed nodes in the graph.
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   239
     */
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   240
    private static class FrameStateMapperClosure extends NodeIteratorClosure<FrameState> {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   241
        private NodeMap<FrameState> reachingStates;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   242
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   243
        @Override
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   244
        protected FrameState processNode(FixedNode node, FrameState previousState) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   245
            FrameState currentState = previousState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   246
            if (node instanceof StateSplit) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   247
                StateSplit stateSplit = (StateSplit) node;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   248
                FrameState stateAfter = stateSplit.stateAfter();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   249
                if (stateAfter != null) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   250
                    currentState = stateAfter;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   251
                }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   252
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   253
            reachingStates.put(node, currentState);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   254
            return currentState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   255
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   256
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   257
        @Override
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   258
        protected FrameState merge(AbstractMergeNode merge, List<FrameState> states) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   259
            FrameState singleFrameState = singleFrameState(states);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   260
            FrameState currentState = singleFrameState == null ? merge.stateAfter() : singleFrameState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   261
            reachingStates.put(merge, currentState);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   262
            return currentState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   263
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   264
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   265
        @Override
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   266
        protected FrameState afterSplit(AbstractBeginNode node, FrameState oldState) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   267
            return oldState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   268
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   269
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   270
        @Override
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   271
        protected EconomicMap<LoopExitNode, FrameState> processLoop(LoopBeginNode loop, FrameState initialState) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   272
            return ReentrantNodeIterator.processLoop(this, loop, initialState).exitStates;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   273
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   274
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   275
        private static FrameState singleFrameState(List<FrameState> states) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   276
            FrameState singleState = states.get(0);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   277
            for (int i = 1; i < states.size(); ++i) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   278
                if (states.get(i) != singleState) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   279
                    return null;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   280
                }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   281
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   282
            return singleState;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   283
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   284
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   285
        FrameStateMapperClosure(StructuredGraph graph) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   286
            reachingStates = new NodeMap<>(graph);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   287
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   288
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   289
        public FrameState getState(Node n) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   290
            return reachingStates.get(n);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   291
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   292
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   293
        public void addState(Node n, FrameState s) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   294
            reachingStates.setAndGrow(n, s);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   295
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   296
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   297
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   298
    /**
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   299
     * Try to find dominating node doing the resolution that can be reused.
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   300
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   301
     * @param graph
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   302
     * @param node {@link ConstantNode} containing a {@link HotSpotResolvedJavaType} that needs
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   303
     *            resolution.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   304
     */
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   305
    private static void tryToReplaceWithExisting(StructuredGraph graph, ConstantNode node) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   306
        ScheduleResult schedule = graph.getLastSchedule();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   307
        NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   308
        BlockMap<List<Node>> blockToNodes = schedule.getBlockToNodesMap();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   309
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   310
        EconomicMap<Block, Node> blockToExisting = EconomicMap.create();
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   311
        for (Node n : node.usages().filter(n -> isReplacementNode(n))) {
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   312
            blockToExisting.put(nodeToBlock.get(n), n);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   313
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   314
        for (Node use : node.usages().filter(n -> !isReplacementNode(n)).snapshot()) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   315
            boolean replaced = false;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   316
            Block b = nodeToBlock.get(use);
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   317
            Node e = blockToExisting.get(b);
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   318
            if (e != null) {
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   319
                // There is an initialization or resolution in the same block as the use, look if
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   320
                // the use is scheduled after it.
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   321
                for (Node n : blockToNodes.get(b)) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   322
                    if (n.equals(use)) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   323
                        // Usage is before initialization, can't use it
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   324
                        break;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   325
                    }
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   326
                    if (n.equals(e)) {
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   327
                        use.replaceFirstInput(node, e);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   328
                        replaced = true;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   329
                        break;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   330
                    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   331
                }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   332
            }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   333
            if (!replaced) {
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   334
                // Look for dominating blocks that have existing nodes
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   335
                for (Block d : blockToExisting.getKeys()) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   336
                    if (strictlyDominates(d, b)) {
46566
231c681fa946 8182883: Update Graal
iveresov
parents: 46536
diff changeset
   337
                        use.replaceFirstInput(node, blockToExisting.get(d));
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   338
                        break;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   339
                    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   340
                }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   341
            }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   342
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   343
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   344
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   345
    /**
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   346
     * Replace the uses of a constant with either {@link LoadConstantIndirectlyNode} or
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   347
     * {@link ResolveConstantNode}.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   348
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   349
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   350
     * @param stateMapper
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   351
     * @param node {@link ConstantNode} containing a {@link HotSpotResolvedJavaType} that needs
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   352
     *            resolution.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   353
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   354
    private static void replaceWithResolution(StructuredGraph graph, FrameStateMapperClosure stateMapper, ConstantNode node) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   355
        HotSpotMetaspaceConstant metaspaceConstant = (HotSpotMetaspaceConstant) node.asConstant();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   356
        HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) metaspaceConstant.asResolvedJavaType();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   357
        ResolvedJavaType topMethodHolder = graph.method().getDeclaringClass();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   358
        ValueNode replacement;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   359
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   360
        if (type.isArray() && type.getComponentType().isPrimitive()) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   361
            // Special case for primitive arrays. The AOT runtime pre-resolves them, so we may
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   362
            // omit the resolution call.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   363
            replacement = graph.addOrUnique(new LoadConstantIndirectlyNode(node));
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   364
        } else if (type.equals(topMethodHolder) || (type.isAssignableFrom(topMethodHolder) && !type.isInterface())) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   365
            // If it's a supertype of or the same class that declares the top method, we are
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   366
            // guaranteed to have it resolved already. If it's an interface, we just test for
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   367
            // equality.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   368
            replacement = graph.addOrUnique(new LoadConstantIndirectlyNode(node));
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   369
        } else {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   370
            FixedWithNextNode fixedReplacement;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   371
            if (builtIns.contains(type.mirror())) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   372
                // Special case of klass constants that come from {@link BoxingSnippets}.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   373
                fixedReplacement = graph.add(new ResolveConstantNode(node, HotSpotConstantLoadAction.INITIALIZE));
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   374
            } else {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   375
                fixedReplacement = graph.add(new ResolveConstantNode(node));
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   376
            }
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   377
            insertReplacement(graph, stateMapper, node, fixedReplacement);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   378
            replacement = fixedReplacement;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   379
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   380
        node.replaceAtUsages(replacement, n -> !isReplacementNode(n));
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   381
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   382
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   383
    /**
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   384
     * Replace {@link ConstantNode} containing a {@link HotSpotResolvedJavaType} with indirection.
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   385
     *
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   386
     * @param graph
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   387
     * @param stateMapper
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   388
     * @param node {@link ConstantNode} containing a {@link HotSpotResolvedJavaType} that needs
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   389
     *            resolution.
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   390
     */
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   391
    private void handleHotSpotMetaspaceConstant(StructuredGraph graph, FrameStateMapperClosure stateMapper, ConstantNode node) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   392
        HotSpotMetaspaceConstant metaspaceConstant = (HotSpotMetaspaceConstant) node.asConstant();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   393
        HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) metaspaceConstant.asResolvedJavaType();
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   394
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   395
        if (type != null) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   396
            if (verifyFingerprints && checkForBadFingerprint(type)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   397
                throw new GraalError("Type with bad fingerprint: " + type);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   398
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   399
            assert !metaspaceConstant.isCompressed() : "No support for replacing compressed metaspace constants";
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   400
            tryToReplaceWithExisting(graph, node);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   401
            if (anyUsagesNeedReplacement(node)) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   402
                replaceWithResolution(graph, stateMapper, node);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   403
            }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   404
        } else {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   405
            throw new GraalError("Unsupported metaspace constant type: " + type);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   406
        }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   407
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   408
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   409
    /**
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   410
     * Replace an object constant with an indirect load {@link ResolveConstantNode}. Currently we
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   411
     * support only strings.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   412
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   413
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   414
     * @param stateMapper
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   415
     * @param node {@link ConstantNode} containing a {@link HotSpotObjectConstant} that needs
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   416
     *            resolution.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   417
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   418
    private static void handleHotSpotObjectConstant(StructuredGraph graph, FrameStateMapperClosure stateMapper, ConstantNode node) {
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   419
        HotSpotObjectConstant constant = (HotSpotObjectConstant) node.asJavaConstant();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   420
        HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) constant.getType();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   421
        if (type.mirror().equals(String.class)) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   422
            assert !constant.isCompressed() : "No support for replacing compressed oop constants";
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   423
            FixedWithNextNode replacement = graph.add(new ResolveConstantNode(node));
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   424
            insertReplacement(graph, stateMapper, node, replacement);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   425
            node.replaceAtUsages(replacement, n -> !(n instanceof ResolveConstantNode));
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   426
        } else {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   427
            throw new GraalError("Unsupported object constant type: " + type);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   428
        }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   429
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   430
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   431
    /**
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   432
     * Replace {@link LoadMethodCountersNode} with indirect load
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   433
     * {@link ResolveMethodAndLoadCountersNode}, expose a klass constant of the holder.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   434
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   435
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   436
     * @param stateMapper
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   437
     * @param node
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   438
     * @param context
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   439
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   440
    private static void handleLoadMethodCounters(StructuredGraph graph, FrameStateMapperClosure stateMapper, LoadMethodCountersNode node, PhaseContext context) {
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   441
        ResolvedJavaType type = node.getMethod().getDeclaringClass();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   442
        Stamp hubStamp = context.getStampProvider().createHubStamp((ObjectStamp) StampFactory.objectNonNull());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   443
        ConstantReflectionProvider constantReflection = context.getConstantReflection();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   444
        ConstantNode klassHint = ConstantNode.forConstant(hubStamp, constantReflection.asObjectHub(type), context.getMetaAccess(), graph);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   445
        FixedWithNextNode replacement = graph.add(new ResolveMethodAndLoadCountersNode(node.getMethod(), klassHint));
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   446
        insertReplacement(graph, stateMapper, node, replacement);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   447
        node.replaceAtUsages(replacement, n -> !(n instanceof ResolveMethodAndLoadCountersNode));
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   448
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   449
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   450
    /**
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   451
     * Replace {@link LoadMethodCountersNode} with {@link ResolveMethodAndLoadCountersNode}, expose
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   452
     * klass constants.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   453
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   454
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   455
     * @param stateMapper
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   456
     * @param context
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   457
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   458
    private static void replaceLoadMethodCounters(StructuredGraph graph, FrameStateMapperClosure stateMapper, PhaseContext context) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   459
        new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, true).apply(graph, false);
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   460
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   461
        for (LoadMethodCountersNode node : getLoadMethodCountersNodes(graph)) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   462
            if (anyUsagesNeedReplacement(node)) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   463
                handleLoadMethodCounters(graph, stateMapper, node, context);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   464
            }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   465
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   466
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   467
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   468
    /**
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   469
     * Replace object and klass constants with resolution nodes or reuse preceding initializations.
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   470
     *
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   471
     * @param graph
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   472
     * @param stateMapper
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   473
     */
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   474
    private void replaceKlassesAndObjects(StructuredGraph graph, FrameStateMapperClosure stateMapper) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   475
        new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, true).apply(graph, false);
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   476
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   477
        for (ConstantNode node : getConstantNodes(graph)) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   478
            Constant constant = node.asConstant();
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   479
            if (constant instanceof HotSpotMetaspaceConstant && anyUsagesNeedReplacement(node)) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   480
                handleHotSpotMetaspaceConstant(graph, stateMapper, node);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   481
            } else if (constant instanceof HotSpotObjectConstant && anyUsagesNeedReplacement(node)) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   482
                handleHotSpotObjectConstant(graph, stateMapper, node);
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   483
            }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   484
        }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   485
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   486
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   487
    @Override
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   488
    protected void run(StructuredGraph graph, PhaseContext context) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   489
        FrameStateMapperClosure stateMapper = new FrameStateMapperClosure(graph);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   490
        ReentrantNodeIterator.apply(stateMapper, graph.start(), null);
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   491
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   492
        // Replace LoadMethodCountersNode with ResolveMethodAndLoadCountersNode, expose klass
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   493
        // constants.
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   494
        replaceLoadMethodCounters(graph, stateMapper, context);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   495
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   496
        // Replace object and klass constants (including the ones added in the previous pass) with
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   497
        // resolution nodes.
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46566
diff changeset
   498
        replaceKlassesAndObjects(graph, stateMapper);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   499
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   500
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   501
    @Override
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   502
    public boolean checkContract() {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   503
        return false;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   504
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   505
46536
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   506
    public ReplaceConstantNodesPhase() {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   507
        this(true);
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   508
    }
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   509
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   510
    public ReplaceConstantNodesPhase(boolean verifyFingerprints) {
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   511
        this.verifyFingerprints = verifyFingerprints;
79d8dffda212 8182018: Update Graal
iveresov
parents: 43972
diff changeset
   512
    }
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   513
}