1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/services/serviceUtil.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,89 @@ 1.4 +/* 1.5 + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// 1.29 +// Serviceability utility functions. 1.30 +// (Shared by MM and JVMTI). 1.31 +// 1.32 +class ServiceUtil : public AllStatic { 1.33 + public: 1.34 + 1.35 + // Return true if oop represents an object that is "visible" 1.36 + // to the java world. 1.37 + static inline bool visible_oop(oop o) { 1.38 + // the sentinel for deleted handles isn't visible 1.39 + if (o == JNIHandles::deleted_handle()) { 1.40 + return false; 1.41 + } 1.42 + 1.43 + // ignore KlassKlass 1.44 + if (o->is_klass()) { 1.45 + return false; 1.46 + } 1.47 + 1.48 + // instance 1.49 + if (o->is_instance()) { 1.50 + // instance objects are visible 1.51 + if (o->klass() != SystemDictionary::class_klass()) { 1.52 + return true; 1.53 + } 1.54 + if (java_lang_Class::is_primitive(o)) { 1.55 + return true; 1.56 + } 1.57 + // java.lang.Classes are visible 1.58 + o = java_lang_Class::as_klassOop(o); 1.59 + if (o->is_klass()) { 1.60 + // if it's a class for an object, an object array, or 1.61 + // primitive (type) array then it's visible. 1.62 + klassOop klass = (klassOop)o; 1.63 + if (Klass::cast(klass)->oop_is_instance()) { 1.64 + return true; 1.65 + } 1.66 + if (Klass::cast(klass)->oop_is_objArray()) { 1.67 + return true; 1.68 + } 1.69 + if (Klass::cast(klass)->oop_is_typeArray()) { 1.70 + return true; 1.71 + } 1.72 + } 1.73 + return false; 1.74 + } 1.75 + // object arrays are visible if they aren't system object arrays 1.76 + if (o->is_objArray()) { 1.77 + objArrayOop array = (objArrayOop)o; 1.78 + if (array->klass() != Universe::systemObjArrayKlassObj()) { 1.79 + return true; 1.80 + } else { 1.81 + return false; 1.82 + } 1.83 + } 1.84 + // type arrays are visible 1.85 + if (o->is_typeArray()) { 1.86 + return true; 1.87 + } 1.88 + // everything else (methodOops, ...) aren't visible 1.89 + return false; 1.90 + }; // end of visible_oop() 1.91 + 1.92 +};