src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/FixedGuardNode.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58299 6df94ce3ab2f
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
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
/*
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 57537
diff changeset
     2
 * Copyright (c) 2011, 2019, 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
 */
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    23
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    24
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    25
package org.graalvm.compiler.nodes;
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    26
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    27
import static org.graalvm.compiler.nodeinfo.InputType.Guard;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    28
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    29
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_2;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    30
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    31
import org.graalvm.compiler.debug.DebugCloseable;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    32
import org.graalvm.compiler.graph.IterableNodeType;
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    33
import org.graalvm.compiler.graph.Node;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    34
import org.graalvm.compiler.graph.NodeClass;
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    35
import org.graalvm.compiler.graph.NodeSourcePosition;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    36
import org.graalvm.compiler.graph.spi.SimplifierTool;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    37
import org.graalvm.compiler.nodeinfo.NodeInfo;
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    38
import org.graalvm.compiler.nodes.calc.IntegerEqualsNode;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    39
import org.graalvm.compiler.nodes.spi.Lowerable;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    40
import org.graalvm.compiler.nodes.spi.LoweringTool;
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    41
import org.graalvm.compiler.nodes.spi.SwitchFoldable;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    42
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    43
import jdk.vm.ci.meta.DeoptimizationAction;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    44
import jdk.vm.ci.meta.DeoptimizationReason;
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    45
import jdk.vm.ci.meta.SpeculationLog;
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    46
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    47
@NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}", allowedUsageTypes = Guard, size = SIZE_2, cycles = CYCLES_2)
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    48
public final class FixedGuardNode extends AbstractFixedGuardNode implements Lowerable, IterableNodeType, SwitchFoldable {
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    49
    public static final NodeClass<FixedGuardNode> TYPE = NodeClass.create(FixedGuardNode.class);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    50
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    51
    public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action) {
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    52
        this(condition, deoptReason, action, SpeculationLog.NO_SPECULATION, false);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    53
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    54
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    55
    public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) {
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    56
        this(condition, deoptReason, action, SpeculationLog.NO_SPECULATION, negated);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    57
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    58
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    59
    public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated, NodeSourcePosition noDeoptSuccessorPosition) {
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    60
        this(condition, deoptReason, action, SpeculationLog.NO_SPECULATION, negated, noDeoptSuccessorPosition);
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    61
    }
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    62
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    63
    public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, SpeculationLog.Speculation speculation, boolean negated) {
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    64
        super(TYPE, condition, deoptReason, action, speculation, negated);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    65
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    66
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    67
    public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, SpeculationLog.Speculation speculation, boolean negated,
2d3e99a72541 8205824: Update Graal
never
parents: 50330
diff changeset
    68
                    NodeSourcePosition noDeoptSuccessorPosition) {
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    69
        super(TYPE, condition, deoptReason, action, speculation, negated, noDeoptSuccessorPosition);
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    70
    }
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    71
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    72
    @Override
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    73
    public void simplify(SimplifierTool tool) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    74
        super.simplify(tool);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    75
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    76
        if (getCondition() instanceof LogicConstantNode) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    77
            LogicConstantNode c = (LogicConstantNode) getCondition();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    78
            if (c.getValue() == isNegated()) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    79
                FixedNode currentNext = this.next();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    80
                if (currentNext != null) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    81
                    tool.deleteBranch(currentNext);
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
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    84
                DeoptimizeNode deopt = graph().add(new DeoptimizeNode(getAction(), getReason(), getSpeculation()));
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    85
                deopt.setStateBefore(stateBefore());
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    86
                setNext(deopt);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    87
            }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    88
            this.replaceAtUsages(null);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    89
            graph().removeFixed(this);
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    90
        } else if (getCondition() instanceof ShortCircuitOrNode) {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    91
            ShortCircuitOrNode shortCircuitOr = (ShortCircuitOrNode) getCondition();
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    92
            if (isNegated() && hasNoUsages()) {
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    93
                graph().addAfterFixed(this,
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    94
                                graph().add(new FixedGuardNode(shortCircuitOr.getY(), getReason(), getAction(), getSpeculation(), !shortCircuitOr.isYNegated(), getNoDeoptSuccessorPosition())));
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    95
                graph().replaceFixedWithFixed(this,
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
    96
                                graph().add(new FixedGuardNode(shortCircuitOr.getX(), getReason(), getAction(), getSpeculation(), !shortCircuitOr.isXNegated(), getNoDeoptSuccessorPosition())));
43972
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
        }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
    99
    }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   100
