1.1 --- a/src/share/vm/jfr/recorder/jfrRecorder.cpp Sun Jun 07 18:57:54 2020 +0100 1.2 +++ b/src/share/vm/jfr/recorder/jfrRecorder.cpp Fri Jun 12 02:59:56 2020 +0100 1.3 @@ -44,6 +44,9 @@ 1.4 #include "runtime/handles.inline.hpp" 1.5 #include "runtime/globals_extension.hpp" 1.6 #include "utilities/growableArray.hpp" 1.7 +#ifdef ASSERT 1.8 +#include "prims/jvmtiEnvBase.hpp" 1.9 +#endif 1.10 1.11 bool JfrRecorder::_shutting_down = false; 1.12 1.13 @@ -57,7 +60,9 @@ 1.14 1.15 static bool enable() { 1.16 assert(!_enabled, "invariant"); 1.17 - FLAG_SET_MGMT(bool, FlightRecorder, true); 1.18 + if (!FlightRecorder) { 1.19 + FLAG_SET_MGMT(bool, FlightRecorder, true); 1.20 + } 1.21 _enabled = FlightRecorder; 1.22 assert(_enabled, "invariant"); 1.23 return _enabled; 1.24 @@ -67,7 +72,7 @@ 1.25 return _enabled; 1.26 } 1.27 1.28 -bool JfrRecorder::on_vm_init() { 1.29 +bool JfrRecorder::on_create_vm_1() { 1.30 if (!is_disabled()) { 1.31 if (FlightRecorder || StartFlightRecording != NULL) { 1.32 enable(); 1.33 @@ -92,7 +97,7 @@ 1.34 1.35 static void teardown_startup_support() { 1.36 release_recordings(); 1.37 - JfrOptionSet::release_startup_recording_options(); 1.38 + JfrOptionSet::release_start_flight_recording_options(); 1.39 } 1.40 1.41 // Parsing options here to detect errors as soon as possible 1.42 @@ -110,7 +115,7 @@ 1.43 } 1.44 1.45 static bool validate_recording_options(TRAPS) { 1.46 - const GrowableArray<const char*>* options = JfrOptionSet::startup_recording_options(); 1.47 + const GrowableArray<const char*>* options = JfrOptionSet::start_flight_recording_options(); 1.48 if (options == NULL) { 1.49 return true; 1.50 } 1.51 @@ -143,7 +148,7 @@ 1.52 return true; 1.53 } 1.54 1.55 -static bool launch_recordings(TRAPS) { 1.56 +static bool launch_command_line_recordings(TRAPS) { 1.57 bool result = true; 1.58 if (dcmd_recordings_array != NULL) { 1.59 const int length = dcmd_recordings_array->length(); 1.60 @@ -161,7 +166,7 @@ 1.61 1.62 static bool is_cds_dump_requested() { 1.63 // we will not be able to launch recordings if a cds dump is being requested 1.64 - if (DumpSharedSpaces && (JfrOptionSet::startup_recording_options() != NULL)) { 1.65 + if (DumpSharedSpaces && (JfrOptionSet::start_flight_recording_options() != NULL)) { 1.66 warning("JFR will be disabled during CDS dumping"); 1.67 teardown_startup_support(); 1.68 return true; 1.69 @@ -169,7 +174,7 @@ 1.70 return false; 1.71 } 1.72 1.73 -bool JfrRecorder::on_vm_start() { 1.74 +bool JfrRecorder::on_create_vm_2() { 1.75 if (is_cds_dump_requested()) { 1.76 return true; 1.77 } 1.78 @@ -196,9 +201,13 @@ 1.79 if (!is_enabled()) { 1.80 return true; 1.81 } 1.82 + return true; 1.83 +} 1.84 1.85 - return launch_recordings(thread); 1.86 -} 1.87 +bool JfrRecorder::on_create_vm_3() { 1.88 + assert(JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE, "invalid init sequence"); 1.89 + return launch_command_line_recordings(Thread::current()); 1.90 + } 1.91 1.92 static bool _created = false; 1.93 1.94 @@ -266,7 +275,6 @@ 1.95 } 1.96 1.97 // subsystems 1.98 -static JfrJvmtiAgent* _jvmti_agent = NULL; 1.99 static JfrPostBox* _post_box = NULL; 1.100 static JfrStorage* _storage = NULL; 1.101 static JfrCheckpointManager* _checkpoint_manager = NULL;