src/share/vm/services/serviceUtil.hpp

Thu, 12 Mar 2009 18:16:36 -0700

author
trims
date
Thu, 12 Mar 2009 18:16:36 -0700
changeset 1063
7bb995fbd3c0
parent 435
a61af66fc99e
child 1577
4ce7240d622c
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 //
duke@435 26 // Serviceability utility functions.
duke@435 27 // (Shared by MM and JVMTI).
duke@435 28 //
duke@435 29 class ServiceUtil : public AllStatic {
duke@435 30 public:
duke@435 31
duke@435 32 // Return true if oop represents an object that is "visible"
duke@435 33 // to the java world.
duke@435 34 static inline bool visible_oop(oop o) {
duke@435 35 // the sentinel for deleted handles isn't visible
duke@435 36 if (o == JNIHandles::deleted_handle()) {
duke@435 37 return false;
duke@435 38 }
duke@435 39
duke@435 40 // ignore KlassKlass
duke@435 41 if (o->is_klass()) {
duke@435 42 return false;
duke@435 43 }
duke@435 44
duke@435 45 // instance
duke@435 46 if (o->is_instance()) {
duke@435 47 // instance objects are visible
duke@435 48 if (o->klass() != SystemDictionary::class_klass()) {
duke@435 49 return true;
duke@435 50 }
duke@435 51 if (java_lang_Class::is_primitive(o)) {
duke@435 52 return true;
duke@435 53 }
duke@435 54 // java.lang.Classes are visible
duke@435 55 o = java_lang_Class::as_klassOop(o);
duke@435 56 if (o->is_klass()) {
duke@435 57 // if it's a class for an object, an object array, or
duke@435 58 // primitive (type) array then it's visible.
duke@435 59 klassOop klass = (klassOop)o;
duke@435 60 if (Klass::cast(klass)->oop_is_instance()) {
duke@435 61 return true;
duke@435 62 }
duke@435 63 if (Klass::cast(klass)->oop_is_objArray()) {
duke@435 64 return true;
duke@435 65 }
duke@435 66 if (Klass::cast(klass)->oop_is_typeArray()) {
duke@435 67 return true;
duke@435 68 }
duke@435 69 }
duke@435 70 return false;
duke@435 71 }
duke@435 72 // object arrays are visible if they aren't system object arrays
duke@435 73 if (o->is_objArray()) {
duke@435 74 objArrayOop array = (objArrayOop)o;
duke@435 75 if (array->klass() != Universe::systemObjArrayKlassObj()) {
duke@435 76 return true;
duke@435 77 } else {
duke@435 78 return false;
duke@435 79 }
duke@435 80 }
duke@435 81 // type arrays are visible
duke@435 82 if (o->is_typeArray()) {
duke@435 83 return true;
duke@435 84 }
duke@435 85 // everything else (methodOops, ...) aren't visible
duke@435 86 return false;
duke@435 87 }; // end of visible_oop()
duke@435 88
duke@435 89 };

mercurial