提交 5a277f2d 编写于 作者: M mgronlun

8227011: Starting a JFR recording in response to JVMTI VMInit and / or Java...

8227011: Starting a JFR recording in response to JVMTI VMInit and / or Java agent premain corrupts memory
Reviewed-by: egahlin, rwestberg
上级 2a4aa503
...@@ -189,9 +189,6 @@ bool JfrRecorder::on_vm_start() { ...@@ -189,9 +189,6 @@ bool JfrRecorder::on_vm_start() {
if (!validate_recording_options(thread)) { if (!validate_recording_options(thread)) {
return false; return false;
} }
if (!JfrJavaEventWriter::initialize()) {
return false;
}
if (!JfrOptionSet::configure(thread)) { if (!JfrOptionSet::configure(thread)) {
return false; return false;
} }
...@@ -235,6 +232,9 @@ bool JfrRecorder::create_components() { ...@@ -235,6 +232,9 @@ bool JfrRecorder::create_components() {
ResourceMark rm; ResourceMark rm;
HandleMark hm; HandleMark hm;
if (!create_java_event_writer()) {
return false;
}
if (!create_jvmti_agent()) { if (!create_jvmti_agent()) {
return false; return false;
} }
...@@ -276,6 +276,10 @@ static JfrStringPool* _stringpool = NULL; ...@@ -276,6 +276,10 @@ static JfrStringPool* _stringpool = NULL;
static JfrOSInterface* _os_interface = NULL; static JfrOSInterface* _os_interface = NULL;
static JfrThreadSampling* _thread_sampling = NULL; static JfrThreadSampling* _thread_sampling = NULL;
bool JfrRecorder::create_java_event_writer() {
return JfrJavaEventWriter::initialize();
}
bool JfrRecorder::create_jvmti_agent() { bool JfrRecorder::create_jvmti_agent() {
return JfrOptionSet::allow_retransforms() ? JfrJvmtiAgent::create() : true; return JfrOptionSet::allow_retransforms() ? JfrJvmtiAgent::create() : true;
} }
......
...@@ -42,6 +42,7 @@ class JfrRecorder : public JfrCHeapObj { ...@@ -42,6 +42,7 @@ class JfrRecorder : public JfrCHeapObj {
static bool create_checkpoint_manager(); static bool create_checkpoint_manager();
static bool create_chunk_repository(); static bool create_chunk_repository();
static bool create_java_event_writer();
static bool create_jvmti_agent(); static bool create_jvmti_agent();
static bool create_os_interface(); static bool create_os_interface();
static bool create_post_box(); static bool create_post_box();
......
...@@ -142,8 +142,7 @@ bool JfrJavaEventWriter::has_required_classes(TRAPS) { ...@@ -142,8 +142,7 @@ bool JfrJavaEventWriter::has_required_classes(TRAPS) {
bool JfrJavaEventWriter::initialize() { bool JfrJavaEventWriter::initialize() {
static bool initialized = false; static bool initialized = false;
if (!initialized) { if (!initialized) {
Thread* thread = Thread::current(); initialized = setup_event_writer_offsets(Thread::current());
initialized = setup_event_writer_offsets(thread);
} }
return initialized; return initialized;
} }
...@@ -162,6 +161,7 @@ jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, Ja ...@@ -162,6 +161,7 @@ jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, Ja
// large enough to accommodate the "requested size". // large enough to accommodate the "requested size".
const bool is_valid = buffer->free_size() >= (size_t)(used + requested); const bool is_valid = buffer->free_size() >= (size_t)(used + requested);
u1* const new_current_position = is_valid ? buffer->pos() + used : buffer->pos(); 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(start_pos_offset, (jlong)buffer->pos());
w->long_field_put(current_pos_offset, (jlong)new_current_position); w->long_field_put(current_pos_offset, (jlong)new_current_position);
// only update java writer if underlying memory changed // only update java writer if underlying memory changed
......
...@@ -33,14 +33,15 @@ class Thread; ...@@ -33,14 +33,15 @@ class Thread;
class JfrJavaEventWriter : AllStatic { class JfrJavaEventWriter : AllStatic {
friend class JfrCheckpointThreadClosure; friend class JfrCheckpointThreadClosure;
friend class JfrJavaEventWriterNotifyOperation;
friend class JfrJavaEventWriterNotificationClosure; friend class JfrJavaEventWriterNotificationClosure;
friend class JfrJavaEventWriterNotifyOperation;
friend class JfrRecorder;
private: private:
static bool initialize();
static void notify(JavaThread* jt); static void notify(JavaThread* jt);
public: public:
static bool has_required_classes(TRAPS); static bool has_required_classes(TRAPS);
static bool initialize();
static void notify(); static void notify();
static jobject event_writer(Thread* t); static jobject event_writer(Thread* t);
static jobject new_event_writer(TRAPS); static jobject new_event_writer(TRAPS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册