< prev index next >

src/hotspot/share/runtime/vmStructs.cpp

Print this page

 130 #include "opto/machnode.hpp"
 131 #include "opto/matcher.hpp"
 132 #include "opto/mathexactnode.hpp"
 133 #include "opto/movenode.hpp"
 134 #include "opto/mulnode.hpp"
 135 #include "opto/narrowptrnode.hpp"
 136 #include "opto/opaquenode.hpp"
 137 #include "opto/optoreg.hpp"
 138 #include "opto/parse.hpp"
 139 #include "opto/phaseX.hpp"
 140 #include "opto/regalloc.hpp"
 141 #include "opto/rootnode.hpp"
 142 #include "opto/subnode.hpp"
 143 #include "opto/vectornode.hpp"
 144 #endif // COMPILER2
 145 
 146 #include CPU_HEADER(vmStructs)
 147 #include OS_HEADER(vmStructs)
 148 #include OS_CPU_HEADER(vmStructs)
 149 










 150 // Note: the cross-product of (c1, c2, product, nonproduct, ...),
 151 // (nonstatic, static), and (unchecked, checked) has not been taken.
 152 // Only the macros currently needed have been defined.
 153 
 154 // A field whose type is not checked is given a null string as the
 155 // type name, indicating an "opaque" type to the serviceability agent.
 156 
 157 // NOTE: there is an interdependency between this file and
 158 // HotSpotTypeDataBase.java, which parses the type strings.
 159 
 160 #ifndef REG_COUNT
 161   #define REG_COUNT 0
 162 #endif
 163 
 164 #if INCLUDE_JVMTI
 165   #define JVMTI_STRUCTS(static_field) \
 166     static_field(JvmtiExport,                     _can_access_local_variables,                  bool)                                  \
 167     static_field(JvmtiExport,                     _can_hotswap_or_post_breakpoint,              bool)                                  \
 168     static_field(JvmtiExport,                     _can_post_on_exceptions,                      bool)                                  \
 169     static_field(JvmtiExport,                     _can_walk_any_space,                          bool)

1139   declare_unsigned_integer_type(size_t)                                   \
1140   declare_integer_type(ssize_t)                                           \
1141   declare_integer_type(intx)                                              \
1142   declare_integer_type(intptr_t)                                          \
1143   declare_integer_type(int64_t)                                           \
1144   declare_unsigned_integer_type(uintx)                                    \
1145   declare_unsigned_integer_type(uintptr_t)                                \
1146   declare_unsigned_integer_type(uint8_t)                                  \
1147   declare_unsigned_integer_type(uint32_t)                                 \
1148   declare_unsigned_integer_type(uint64_t)                                 \
1149                                                                           \
1150   /******************************************/                            \
1151   /* OopDesc hierarchy (NOTE: some missing) */                            \
1152   /******************************************/                            \
1153                                                                           \
1154   declare_toplevel_type(oopDesc)                                          \
1155     declare_type(arrayOopDesc, oopDesc)                                   \
1156       declare_type(objArrayOopDesc, arrayOopDesc)                         \
1157     declare_type(instanceOopDesc, oopDesc)                                \
1158                                                                           \


1159   /**************************************************/                    \
1160   /* MetadataOopDesc hierarchy (NOTE: some missing) */                    \
1161   /**************************************************/                    \
1162                                                                           \
1163   declare_toplevel_type(MetaspaceObj)                                     \
1164     declare_type(Metadata, MetaspaceObj)                                  \
1165     declare_type(Klass, Metadata)                                         \
1166            declare_type(ArrayKlass, Klass)                                \
1167            declare_type(ObjArrayKlass, ArrayKlass)                        \
1168            declare_type(TypeArrayKlass, ArrayKlass)                       \
1169       declare_type(InstanceKlass, Klass)                                  \
1170         declare_type(InstanceClassLoaderKlass, InstanceKlass)             \
1171         declare_type(InstanceMirrorKlass, InstanceKlass)                  \
1172         declare_type(InstanceRefKlass, InstanceKlass)                     \
1173         declare_type(InstanceStackChunkKlass, InstanceKlass)              \
1174     declare_type(ConstantPool, Metadata)                                  \
1175     declare_type(ConstantPoolCache, MetaspaceObj)                         \
1176     declare_type(MethodData, Metadata)                                    \
1177     declare_type(Method, Metadata)                                        \
1178     declare_type(MethodCounters, MetaspaceObj)                            \

