1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/oopStorage.hpp" 27 #include "gc/shared/oopStorageSet.hpp" 28 #include "jfr/leakprofiler/utilities/rootType.hpp" 29 #include "utilities/debug.hpp" 30 31 OopStorage* OldObjectRoot::system_oop_storage(System system) { 32 int val = int(system); 33 if (val >= _strong_oop_storage_set_first && val <= _strong_oop_storage_set_last) { 34 int index = val - _strong_oop_storage_set_first; 35 int i = 0; 36 for (OopStorageSet::Iterator it = OopStorageSet::strong_iterator(); !it.is_end(); ++it, ++i) { 37 if (i == index) { 38 return *it; 39 } 40 } 41 } 42 return NULL; 43 } 44 45 const char* OldObjectRoot::system_description(System system) { 46 OopStorage* oop_storage = system_oop_storage(system); 47 if (oop_storage != NULL) { 48 return oop_storage->name(); 49 } 50 switch (system) { 51 case _system_undetermined: 52 return "<unknown>"; 53 case _universe: 54 return "Universe"; 55 case _threads: 56 return "Threads"; 57 case _object_synchronizer: 58 return "Object Monitor"; 59 case _class_loader_data: 60 return "Class Loader Data"; 61 case _management: 62 return "Management"; 63 case _jvmti: 64 return "JVMTI"; 65 case _code_cache: 66 return "Code Cache"; 67 case _aot: 68 return "AOT"; 69 #if INCLUDE_JVMCI 70 case _jvmci: 71 return "JVMCI"; 72 #endif 73 default: 74 ShouldNotReachHere(); 75 } 76 return NULL; 77 } 78 79 const char* OldObjectRoot::type_description(Type type) { 80 switch (type) { 81 case _type_undetermined: 82 return "<unknown>"; 83 case _stack_variable: 84 return "Stack Variable"; 85 case _local_jni_handle: 86 return "Local JNI Handle"; 87 case _global_jni_handle: 88 return "Global JNI Handle"; 89 case _global_oop_handle: 90 return "Global Object Handle"; 91 case _handle_area: 92 return "Handle Area"; 93 default: 94 ShouldNotReachHere(); 95 } 96 return NULL; 97 }