8195109: ServiceUtil::visible_oop is not needed anymore
authorcjplummer
Wed, 21 Mar 2018 13:07:19 -0700
changeset 49476 1f904e305a05
parent 49475 8f3c8e44e585
child 49477 84f0f5df5afa
8195109: ServiceUtil::visible_oop is not needed anymore Summary: strip out ServiceUtil and all users of it Reviewed-by: coleenp, stefank, jcbeyler, sspitsyn
src/hotspot/share/prims/jvmtiExport.cpp
src/hotspot/share/prims/jvmtiTagMap.cpp
src/hotspot/share/runtime/threadSMR.cpp
src/hotspot/share/services/serviceUtil.hpp
src/hotspot/share/services/threadService.hpp
--- a/src/hotspot/share/prims/jvmtiExport.cpp	Wed Mar 21 10:05:36 2018 +0100
+++ b/src/hotspot/share/prims/jvmtiExport.cpp	Wed Mar 21 13:07:19 2018 -0700
@@ -57,7 +57,6 @@
 #include "runtime/thread.inline.hpp"
 #include "runtime/threadSMR.hpp"
 #include "runtime/vframe.hpp"
-#include "services/serviceUtil.hpp"
 #include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc/parallel/psMarkSweep.hpp"
@@ -2363,10 +2362,6 @@
 
 void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor *obj_mntr) {
   oop object = (oop)obj_mntr->object();
-  if (!ServiceUtil::visible_oop(object)) {
-    // Ignore monitor contended enter for vm internal object.
-    return;
-  }
   JvmtiThreadState *state = thread->jvmti_thread_state();
   if (state == NULL) {
     return;
@@ -2398,10 +2393,6 @@
 
 void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonitor *obj_mntr) {
   oop object = (oop)obj_mntr->object();
-  if (!ServiceUtil::visible_oop(object)) {
-    // Ignore monitor contended entered for vm internal object.
-    return;
-  }
   JvmtiThreadState *state = thread->jvmti_thread_state();
   if (state == NULL) {
     return;
@@ -2465,10 +2456,6 @@
 
 void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mntr, jboolean timed_out) {
   oop object = (oop)obj_mntr->object();
-  if (!ServiceUtil::visible_oop(object)) {
-    // Ignore monitor waited for vm internal object.
-    return;
-  }
   JvmtiThreadState *state = thread->jvmti_thread_state();
   if (state == NULL) {
     return;
@@ -2761,9 +2748,7 @@
     set_enabled(false);
     for (int i = 0; i < _allocated->length(); i++) {
       oop obj = _allocated->at(i);
-      if (ServiceUtil::visible_oop(obj)) {
-        JvmtiExport::post_vm_object_alloc(JavaThread::current(), obj);
-      }
+      JvmtiExport::post_vm_object_alloc(JavaThread::current(), obj);
     }
     delete _allocated;
   }
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Wed Mar 21 10:05:36 2018 +0100
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Wed Mar 21 13:07:19 2018 -0700
@@ -55,7 +55,6 @@
 #include "runtime/vframe.hpp"
 #include "runtime/vmThread.hpp"
 #include "runtime/vm_operations.hpp"
-#include "services/serviceUtil.hpp"
 #include "utilities/macros.hpp"
 
 // JvmtiTagHashmapEntry
@@ -1324,9 +1323,6 @@
   // check if iteration has been halted
   if (is_iteration_aborted()) return;
 
-  // ignore any objects that aren't visible to profiler
-  if (!ServiceUtil::visible_oop(o)) return;
-
   // instanceof check when filtering by klass
   if (klass() != NULL && !o->is_a(klass())) {
     return;
@@ -1407,9 +1403,6 @@
   // check if iteration has been halted
   if (is_iteration_aborted()) return;
 
-  // ignore any objects that aren't visible to profiler
-  if (!ServiceUtil::visible_oop(obj)) return;
-
   // apply class filter
   if (is_filtered_by_klass_filter(obj, klass())) return;
 
@@ -1987,8 +1980,6 @@
 
 // invoke basic style heap root callback
 inline bool CallbackInvoker::invoke_basic_heap_root_callback(jvmtiHeapRootKind root_kind, oop obj) {
-  assert(ServiceUtil::visible_oop(obj), "checking");
-
   // if we heap roots should be reported
   jvmtiHeapRootCallback cb = basic_context()->heap_root_callback();
   if (cb == NULL) {
@@ -2016,8 +2007,6 @@
                                                              jmethodID method,
                                                              int slot,
                                                              oop obj) {
-  assert(ServiceUtil::visible_oop(obj), "checking");
-
   // if we stack refs should be reported
   jvmtiStackReferenceCallback cb = basic_context()->stack_ref_callback();
   if (cb == NULL) {
@@ -2048,9 +2037,6 @@
                                                                     oop referree,
                                                                     jint index) {
 
-  assert(ServiceUtil::visible_oop(referrer), "checking");
-  assert(ServiceUtil::visible_oop(referree), "checking");
-
   BasicHeapWalkContext* context = basic_context();
 
   // callback requires the referrer's tag. If it's the same referrer
@@ -2092,8 +2078,6 @@
 // invoke advanced style heap root callback
 inline bool CallbackInvoker::invoke_advanced_heap_root_callback(jvmtiHeapReferenceKind ref_kind,
                                                                 oop obj) {
-  assert(ServiceUtil::visible_oop(obj), "checking");
-
   AdvancedHeapWalkContext* context = advanced_context();
 
   // check that callback is provided
@@ -2148,8 +2132,6 @@
                                                                 jlocation bci,
                                                                 jint slot,
                                                                 oop obj) {
-  assert(ServiceUtil::visible_oop(obj), "checking");
-
   AdvancedHeapWalkContext* context = advanced_context();
 
   // check that callback is provider
@@ -2223,9 +2205,6 @@
   // field index is only valid field in reference_info
   static jvmtiHeapReferenceInfo reference_info = { 0 };
 
-  assert(ServiceUtil::visible_oop(referrer), "checking");
-  assert(ServiceUtil::visible_oop(obj), "checking");
-
   AdvancedHeapWalkContext* context = advanced_context();
 
   // check that callback is provider
@@ -2279,7 +2258,6 @@
 inline bool CallbackInvoker::report_simple_root(jvmtiHeapReferenceKind kind, oop obj) {
   assert(kind != JVMTI_HEAP_REFERENCE_STACK_LOCAL &&
          kind != JVMTI_HEAP_REFERENCE_JNI_LOCAL, "not a simple root");
-  assert(ServiceUtil::visible_oop(obj), "checking");
 
   if (is_basic_heap_walk()) {
     // map to old style root kind
@@ -2604,13 +2582,6 @@
       }
     }
 
-    // some objects are ignored - in the case of simple
-    // roots it's mostly Symbol*s that we are skipping
-    // here.
-    if (!ServiceUtil::visible_oop(o)) {
-      return;
-    }
-
     // invoke the callback
     _continue = CallbackInvoker::report_simple_root(kind, o);
 
@@ -2651,10 +2622,6 @@
       return;
     }
 
-    if (!ServiceUtil::visible_oop(o)) {
-      return;
-    }
-
     // invoke the callback
     _continue = CallbackInvoker::report_jni_local_root(_thread_tag, _tid, _depth, _method, o);
   }
@@ -2982,7 +2949,7 @@
     if (!is_primitive_field_type(type)) {
       oop fld_o = o->obj_field(field->field_offset());
       // ignore any objects that aren't visible to profiler
-      if (fld_o != NULL && ServiceUtil::visible_oop(fld_o)) {
+      if (fld_o != NULL) {
         assert(Universe::heap()->is_in_reserved(fld_o), "unsafe code should not "
                "have references to Klass* anymore");
         int slot = field->field_index();
--- a/src/hotspot/share/runtime/threadSMR.cpp	Wed Mar 21 10:05:36 2018 +0100
+++ b/src/hotspot/share/runtime/threadSMR.cpp	Wed Mar 21 13:07:19 2018 -0700
@@ -29,8 +29,10 @@
 #include "runtime/thread.inline.hpp"
 #include "runtime/threadSMR.inline.hpp"
 #include "services/threadService.hpp"
+#include "utilities/copy.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/resourceHash.hpp"
+#include "utilities/vmError.hpp"
 
 Monitor*              ThreadsSMRSupport::_delete_lock =
                           new Monitor(Monitor::special, "Thread_SMR_delete_lock",
--- a/src/hotspot/share/services/serviceUtil.hpp	Wed Mar 21 10:05:36 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_SERVICES_SERVICEUTIL_HPP
-#define SHARE_VM_SERVICES_SERVICEUTIL_HPP
-
-#include "classfile/systemDictionary.hpp"
-#include "oops/objArrayOop.hpp"
-#include "oops/oop.inline.hpp"
-
-//
-// Serviceability utility functions.
-// (Shared by MM and JVMTI).
-//
-class ServiceUtil : public AllStatic {
- public:
-
-  // Return true if oop represents an object that is "visible"
-  // to the java world.
-  static inline bool visible_oop(oop o) {
-    // instance
-    if (o->is_instance()) {
-      // instance objects are visible
-      if (o->klass() != SystemDictionary::Class_klass()) {
-        return true;
-      }
-      if (java_lang_Class::is_primitive(o)) {
-        return true;
-      }
-      // java.lang.Classes are visible
-      Klass* k = java_lang_Class::as_Klass(o);
-      if (k->is_klass()) {
-        // if it's a class for an object, an object array, or
-        // primitive (type) array then it's visible.
-        if (k->is_instance_klass()) {
-          return true;
-        }
-        if (k->is_objArray_klass()) {
-          return true;
-        }
-        if (k->is_typeArray_klass()) {
-          return true;
-        }
-      }
-      fatal("visible_oop: should never reach here #1");
-      return false;
-    }
-    // object arrays are visible if they aren't system object arrays
-    if (o->is_objArray()) {
-        return true;
-    }
-    // type arrays are visible
-    if (o->is_typeArray()) {
-      return true;
-    }
-    // everything else (Method*s, ...) aren't visible
-    fatal("visible_oop: should never reach here #2");
-    return false;
-  };   // end of visible_oop()
-
-};
-
-#endif // SHARE_VM_SERVICES_SERVICEUTIL_HPP
--- a/src/hotspot/share/services/threadService.hpp	Wed Mar 21 10:05:36 2018 +0100
+++ b/src/hotspot/share/services/threadService.hpp	Wed Mar 21 13:07:19 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 #include "runtime/thread.hpp"
 #include "runtime/threadSMR.hpp"
 #include "services/management.hpp"
-#include "services/serviceUtil.hpp"
 
 class OopClosure;
 class ThreadDumpResult;
@@ -548,7 +547,7 @@
   static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) {
     assert((java_thread != NULL), "Java thread should not be null here");
     bool active = false;
-    if (is_alive(java_thread) && ServiceUtil::visible_oop((oop)obj_m->object())) {
+    if (is_alive(java_thread)) {
       active = contended_enter_begin(java_thread);
     }
     return active;
@@ -569,7 +568,7 @@
     // like for vm internal objects and for external objects which are not contended
     // thread status is not changed and contended enter stat is not collected.
     _active = false;
-    if (is_alive() && ServiceUtil::visible_oop((oop)obj_m->object()) && obj_m->contentions() > 0) {
+    if (is_alive() && obj_m->contentions() > 0) {
       _stat = java_thread->get_thread_stat();
       _active = contended_enter_begin(java_thread);
     }