diff --git a/src/share/vm/jfr/recorder/jfrRecorder.cpp b/src/share/vm/jfr/recorder/jfrRecorder.cpp index e825c6d63f83a39e23c5c3a804b00c73b4554c91..9e8c0ae593849cd3a398a4fe3af46b704d66327e 100644 --- a/src/share/vm/jfr/recorder/jfrRecorder.cpp +++ b/src/share/vm/jfr/recorder/jfrRecorder.cpp @@ -189,9 +189,6 @@ bool JfrRecorder::on_vm_start() { if (!validate_recording_options(thread)) { return false; } - if (!JfrJavaEventWriter::initialize()) { - return false; - } if (!JfrOptionSet::configure(thread)) { return false; } @@ -235,6 +232,9 @@ bool JfrRecorder::create_components() { ResourceMark rm; HandleMark hm; + if (!create_java_event_writer()) { + return false; + } if (!create_jvmti_agent()) { return false; } @@ -276,6 +276,10 @@ static JfrStringPool* _stringpool = NULL; static JfrOSInterface* _os_interface = NULL; static JfrThreadSampling* _thread_sampling = NULL; +bool JfrRecorder::create_java_event_writer() { + return JfrJavaEventWriter::initialize(); +} + bool JfrRecorder::create_jvmti_agent() { return JfrOptionSet::allow_retransforms() ? JfrJvmtiAgent::create() : true; } diff --git a/src/share/vm/jfr/recorder/jfrRecorder.hpp b/src/share/vm/jfr/recorder/jfrRecorder.hpp index 42b546aa82fd41ee7f0052c3315737543caf235c..80a1265af1ba5ccb541bc667e56eb36853294b00 100644 --- a/src/share/vm/jfr/recorder/jfrRecorder.hpp +++ b/src/share/vm/jfr/recorder/jfrRecorder.hpp @@ -42,6 +42,7 @@ class JfrRecorder : public JfrCHeapObj { static bool create_checkpoint_manager(); static bool create_chunk_repository(); + static bool create_java_event_writer(); static bool create_jvmti_agent(); static bool create_os_interface(); static bool create_post_box(); diff --git a/src/share/vm/jfr/writers/jfrJavaEventWriter.cpp b/src/share/vm/jfr/writers/jfrJavaEventWriter.cpp index 3c7326c964ac88a1cedd3a8197bc2a40a3c8cb77..2237e83584807871adfed1b76dae36210f75c9ea 100644 --- a/src/share/vm/jfr/writers/jfrJavaEventWriter.cpp +++ b/src/share/vm/jfr/writers/jfrJavaEventWriter.cpp @@ -142,8 +142,7 @@ bool JfrJavaEventWriter::has_required_classes(TRAPS) { bool JfrJavaEventWriter::initialize() { static bool initialized = false; if (!initialized) { - Thread* thread = Thread::current(); - initialized = setup_event_writer_offsets(thread); + initialized = setup_event_writer_offsets(Thread::current()); } return initialized; } @@ -162,6 +161,7 @@ jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, Ja // large enough to accommodate the "requested size". const bool is_valid = buffer->free_size() >= (size_t)(used + requested); u1* const new_current_position = is_valid ? buffer->pos() + used : buffer->pos(); + assert(start_pos_offset != invalid_offset, "invariant"); w->long_field_put(start_pos_offset, (jlong)buffer->pos()); w->long_field_put(current_pos_offset, (jlong)new_current_position); // only update java writer if underlying memory changed diff --git a/src/share/vm/jfr/writers/jfrJavaEventWriter.hpp b/src/share/vm/jfr/writers/jfrJavaEventWriter.hpp index e4a97f3359e9def7a775462a45ccf32274216bcb..9e521f417a5b85f92cb668e3e1b7ece88b50c128 100644 --- a/src/share/vm/jfr/writers/jfrJavaEventWriter.hpp +++ b/src/share/vm/jfr/writers/jfrJavaEventWriter.hpp @@ -33,14 +33,15 @@ class Thread; class JfrJavaEventWriter : AllStatic { friend class JfrCheckpointThreadClosure; - friend class JfrJavaEventWriterNotifyOperation; friend class JfrJavaEventWriterNotificationClosure; + friend class JfrJavaEventWriterNotifyOperation; + friend class JfrRecorder; private: + static bool initialize(); static void notify(JavaThread* jt); public: static bool has_required_classes(TRAPS); - static bool initialize(); static void notify(); static jobject event_writer(Thread* t); static jobject new_event_writer(TRAPS);