2492 #define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
2493                                                                           \
2494   /****************/                                                      \
2495   /* GC constants */                                                      \
2496   /****************/                                                      \
2497                                                                           \
2498   VM_LONG_CONSTANTS_GC(declare_constant)                                  \
2499                                                                           \
2500   /*********************/                                                 \
2501   /* markWord constants */                                                \
2502   /*********************/                                                 \
2503                                                                           \
2504   /* Note: some of these are declared as long constants just for */       \
2505   /* consistency. The mask constants are the only ones requiring */       \
2506   /* 64 bits (on 64-bit platforms). */                                    \
2507                                                                           \
2508   declare_constant(markWord::age_bits)                                    \
2509   declare_constant(markWord::lock_bits)                                   \
2510   declare_constant(markWord::max_hash_bits)                               \
2511   declare_constant(markWord::hash_bits)                                   \

2512                                                                           \
2513   declare_constant(markWord::lock_shift)                                  \
2514   declare_constant(markWord::age_shift)                                   \
2515   declare_constant(markWord::hash_shift)                                  \


2516                                                                           \
2517   declare_constant(markWord::lock_mask)                                   \
2518   declare_constant(markWord::lock_mask_in_place)                          \
2519   declare_constant(markWord::age_mask)                                    \
2520   declare_constant(markWord::age_mask_in_place)                           \
2521   declare_constant(markWord::hash_mask)                                   \
2522   declare_constant(markWord::hash_mask_in_place)                          \


2523                                                                           \
2524   declare_constant(markWord::locked_value)                                \
2525   declare_constant(markWord::unlocked_value)                              \
2526   declare_constant(markWord::monitor_value)                               \
2527   declare_constant(markWord::marked_value)                                \
2528                                                                           \
2529   declare_constant(markWord::no_hash)                                     \
2530   declare_constant(markWord::no_hash_in_place)                            \
2531   declare_constant(markWord::no_lock_in_place)                            \
2532   declare_constant(markWord::max_age)                                     \
2533                                                                           \
2534   /* InvocationCounter constants */                                       \
2535   declare_constant(InvocationCounter::count_increment)                    \
2536   declare_constant(InvocationCounter::count_shift)                        \
2537                                                                           \
2538   /* ObjectMonitor constants */                                           \
2539   declare_constant(ObjectMonitor::ANONYMOUS_OWNER)                        \
2540 
2541 //--------------------------------------------------------------------------------
2542 //

3039       return 1;
3040     }
3041     os::free(s);
3042   }
3043   if (!isRecurse) {
3044     tty->print_cr("type \"%s\" not found", typeName);
3045   }
3046   return 0;
3047 }
3048 
3049 int VMStructs::findType(const char* typeName) {
3050   VMTypeEntry* types = gHotSpotVMTypes;
3051 
3052   return recursiveFindType(types, typeName, false);
3053 }
3054 
3055 void vmStructs_init() {
3056   VMStructs::init();
3057 }
3058 #endif // ASSERT



























 130 #include "opto/machnode.hpp"
 131 #include "opto/matcher.hpp"
 132 #include "opto/mathexactnode.hpp"
 133 #include "opto/movenode.hpp"
 134 #include "opto/mulnode.hpp"
 135 #include "opto/narrowptrnode.hpp"
 136 #include "opto/opaquenode.hpp"
 137 #include "opto/optoreg.hpp"
 138 #include "opto/parse.hpp"
 139 #include "opto/phaseX.hpp"
 140 #include "opto/regalloc.hpp"
 141 #include "opto/rootnode.hpp"
 142 #include "opto/subnode.hpp"
 143 #include "opto/vectornode.hpp"
 144 #endif // COMPILER2
 145 
 146 #include CPU_HEADER(vmStructs)
 147 #include OS_HEADER(vmStructs)
 148 #include OS_CPU_HEADER(vmStructs)
 149 
 150 // Used by VMStructs when CompactObjectHeaders are enabled.
 151 // Must match the relevant parts from the real oopDesc.
 152 class fakeOopDesc {
 153 private:
 154   union _metadata {
 155     Klass*      _klass;
 156     narrowKlass _compressed_klass;
 157   } _metadata;
 158 };
 159 
 160 // Note: the cross-product of (c1, c2, product, nonproduct, ...),
 161 // (nonstatic, static), and (unchecked, checked) has not been taken.
 162 // Only the macros currently needed have been defined.
 163 
 164 // A field whose type is not checked is given a null string as the
 165 // type name, indicating an "opaque" type to the serviceability agent.
 166 
 167 // NOTE: there is an interdependency between this file and
 168 // HotSpotTypeDataBase.java, which parses the type strings.
 169 
 170 #ifndef REG_COUNT
 171   #define REG_COUNT 0
 172 #endif
 173 
 174 #if INCLUDE_JVMTI
 175   #define JVMTI_STRUCTS(static_field) \
 176     static_field(JvmtiExport,                     _can_access_local_variables,                  bool)                                  \
 177     static_field(JvmtiExport,                     _can_hotswap_or_post_breakpoint,              bool)                                  \
 178     static_field(JvmtiExport,                     _can_post_on_exceptions,                      bool)                                  \
 179     static_field(JvmtiExport,                     _can_walk_any_space,                          bool)

