aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/opto/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/vm/opto/compile.cpp')
-rw-r--r--src/share/vm/opto/compile.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/share/vm/opto/compile.cpp b/src/share/vm/opto/compile.cpp
index 4b8048386..568af91f1 100644
--- a/src/share/vm/opto/compile.cpp
+++ b/src/share/vm/opto/compile.cpp
@@ -2899,6 +2899,13 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) {
}
}
break;
+ case Op_MemBarStoreStore:
+ // Break the link with AllocateNode: it is no longer useful and
+ // confuses register allocation.
+ if (n->req() > MemBarNode::Precedent) {
+ n->set_req(MemBarNode::Precedent, top());
+ }
+ break;
default:
assert( !n->is_Call(), "" );
assert( !n->is_Mem(), "" );
@@ -3669,3 +3676,38 @@ void Compile::add_expensive_node(Node * n) {
n->set_req(0, NULL);
}
}
+
+// Auxiliary method to support randomized stressing/fuzzing.
+//
+// This method can be called the arbitrary number of times, with current count
+// as the argument. The logic allows selecting a single candidate from the
+// running list of candidates as follows:
+// int count = 0;
+// Cand* selected = null;
+// while(cand = cand->next()) {
+// if (randomized_select(++count)) {
+// selected = cand;
+// }
+// }
+//
+// Including count equalizes the chances any candidate is "selected".
+// This is useful when we don't have the complete list of candidates to choose
+// from uniformly. In this case, we need to adjust the randomicity of the
+// selection, or else we will end up biasing the selection towards the latter
+// candidates.
+//
+// Quick back-envelope calculation shows that for the list of n candidates
+// the equal probability for the candidate to persist as "best" can be
+// achieved by replacing it with "next" k-th candidate with the probability
+// of 1/k. It can be easily shown that by the end of the run, the
+// probability for any candidate is converged to 1/n, thus giving the
+// uniform distribution among all the candidates.
+//
+// We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large.
+#define RANDOMIZED_DOMAIN_POW 29
+#define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW)
+#define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
+bool Compile::randomized_select(int count) {
+ assert(count > 0, "only positive");
+ return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
+}