1 /* 2 * Copyright (c) 2011, 2019, 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 #ifndef SHARE_MEMORY_METASPACEENUMS_HPP 25 #define SHARE_MEMORY_METASPACEENUMS_HPP 26 27 #include "utilities/debug.hpp" 28 29 // MetadataType and MetaspaceType, as well as some convenience functions surrounding them. 30 namespace metaspace { 31 32 /////////////////////// 33 34 enum MetadataType { 35 ClassType, 36 NonClassType, 37 MetadataTypeCount 38 }; 39 40 inline bool is_class(MetadataType md) { return md == ClassType; } 41 42 inline MetadataType mdtype_from_bool(bool is_class) { return is_class ? ClassType : NonClassType; } 43 44 const char* describe_mdtype(MetadataType md); 45 46 #ifdef ASSERT 47 inline bool is_valid_mdtype(MetadataType md) { 48 return (int)md >= 0 && (int)md < MetadataTypeCount; 49 } 50 void check_valid_mdtype(MetadataType md) { 51 assert(is_valid_mdtype(md), "Wrong value for MetadataType: %d", (int) md); 52 } 53 #endif 54 55 /////////////////////// 56 57 enum MetaspaceType { 58 ZeroMetaspaceType = 0, 59 StandardMetaspaceType = ZeroMetaspaceType, 60 BootMetaspaceType = StandardMetaspaceType + 1, 61 UnsafeAnonymousMetaspaceType = BootMetaspaceType + 1, 62 ReflectionMetaspaceType = UnsafeAnonymousMetaspaceType + 1, 63 MetaspaceTypeCount 64 }; 65 66 const char* describe_spacetype(MetaspaceType st); 67 68 #ifdef ASSERT 69 inline bool is_valid_spacetype(MetaspaceType st) { 70 return (int)st >= 0 && (int)st < MetaspaceTypeCount; 71 } 72 void check_valid_spacetype(MetaspaceType st) { 73 assert(is_valid_spacetype(st), "Wrong value for MetaspaceType: %d", (int) st); 74 } 75 #endif 76 77 } // namespace metaspace 78 79 #endif // SHARE_MEMORY_METASPACEENUMS_HPP