1149   declare_unsigned_integer_type(size_t)                                   \
1150   declare_integer_type(ssize_t)                                           \
1151   declare_integer_type(intx)                                              \
1152   declare_integer_type(intptr_t)                                          \
1153   declare_integer_type(int64_t)                                           \
1154   declare_unsigned_integer_type(uintx)                                    \
1155   declare_unsigned_integer_type(uintptr_t)                                \
1156   declare_unsigned_integer_type(uint8_t)                                  \
1157   declare_unsigned_integer_type(uint32_t)                                 \
1158   declare_unsigned_integer_type(uint64_t)                                 \
1159                                                                           \
1160   /******************************************/                            \
1161   /* OopDesc hierarchy (NOTE: some missing) */                            \
1162   /******************************************/                            \
1163                                                                           \
1164   declare_toplevel_type(oopDesc)                                          \
1165     declare_type(arrayOopDesc, oopDesc)                                   \
1166       declare_type(objArrayOopDesc, arrayOopDesc)                         \
1167     declare_type(instanceOopDesc, oopDesc)                                \
1168                                                                           \
1169   declare_toplevel_type(fakeOopDesc)                                      \
1170                                                                           \
1171   /**************************************************/                    \
1172   /* MetadataOopDesc hierarchy (NOTE: some missing) */                    \
1173   /**************************************************/                    \
1174                                                                           \
1175   declare_toplevel_type(MetaspaceObj)                                     \
1176     declare_type(Metadata, MetaspaceObj)                                  \
1177     declare_type(Klass, Metadata)                                         \
1178            declare_type(ArrayKlass, Klass)                                \
1179            declare_type(ObjArrayKlass, ArrayKlass)                        \
1180            declare_type(TypeArrayKlass, ArrayKlass)                       \
1181       declare_type(InstanceKlass, Klass)                                  \
1182         declare_type(InstanceClassLoaderKlass, InstanceKlass)             \
1183         declare_type(InstanceMirrorKlass, InstanceKlass)                  \
1184         declare_type(InstanceRefKlass, InstanceKlass)                     \
1185         declare_type(InstanceStackChunkKlass, InstanceKlass)              \
1186     declare_type(ConstantPool, Metadata)                                  \
1187     declare_type(ConstantPoolCache, MetaspaceObj)                         \
1188     declare_type(MethodData, Metadata)                                    \
1189     declare_type(Method, Metadata)                                        \
1190     declare_type(MethodCounters, MetaspaceObj)                            \

