diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index d5ed95187a8..25c7ced8aeb 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -844,19 +844,9 @@ 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 || StressIncrementalInlining || StressMacroExpansion) { - 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 @@ -983,6 +973,11 @@ Compile::Compile( ciEnv* ci_env, _igvn_worklist = new (comp_arena()) Unique_Node_List(comp_arena()); _types = new (comp_arena()) Type_Array(comp_arena()); _node_hash = new (comp_arena()) NodeHash(comp_arena(), 255); + + if (StressLCM || StressGCM) { + initialize_stress_seed(directive); + } + { PhaseGVN gvn; set_initial_gvn(&gvn); // not significant, but GraphKit guys use it pervasively @@ -5068,6 +5063,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 df93b388daa..e1d9b61f7f8 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -1278,6 +1278,9 @@ private: 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);