Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java @ 11677:9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 17 Sep 2013 02:35:52 +0200 |
parents | c4703de83626 |
children | 29907e69ae8d |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes.extended; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
7265
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
25 import java.util.*; |
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
26 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
28 import com.oracle.graal.graph.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.type.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 * The {@code SwitchNode} class is the base of both lookup and table switches. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 public abstract class SwitchNode extends ControlSplitNode { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7283
diff
changeset
|
36 |
9715
badabdca0c53
fix final-ness of @Input node inputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
9467
diff
changeset
|
37 @Successor private final NodeSuccessorList<AbstractBeginNode> successors; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 @Input private ValueNode value; |
7265
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
39 private double[] keyProbabilities; |
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
40 private int[] keySuccessors; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * Constructs a new Switch. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7283
diff
changeset
|
44 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * @param value the instruction that provides the value to be switched over |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 * @param successors the list of successors of this switch |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
48 public SwitchNode(ValueNode value, AbstractBeginNode[] successors, int[] keySuccessors, double[] keyProbabilities) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
49 super(StampFactory.forVoid()); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
50 assert keySuccessors.length == keyProbabilities.length; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
51 this.successors = new NodeSuccessorList<>(this, successors); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 this.value = value; |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
53 this.keySuccessors = keySuccessors; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
54 this.keyProbabilities = keyProbabilities; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
55 assert assertProbabilities(); |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
56 } |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
57 |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
58 private boolean assertProbabilities() { |
9932
3d5fdf185a67
Bugfix concerning ComputeProbabilityClosure.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9930
diff
changeset
|
59 double total = 0; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
60 for (double d : keyProbabilities) { |
9932
3d5fdf185a67
Bugfix concerning ComputeProbabilityClosure.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9930
diff
changeset
|
61 total += d; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
62 assert d >= 0.0 : "Cannot have negative probabilities in switch node: " + d; |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
63 } |
11262
c4703de83626
Fix Switch probability if simplification leaves no non-zero probability successor
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9993
diff
changeset
|
64 assert total > 0.999 && total < 1.001 : "Total " + total; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
65 return true; |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
66 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
67 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
68 @Override |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
69 public double probability(AbstractBeginNode successor) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
70 double sum = 0; |
7705
96a596d751ab
remove successorProbabilities from SwitchNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
71 for (int i = 0; i < keySuccessors.length; i++) { |
96a596d751ab
remove successorProbabilities from SwitchNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
72 if (successors.get(keySuccessors[i]) == successor) { |
96a596d751ab
remove successorProbabilities from SwitchNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
73 sum += keyProbabilities[i]; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
74 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
75 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
76 return sum; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
77 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
78 |
9993
053b837d0d7d
Readded the pass that fixes DeoptimizeNode probabilities.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9932
diff
changeset
|
79 @Override |
053b837d0d7d
Readded the pass that fixes DeoptimizeNode probabilities.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9932
diff
changeset
|
80 public void setProbability(AbstractBeginNode successor, double value) { |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
81 double changeInProbability = 0; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
82 int nonZeroProbabilityCases = 0; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
83 for (int i = 0; i < keySuccessors.length; i++) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
84 if (successors.get(keySuccessors[i]) == successor) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
85 changeInProbability += keyProbabilities[i] - value; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
86 keyProbabilities[i] = value; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
87 } else if (keyProbabilities[i] > 0) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
88 nonZeroProbabilityCases++; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
89 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
90 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
91 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
92 if (nonZeroProbabilityCases > 0) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
93 double changePerEntry = changeInProbability / nonZeroProbabilityCases; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
94 if (changePerEntry != 0) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
95 for (int i = 0; i < keyProbabilities.length; i++) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
96 if (keyProbabilities[i] > 0) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
97 keyProbabilities[i] = keyProbabilities[i] + changePerEntry; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
98 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
99 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
100 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
101 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
102 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
103 assertProbabilities(); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
104 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9715
diff
changeset
|
105 |
7283
3964f3d4eb18
Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7265
diff
changeset
|
106 public ValueNode value() { |
3964f3d4eb18
Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7265
diff
changeset
|
107 return value; |
3964f3d4eb18
Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7265
diff
changeset
|
108 } |
3964f3d4eb18
Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7265
diff
changeset
|
109 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
110 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
111 * The number of distinct keys in this switch. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
112 */ |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
113 public abstract int keyCount(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
114 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
115 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
116 * The key at the specified position, encoded in a Constant. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
117 */ |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
118 public abstract Constant keyAt(int i); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
119 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
120 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
121 * Returns the index of the successor belonging to the key at the specified index. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
122 */ |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
123 public int keySuccessorIndex(int i) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
124 return keySuccessors[i]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
125 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
126 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
127 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
128 * Returns the successor for the key at the given index. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
129 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
130 public AbstractBeginNode keySuccessor(int i) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
131 return successors.get(keySuccessors[i]); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 /** |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
135 * Returns the probability of the key at the given index. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
136 */ |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
137 public double keyProbability(int i) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
138 return keyProbabilities[i]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
139 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
140 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
141 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
142 * Returns the index of the default (fall through) successor of this switch. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
143 */ |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
144 public int defaultSuccessorIndex() { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
145 return keySuccessors[keySuccessors.length - 1]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
146 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
147 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
148 public AbstractBeginNode blockSuccessor(int i) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
149 return successors.get(i); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
150 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
151 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
152 public void setBlockSuccessor(int i, AbstractBeginNode s) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
153 successors.set(i, s); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
154 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
155 |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
156 public int blockSuccessorCount() { |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
157 return successors.count(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
158 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
159 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
160 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
161 * Gets the successor corresponding to the default (fall through) case. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7283
diff
changeset
|
162 * |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
163 * @return the default successor |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7705
diff
changeset
|
165 public AbstractBeginNode defaultSuccessor() { |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
166 if (defaultSuccessorIndex() == -1) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
167 throw new GraalInternalError("unexpected"); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
168 } |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5711
diff
changeset
|
169 return defaultSuccessorIndex() == -1 ? null : successors.get(defaultSuccessorIndex()); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
170 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5443
diff
changeset
|
171 |
7265
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
172 @Override |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11262
diff
changeset
|
173 public void afterClone(Node other) { |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11262
diff
changeset
|
174 SwitchNode oldSwitch = (SwitchNode) other; |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11262
diff
changeset
|
175 keyProbabilities = Arrays.copyOf(oldSwitch.keyProbabilities, oldSwitch.keyProbabilities.length); |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11262
diff
changeset
|
176 keySuccessors = Arrays.copyOf(oldSwitch.keySuccessors, oldSwitch.keySuccessors.length); |
7265
32e29e5df27e
SwitchNode: avoid sharing any arrays while cloning
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7257
diff
changeset
|
177 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 } |