42 #include "jfr/writers/jfrJavaEventWriter.hpp" |
42 #include "jfr/writers/jfrJavaEventWriter.hpp" |
43 #include "memory/resourceArea.hpp" |
43 #include "memory/resourceArea.hpp" |
44 #include "runtime/handles.inline.hpp" |
44 #include "runtime/handles.inline.hpp" |
45 #include "runtime/globals_extension.hpp" |
45 #include "runtime/globals_extension.hpp" |
46 #include "utilities/growableArray.hpp" |
46 #include "utilities/growableArray.hpp" |
|
47 #ifdef ASSERT |
|
48 #include "prims/jvmtiEnvBase.hpp" |
|
49 #endif |
47 |
50 |
48 bool JfrRecorder::_shutting_down = false; |
51 bool JfrRecorder::_shutting_down = false; |
49 |
52 |
50 bool JfrRecorder::is_disabled() { |
53 bool JfrRecorder::is_disabled() { |
51 // True if -XX:-FlightRecorder has been explicitly set on the |
54 // True if -XX:-FlightRecorder has been explicitly set on the |
55 |
58 |
56 static bool _enabled = false; |
59 static bool _enabled = false; |
57 |
60 |
58 static bool enable() { |
61 static bool enable() { |
59 assert(!_enabled, "invariant"); |
62 assert(!_enabled, "invariant"); |
60 FLAG_SET_MGMT(bool, FlightRecorder, true); |
63 if (!FlightRecorder) { |
|
64 FLAG_SET_MGMT(bool, FlightRecorder, true); |
|
65 } |
61 _enabled = FlightRecorder; |
66 _enabled = FlightRecorder; |
62 assert(_enabled, "invariant"); |
67 assert(_enabled, "invariant"); |
63 return _enabled; |
68 return _enabled; |
64 } |
69 } |
65 |
70 |
66 bool JfrRecorder::is_enabled() { |
71 bool JfrRecorder::is_enabled() { |
67 return _enabled; |
72 return _enabled; |
68 } |
73 } |
69 |
74 |
70 bool JfrRecorder::on_vm_init() { |
75 bool JfrRecorder::on_create_vm_1() { |
71 if (!is_disabled()) { |
76 if (!is_disabled()) { |
72 if (FlightRecorder || StartFlightRecording != NULL) { |
77 if (FlightRecorder || StartFlightRecording != NULL) { |
73 enable(); |
78 enable(); |
74 } |
79 } |
75 } |
80 } |
90 } |
95 } |
91 } |
96 } |
92 |
97 |
93 static void teardown_startup_support() { |
98 static void teardown_startup_support() { |
94 release_recordings(); |
99 release_recordings(); |
95 JfrOptionSet::release_startup_recording_options(); |
100 JfrOptionSet::release_start_flight_recording_options(); |
96 } |
101 } |
97 |
102 |
98 // Parsing options here to detect errors as soon as possible |
103 // Parsing options here to detect errors as soon as possible |
99 static bool parse_recording_options(const char* options, JfrStartFlightRecordingDCmd* dcmd_recording, TRAPS) { |
104 static bool parse_recording_options(const char* options, JfrStartFlightRecordingDCmd* dcmd_recording, TRAPS) { |
100 assert(options != NULL, "invariant"); |
105 assert(options != NULL, "invariant"); |
108 } |
113 } |
109 return true; |
114 return true; |
110 } |
115 } |
111 |
116 |
112 static bool validate_recording_options(TRAPS) { |
117 static bool validate_recording_options(TRAPS) { |
113 const GrowableArray<const char*>* options = JfrOptionSet::startup_recording_options(); |
118 const GrowableArray<const char*>* options = JfrOptionSet::start_flight_recording_options(); |
114 if (options == NULL) { |
119 if (options == NULL) { |
115 return true; |
120 return true; |
116 } |
121 } |
117 const int length = options->length(); |
122 const int length = options->length(); |
118 assert(length >= 1, "invariant"); |
123 assert(length >= 1, "invariant"); |
141 } |
146 } |
142 if (LogJFR && Verbose) tty->print_cr("Finished starting a recording"); |
147 if (LogJFR && Verbose) tty->print_cr("Finished starting a recording"); |
143 return true; |
148 return true; |
144 } |
149 } |
145 |
150 |
146 static bool launch_recordings(TRAPS) { |
151 static bool launch_command_line_recordings(TRAPS) { |
147 bool result = true; |
152 bool result = true; |
148 if (dcmd_recordings_array != NULL) { |
153 if (dcmd_recordings_array != NULL) { |
149 const int length = dcmd_recordings_array->length(); |
154 const int length = dcmd_recordings_array->length(); |
150 assert(length >= 1, "invariant"); |
155 assert(length >= 1, "invariant"); |
151 for (int i = 0; i < length; ++i) { |
156 for (int i = 0; i < length; ++i) { |
159 return result; |
164 return result; |
160 } |
165 } |
161 |
166 |
162 static bool is_cds_dump_requested() { |
167 static bool is_cds_dump_requested() { |
163 // we will not be able to launch recordings if a cds dump is being requested |
168 // we will not be able to launch recordings if a cds dump is being requested |
164 if (DumpSharedSpaces && (JfrOptionSet::startup_recording_options() != NULL)) { |
169 if (DumpSharedSpaces && (JfrOptionSet::start_flight_recording_options() != NULL)) { |
165 warning("JFR will be disabled during CDS dumping"); |
170 warning("JFR will be disabled during CDS dumping"); |
166 teardown_startup_support(); |
171 teardown_startup_support(); |
167 return true; |
172 return true; |
168 } |
173 } |
169 return false; |
174 return false; |
170 } |
175 } |
171 |
176 |
172 bool JfrRecorder::on_vm_start() { |
177 bool JfrRecorder::on_create_vm_2() { |
173 if (is_cds_dump_requested()) { |
178 if (is_cds_dump_requested()) { |
174 return true; |
179 return true; |
175 } |
180 } |
176 Thread* const thread = Thread::current(); |
181 Thread* const thread = Thread::current(); |
177 if (!JfrJavaEventWriter::has_required_classes(thread)) { |
182 if (!JfrJavaEventWriter::has_required_classes(thread)) { |
264 } |
273 } |
265 return true; |
274 return true; |
266 } |
275 } |
267 |
276 |
268 // subsystems |
277 // subsystems |
269 static JfrJvmtiAgent* _jvmti_agent = NULL; |
|
270 static JfrPostBox* _post_box = NULL; |
278 static JfrPostBox* _post_box = NULL; |
271 static JfrStorage* _storage = NULL; |
279 static JfrStorage* _storage = NULL; |
272 static JfrCheckpointManager* _checkpoint_manager = NULL; |
280 static JfrCheckpointManager* _checkpoint_manager = NULL; |
273 static JfrRepository* _repository = NULL; |
281 static JfrRepository* _repository = NULL; |
274 static JfrStackTraceRepository* _stack_trace_repository; |
282 static JfrStackTraceRepository* _stack_trace_repository; |