diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index 74074063bad..a25449cf655 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -772,18 +772,8 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, if (failing()) return; NOT_PRODUCT( verify_graph_edges(); ) - // If any phase is randomized for stress testing, seed random number - // generation and log the seed for repeatability. if (StressLCM || StressGCM || StressIGVN || StressCCP) { - if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && directive->RepeatCompilationOption)) { - _stress_seed = static_cast(Ticks::now().nanoseconds()); - FLAG_SET_ERGO(StressSeed, _stress_seed); - } else { - _stress_seed = StressSeed; - } - if (_log != nullptr) { - _log->elem("stress_test seed='%u'", _stress_seed); - } + initialize_stress_seed(directive); } // Now optimize @@ -917,6 +907,10 @@ Compile::Compile( ciEnv* ci_env, Init(/*AliasLevel=*/ 0); init_tf((*generator)()); + if (StressLCM || StressGCM) { + initialize_stress_seed(directive); + } + { // The following is a dummy for the sake of GraphKit::gen_stub Unique_Node_List for_igvn(comp_arena()); @@ -4660,6 +4654,18 @@ void Compile::remove_speculative_types(PhaseIterGVN &igvn) { // Auxiliary methods to support randomized stressing/fuzzing. +void Compile::initialize_stress_seed(const DirectiveSet* directive) { + if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && directive->RepeatCompilationOption)) { + _stress_seed = static_cast(Ticks::now().nanoseconds()); + FLAG_SET_ERGO(StressSeed, _stress_seed); + } else { + _stress_seed = StressSeed; + } + if (_log != nullptr) { + _log->elem("stress_test seed='%u'", _stress_seed); + } +} + int Compile::random() { _stress_seed = os::next_random(_stress_seed); return static_cast(_stress_seed); diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index cae1cb27c27..8b2c4d96f69 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -1175,6 +1175,9 @@ class Compile : public Phase { int random(); bool randomized_select(int count); + // seed random number generation and log the seed for repeatability. + void initialize_stress_seed(const DirectiveSet* directive); + // supporting clone_map CloneMap& clone_map(); void set_clone_map(Dict* d);