1 /* 2 * Copyright (c) 2022, 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 #ifndef SHARE_OOPS_INSTANCEKLASSMISCSTATUS_HPP 26 #define SHARE_OOPS_INSTANCEKLASSMISCSTATUS_HPP 27 28 class ClassLoaderData; 29 30 class InstanceKlassMiscStatus { 31 friend class VMStructs; 32 friend class JVMCIVMStructs; 33 34 #define IK_FLAGS_DO(flag) \ 35 flag(rewritten , 1 << 0) /* methods rewritten. */ \ 36 flag(has_nonstatic_fields , 1 << 1) /* for sizing with UseCompressedOops */ \ 37 flag(should_verify_class , 1 << 2) /* allow caching of preverification */ \ 38 flag(unused , 1 << 3) /* not currently used */ \ 39 flag(is_contended , 1 << 4) /* marked with contended annotation */ \ 40 flag(has_nonstatic_concrete_methods , 1 << 5) /* class/superclass/implemented interfaces has non-static, concrete methods */ \ 41 flag(declares_nonstatic_concrete_methods, 1 << 6) /* directly declares non-static, concrete methods */ \ 42 flag(has_been_redefined , 1 << 7) /* class has been redefined */ \ 43 flag(shared_loading_failed , 1 << 8) /* class has been loaded from shared archive */ \ 44 flag(is_scratch_class , 1 << 9) /* class is the redefined scratch class */ \ 45 flag(is_shared_boot_class , 1 << 10) /* defining class loader is boot class loader */ \ 46 flag(is_shared_platform_class , 1 << 11) /* defining class loader is platform class loader */ \ 47 flag(is_shared_app_class , 1 << 12) /* defining class loader is app class loader */ \ 48 flag(has_contended_annotations , 1 << 13) /* has @Contended annotation */ 49 50 #define IK_FLAGS_ENUM_NAME(name, value) _misc_##name = value, 51 enum { 52 IK_FLAGS_DO(IK_FLAGS_ENUM_NAME) 53 }; 54 #undef IK_FLAGS_ENUM_NAME 55 56 u2 shared_loader_type_bits() const { 57 return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class; 58 } 59 60 // These flags are write-once before the class is published and then read-only so don't require atomic updates. 61 u2 _flags; 62 63 public: 64 65 InstanceKlassMiscStatus() : _flags(0) {} 66 67 // Create getters and setters for the flag values. 68 #define IK_FLAGS_GET(name, ignore) \ 69 bool name() const { return (_flags & _misc_##name) != 0; } 70 IK_FLAGS_DO(IK_FLAGS_GET) 71 #undef IK_FLAGS_GET 72 73 #define IK_FLAGS_SET(name, ignore) \ 74 void set_##name(bool b) { \ 75 assert(!name(), "set once"); \ 76 if (b) _flags |= _misc_##name; \ 77 } 78 IK_FLAGS_DO(IK_FLAGS_SET) 79 #undef IK_FLAGS_SET 80 81 bool is_shared_unregistered_class() const { 82 return (_flags & shared_loader_type_bits()) == 0; 83 } 84 85 void set_shared_class_loader_type(s2 loader_type); 86 87 void assign_class_loader_type(const ClassLoaderData* cld); 88 }; 89 90 #endif // SHARE_OOPS_INSTANCEKLASSMISCSTATUS_HPP