提交 f0edd16c 编写于 作者: D dcubed

7039447: 2/1 java profiling is broken in build 139 (garbage in function name)

Summary: The name in a deferred JVM/TI DynamicCodeGenerated event needs to be explicitly saved.
Reviewed-by: acorn, never, dsamersoff, dholmes
上级 010c5ffe
...@@ -1804,6 +1804,8 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, const jmethodID metho ...@@ -1804,6 +1804,8 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, const jmethodID metho
} }
void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) { void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) {
assert(name != NULL && name[0] != '\0', "sanity check");
JavaThread* thread = JavaThread::current(); JavaThread* thread = JavaThread::current();
// In theory everyone coming thru here is in_vm but we need to be certain // In theory everyone coming thru here is in_vm but we need to be certain
// because a callee will do a vm->native transition // because a callee will do a vm->native transition
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.hpp" #include "runtime/interfaceSupport.hpp"
#include "runtime/javaCalls.hpp" #include "runtime/javaCalls.hpp"
#include "runtime/os.hpp"
#include "runtime/serviceThread.hpp" #include "runtime/serviceThread.hpp"
#include "runtime/signature.hpp" #include "runtime/signature.hpp"
#include "runtime/vframe.hpp" #include "runtime/vframe.hpp"
...@@ -939,10 +940,15 @@ JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_unload_event( ...@@ -939,10 +940,15 @@ JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_unload_event(
nmethodLocker::lock_nmethod(nm, true /* zombie_ok */); nmethodLocker::lock_nmethod(nm, true /* zombie_ok */);
return event; return event;
} }
JvmtiDeferredEvent JvmtiDeferredEvent::dynamic_code_generated_event( JvmtiDeferredEvent JvmtiDeferredEvent::dynamic_code_generated_event(
const char* name, const void* code_begin, const void* code_end) { const char* name, const void* code_begin, const void* code_end) {
JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_DYNAMIC_CODE_GENERATED); JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_DYNAMIC_CODE_GENERATED);
event._event_data.dynamic_code_generated.name = name; // Need to make a copy of the name since we don't know how long
// the event poster will keep it around after we enqueue the
// deferred event and return. strdup() failure is handled in
// the post() routine below.
event._event_data.dynamic_code_generated.name = os::strdup(name);
event._event_data.dynamic_code_generated.code_begin = code_begin; event._event_data.dynamic_code_generated.code_begin = code_begin;
event._event_data.dynamic_code_generated.code_end = code_end; event._event_data.dynamic_code_generated.code_end = code_end;
return event; return event;
...@@ -968,12 +974,19 @@ void JvmtiDeferredEvent::post() { ...@@ -968,12 +974,19 @@ void JvmtiDeferredEvent::post() {
nmethodLocker::unlock_nmethod(nm); nmethodLocker::unlock_nmethod(nm);
break; break;
} }
case TYPE_DYNAMIC_CODE_GENERATED: case TYPE_DYNAMIC_CODE_GENERATED: {
JvmtiExport::post_dynamic_code_generated_internal( JvmtiExport::post_dynamic_code_generated_internal(
_event_data.dynamic_code_generated.name, // if strdup failed give the event a default name
(_event_data.dynamic_code_generated.name == NULL)
? "unknown_code" : _event_data.dynamic_code_generated.name,
_event_data.dynamic_code_generated.code_begin, _event_data.dynamic_code_generated.code_begin,
_event_data.dynamic_code_generated.code_end); _event_data.dynamic_code_generated.code_end);
if (_event_data.dynamic_code_generated.name != NULL) {
// release our copy
os::free((void *)_event_data.dynamic_code_generated.name);
}
break; break;
}
default: default:
ShouldNotReachHere(); ShouldNotReachHere();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册