2504 #define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
2505                                                                           \
2506   /****************/                                                      \
2507   /* GC constants */                                                      \
2508   /****************/                                                      \
2509                                                                           \
2510   VM_LONG_CONSTANTS_GC(declare_constant)                                  \
2511                                                                           \
2512   /*********************/                                                 \
2513   /* markWord constants */                                                \
2514   /*********************/                                                 \
2515                                                                           \
2516   /* Note: some of these are declared as long constants just for */       \
2517   /* consistency. The mask constants are the only ones requiring */       \
2518   /* 64 bits (on 64-bit platforms). */                                    \
2519                                                                           \
2520   declare_constant(markWord::age_bits)                                    \
2521   declare_constant(markWord::lock_bits)                                   \
2522   declare_constant(markWord::max_hash_bits)                               \
2523   declare_constant(markWord::hash_bits)                                   \
2524   declare_constant(markWord::hash_bits_compact)                           \
2525                                                                           \
2526   declare_constant(markWord::lock_shift)                                  \
2527   declare_constant(markWord::age_shift)                                   \
2528   declare_constant(markWord::hash_shift)                                  \
2529   declare_constant(markWord::hash_shift_compact)                          \
2530   LP64_ONLY(declare_constant(markWord::klass_shift))                      \
2531                                                                           \
2532   declare_constant(markWord::lock_mask)                                   \
2533   declare_constant(markWord::lock_mask_in_place)                          \
2534   declare_constant(markWord::age_mask)                                    \
2535   declare_constant(markWord::age_mask_in_place)                           \
2536   declare_constant(markWord::hash_mask)                                   \
2537   declare_constant(markWord::hash_mask_in_place)                          \
2538   declare_constant(markWord::hash_mask_compact)                           \
2539   declare_constant(markWord::hash_mask_compact_in_place)                  \
2540                                                                           \
2541   declare_constant(markWord::locked_value)                                \
2542   declare_constant(markWord::unlocked_value)                              \
2543   declare_constant(markWord::monitor_value)                               \
2544   declare_constant(markWord::marked_value)                                \
2545                                                                           \
2546   declare_constant(markWord::no_hash)                                     \
2547   declare_constant(markWord::no_hash_in_place)                            \
2548   declare_constant(markWord::no_lock_in_place)                            \
2549   declare_constant(markWord::max_age)                                     \
2550                                                                           \
2551   /* InvocationCounter constants */                                       \
2552   declare_constant(InvocationCounter::count_increment)                    \
2553   declare_constant(InvocationCounter::count_shift)                        \
2554                                                                           \
2555   /* ObjectMonitor constants */                                           \
2556   declare_constant(ObjectMonitor::ANONYMOUS_OWNER)                        \
2557 
2558 //--------------------------------------------------------------------------------
2559 //

3056       return 1;
3057     }
3058     os::free(s);
3059   }
3060   if (!isRecurse) {
3061     tty->print_cr("type \"%s\" not found", typeName);
3062   }
3063   return 0;
3064 }
3065 
3066 int VMStructs::findType(const char* typeName) {
3067   VMTypeEntry* types = gHotSpotVMTypes;
3068 
3069   return recursiveFindType(types, typeName, false);
3070 }
3071 
3072 void vmStructs_init() {
3073   VMStructs::init();
3074 }
3075 #endif // ASSERT
3076 
3077 void VMStructs::compact_headers_overrides() {
3078   assert(UseCompactObjectHeaders, "Should have been checked before");
3079 
3080   // We cannot allow SA and other facilities to poke into VM internal fields
3081   // expecting the class pointers there. This will crash in the best case,
3082   // or yield incorrect execution in the worst case. This code hides the
3083   // risky fields from external code by replacing their original container
3084   // type to a fake one. The fake type should exist for VMStructs verification
3085   // code to work.
3086 
3087   size_t len = localHotSpotVMStructsLength();
3088   for (size_t off = 0; off < len; off++) {
3089     VMStructEntry* e = &localHotSpotVMStructs[off];
3090     if (e == nullptr) continue;
3091     if (e->typeName == nullptr) continue;
3092     if (e->fieldName == nullptr) continue;
3093 
3094     if (strcmp(e->typeName, "oopDesc") == 0) {
3095       if ((strcmp(e->fieldName, "_metadata._klass") == 0) ||
3096           (strcmp(e->fieldName, "_metadata._compressed_klass") == 0)) {
3097         e->typeName = "fakeOopDesc";
3098       }
3099     }
3100   }
3101 }
< prev index next >