8201655: Add thread-enabled support for the Heap Sampling

Added thread-enabled support

Reviewed-by: amenkov, sspitsyn
This commit is contained in:
Jean Christophe Beyler 2018-12-14 13:13:06 -08:00
parent d1951aa97c
commit f3657753d6
5 changed files with 100 additions and 123 deletions

View file

@ -2567,6 +2567,11 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) {
}
void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
JvmtiThreadState *state = thread->jvmti_thread_state();
if (state == NULL) {
return;
}
EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
("[%s] Trg sampled object alloc triggered",
JvmtiTrace::safe_get_thread_name(thread)));
@ -2575,14 +2580,16 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
}
HandleMark hm(thread);
Handle h(thread, object);
JvmtiEnvIterator it;
for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
if (env->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
JvmtiEnvThreadStateIterator it(state);
for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
if (ets->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
("[%s] Evt sampled object alloc sent %s",
JvmtiTrace::safe_get_thread_name(thread),
object == NULL ? "NULL" : object->klass()->external_name()));
JvmtiEnv *env = ets->get_env();
JvmtiObjectAllocEventMark jem(thread, h());
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;