< prev index next >

src/hotspot/share/prims/jvmtiExport.cpp

Print this page
*** 1135,11 ***
   private:
     jobject _jobj;
     jlong    _size;
   public:
     JvmtiObjectAllocEventMark(JavaThread *thread, oop obj) : JvmtiClassEventMark(thread, oop_to_klass(obj)) {
!      _jobj = (jobject)to_jobject(obj);
       _size = obj->size() * wordSize;
     };
     jobject jni_jobject() { return _jobj; }
     jlong size() { return _size; }
  };
--- 1135,11 ---
   private:
     jobject _jobj;
     jlong    _size;
   public:
     JvmtiObjectAllocEventMark(JavaThread *thread, oop obj) : JvmtiClassEventMark(thread, oop_to_klass(obj)) {
!      _jobj = obj->is_inline() ? nullptr : (jobject)to_jobject(obj); // nullptr for non-identity objects
       _size = obj->size() * wordSize;
     };
     jobject jni_jobject() { return _jobj; }
     jlong size() { return _size; }
  };

*** 1280,10 ***
--- 1280,11 ---
  bool              JvmtiExport::_can_post_method_exit                      = false;
  bool              JvmtiExport::_can_post_frame_pop                        = false;
  bool              JvmtiExport::_can_pop_frame                             = false;
  bool              JvmtiExport::_can_force_early_return                    = false;
  bool              JvmtiExport::_can_support_virtual_threads               = false;
+ bool              JvmtiExport::_can_support_value_objects                 = false;
  bool              JvmtiExport::_can_get_owned_monitor_info                = false;
  
  bool              JvmtiExport::_early_vmstart_recorded                    = false;
  
  bool              JvmtiExport::_should_post_single_step                   = false;

*** 2965,21 ***
      return;
    }
    if (thread->should_hide_jvmti_events()) {
      return;
    }
    HandleMark hm(thread);
    Handle h(thread, object);
  
    EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Trg vm object alloc triggered",
                        JvmtiTrace::safe_get_thread_name(thread)));
    JvmtiEnvIterator it;
    for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) {
!     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) {
        EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s",
                                           JvmtiTrace::safe_get_thread_name(thread),
!                                          object==nullptr? "null" : object->klass()->external_name()));
  
        JvmtiObjectAllocEventMark jem(thread, h());
        JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
        jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc;
        if (callback != nullptr) {
--- 2966,26 ---
      return;
    }
    if (thread->should_hide_jvmti_events()) {
      return;
    }
+   const bool is_inline = object->is_inline();
+   if (is_inline && !JvmtiExport::can_support_value_objects()) {
+     return;
+   }
    HandleMark hm(thread);
    Handle h(thread, object);
  
    EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Trg vm object alloc triggered",
                        JvmtiTrace::safe_get_thread_name(thread)));
    JvmtiEnvIterator it;
    for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) {
!     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC) &&
+         (!is_inline || env->get_capabilities()->can_support_value_objects != 0)) {
        EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s",
                                           JvmtiTrace::safe_get_thread_name(thread),
!                                          object->klass()->external_name()));
  
        JvmtiObjectAllocEventMark jem(thread, h());
        JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
        jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc;
        if (callback != nullptr) {

*** 3002,23 ***
      return;
    }
    if (thread->should_hide_jvmti_events()) {
      return;
    }
  
    EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
                   ("[%s] Trg sampled object alloc triggered",
                    JvmtiTrace::safe_get_thread_name(thread)));
    JvmtiEnvThreadStateIterator it(state);
    for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; 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 == nullptr ? "null" : object->klass()->external_name()));
  
-       JvmtiEnv *env = ets->get_env();
        JvmtiObjectAllocEventMark jem(thread, h());
        JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
        jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
        if (callback != nullptr) {
          (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
--- 3008,28 ---
      return;
    }
    if (thread->should_hide_jvmti_events()) {
      return;
    }
+   const bool is_inline = object->is_inline();
+   if (is_inline && !JvmtiExport::can_support_value_objects()) {
+     return;
+   }
  
    EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
                   ("[%s] Trg sampled object alloc triggered",
                    JvmtiTrace::safe_get_thread_name(thread)));
    JvmtiEnvThreadStateIterator it(state);
    for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
!     JvmtiEnv *env = ets->get_env();
+     if (ets->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC) &&
+         (!is_inline || env->get_capabilities()->can_support_value_objects != 0)) {
        EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
                  ("[%s] Evt sampled object alloc sent %s",
                   JvmtiTrace::safe_get_thread_name(thread),
!                  object->klass()->external_name()));
  
        JvmtiObjectAllocEventMark jem(thread, h());
        JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
        jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
        if (callback != nullptr) {
          (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
< prev index next >