49451
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   101
    @SuppressWarnings("try")
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   102
    @Override
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   103
    public void lower(LoweringTool tool) {
49451
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   104
        try (DebugCloseable position = this.withNodeSourcePosition()) {
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   105
            if (graph().getGuardsStage().allowsFloatingGuards()) {
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   106
                if (getAction() != DeoptimizationAction.None) {
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 49451
diff changeset
   107
                    ValueNode guard = tool.createGuard(this, getCondition(), getReason(), getAction(), getSpeculation(), isNegated(), getNoDeoptSuccessorPosition()).asNode();
49451
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   108
                    this.replaceAtUsages(guard);
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   109
                    graph().removeFixed(this);
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   110
                }
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   111
            } else {
e06f9607f370 8198969: Update Graal
iveresov
parents: 48861
diff changeset
   112
                lowerToIf().lower(tool);
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   113
            }
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   114
        }
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
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   117
    @Override
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   118
    public boolean canDeoptimize() {
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   119
        return true;
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   120
    }
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   121
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   122
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   123
    public Node getNextSwitchFoldableBranch() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   124
        return next();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   125
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   126
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   127
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   128
    public boolean isInSwitch(ValueNode switchValue) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   129
        return hasNoUsages() && isNegated() && SwitchFoldable.maybeIsInSwitch(condition()) && SwitchFoldable.sameSwitchValue(condition(), switchValue);
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   130
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   131
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   132
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   133
    public void cutOffCascadeNode() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   134
        /* nop */
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   135
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   136
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   137
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   138
    public void cutOffLowestCascadeNode() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   139
        setNext(null);
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   140
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   141
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   142
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   143
    public boolean isDefaultSuccessor(AbstractBeginNode beginNode) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   144
        return beginNode.next() == next();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   145
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   146
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   147
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   148
    public AbstractBeginNode getDefault() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   149
        FixedNode defaultNode = next();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   150
        setNext(null);
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   151
        return BeginNode.begin(defaultNode);
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   152
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   153
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   154
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   155
    public ValueNode switchValue() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   156
        if (SwitchFoldable.maybeIsInSwitch(condition())) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   157
            return ((IntegerEqualsNode) condition()).getX();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   158
        }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   159
        return null;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   160
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   161
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   162
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   163
    public boolean isNonInitializedProfile() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   164
        // @formatter:off
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   165
        // Checkstyle: stop
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   166
        /*
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   167
         * These nodes can appear in non initialized cascades. Though they are technically profiled
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   168
         * nodes, their presence does not really prevent us from constructing a uniform distribution
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   169
         * for the new switch, while keeping these to probability 0. Furthermore, these can be the
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   170
         * result of the pattern:
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   171
         * if (c) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   172
         *     CompilerDirectives.transferToInterpreter();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   173
         * }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   174
         * Since we cannot differentiate this case from, say, a guard created because profiling
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   175
         * determined that the branch was never taken, and given what we saw before, we will
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   176
         * consider all fixedGuards as nodes with no profiles for switch folding purposes.
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   177
         */
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   178
        // Checkstyle: resume
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   179
        // @formatter:on
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   180
        return true;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   181
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   182
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   183
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   184
    public int intKeyAt(int i) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   185
        assert i == 0;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   186
        return ((IntegerEqualsNode) condition()).getY().asJavaConstant().asInt();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   187
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   188
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   189
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   190
    public double keyProbability(int i) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   191
        return 0;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   192
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   193
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   194
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   195
    public AbstractBeginNode keySuccessor(int i) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   196
        DeoptimizeNode deopt = new DeoptimizeNode(getAction(), getReason(), getSpeculation());
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   197
        deopt.setNodeSourcePosition(getNodeSourcePosition());
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   198
        AbstractBeginNode begin = new BeginNode();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   199
        // Link the two nodes, but do not add them to the graph yet, so we do not need to remove
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   200
        // them on an abort.
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   201
        begin.next = deopt;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   202
        return begin;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   203
    }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   204
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   205
    @Override
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   206
    public double defaultProbability() {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   207
        return 1.0d;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
   208
    }
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents:
diff changeset
   209
}