< prev index next >

src/hotspot/share/runtime/vmStructs.cpp

Print this page

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










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

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


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

2513 #define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
2514                                                                           \
2515   /****************/                                                      \
2516   /* GC constants */                                                      \
2517   /****************/                                                      \
2518                                                                           \
2519   VM_LONG_CONSTANTS_GC(declare_constant)                                  \
2520                                                                           \
2521   /*********************/                                                 \
2522   /* markWord constants */                                                \
2523   /*********************/                                                 \
2524                                                                           \
2525   /* Note: some of these are declared as long constants just for */       \
2526   /* consistency. The mask constants are the only ones requiring */       \
2527   /* 64 bits (on 64-bit platforms). */                                    \
2528                                                                           \
2529   declare_constant(markWord::age_bits)                                    \
2530   declare_constant(markWord::lock_bits)                                   \
2531   declare_constant(markWord::max_hash_bits)                               \
2532   declare_constant(markWord::hash_bits)                                   \

2533                                                                           \
2534   declare_constant(markWord::lock_shift)                                  \
2535   declare_constant(markWord::age_shift)                                   \
2536   declare_constant(markWord::hash_shift)                                  \


2537                                                                           \
2538   declare_constant(markWord::lock_mask)                                   \
2539   declare_constant(markWord::lock_mask_in_place)                          \
2540   declare_constant(markWord::age_mask)                                    \
2541   declare_constant(markWord::age_mask_in_place)                           \
2542   declare_constant(markWord::hash_mask)                                   \
2543   declare_constant(markWord::hash_mask_in_place)                          \


2544                                                                           \
2545   declare_constant(markWord::locked_value)                                \
2546   declare_constant(markWord::unlocked_value)                              \
2547   declare_constant(markWord::monitor_value)                               \
2548   declare_constant(markWord::marked_value)                                \
2549                                                                           \
2550   declare_constant(markWord::no_hash)                                     \
2551   declare_constant(markWord::no_hash_in_place)                            \
2552   declare_constant(markWord::no_lock_in_place)                            \
2553   declare_constant(markWord::max_age)                                     \
2554                                                                           \
2555   /* InvocationCounter constants */                                       \
2556   declare_constant(InvocationCounter::count_increment)                    \
2557   declare_constant(InvocationCounter::count_shift)                        \
2558                                                                           \
2559   /* ObjectMonitor constants */                                           \
2560   declare_constant(ObjectMonitor::ANONYMOUS_OWNER)                        \
2561 
2562 //--------------------------------------------------------------------------------
2563 //

3060       return 1;
3061     }
3062     os::free(s);
3063   }
3064   if (!isRecurse) {
3065     tty->print_cr("type \"%s\" not found", typeName);
3066   }
3067   return 0;
3068 }
3069 
3070 int VMStructs::findType(const char* typeName) {
3071   VMTypeEntry* types = gHotSpotVMTypes;
3072 
3073   return recursiveFindType(types, typeName, false);
3074 }
3075 
3076 void vmStructs_init() {
3077   VMStructs::init();
3078 }
3079 #endif // ASSERT



























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

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

2525 #define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
2526                                                                           \
2527   /****************/                                                      \
2528   /* GC constants */                                                      \
2529   /****************/                                                      \
2530                                                                           \
2531   VM_LONG_CONSTANTS_GC(declare_constant)                                  \
2532                                                                           \
2533   /*********************/                                                 \
2534   /* markWord constants */                                                \
2535   /*********************/                                                 \
2536                                                                           \
2537   /* Note: some of these are declared as long constants just for */       \
2538   /* consistency. The mask constants are the only ones requiring */       \
2539   /* 64 bits (on 64-bit platforms). */                                    \
2540                                                                           \
2541   declare_constant(markWord::age_bits)                                    \
2542   declare_constant(markWord::lock_bits)                                   \
2543   declare_constant(markWord::max_hash_bits)                               \
2544   declare_constant(markWord::hash_bits)                                   \
2545   declare_constant(markWord::hash_bits_compact)                           \
2546                                                                           \
2547   declare_constant(markWord::lock_shift)                                  \
2548   declare_constant(markWord::age_shift)                                   \
2549   declare_constant(markWord::hash_shift)                                  \
2550   declare_constant(markWord::hash_shift_compact)                          \
2551   LP64_ONLY(declare_constant(markWord::klass_shift))                      \
2552                                                                           \
2553   declare_constant(markWord::lock_mask)                                   \
2554   declare_constant(markWord::lock_mask_in_place)                          \
2555   declare_constant(markWord::age_mask)                                    \
2556   declare_constant(markWord::age_mask_in_place)                           \
2557   declare_constant(markWord::hash_mask)                                   \
2558   declare_constant(markWord::hash_mask_in_place)                          \
2559   declare_constant(markWord::hash_mask_compact)                           \
2560   declare_constant(markWord::hash_mask_compact_in_place)                  \
2561                                                                           \
2562   declare_constant(markWord::locked_value)                                \
2563   declare_constant(markWord::unlocked_value)                              \
2564   declare_constant(markWord::monitor_value)                               \
2565   declare_constant(markWord::marked_value)                                \
2566                                                                           \
2567   declare_constant(markWord::no_hash)                                     \
2568   declare_constant(markWord::no_hash_in_place)                            \
2569   declare_constant(markWord::no_lock_in_place)                            \
2570   declare_constant(markWord::max_age)                                     \
2571                                                                           \
2572   /* InvocationCounter constants */                                       \
2573   declare_constant(InvocationCounter::count_increment)                    \
2574   declare_constant(InvocationCounter::count_shift)                        \
2575                                                                           \
2576   /* ObjectMonitor constants */                                           \
2577   declare_constant(ObjectMonitor::ANONYMOUS_OWNER)                        \
2578 
2579 //--------------------------------------------------------------------------------
2580 //

3077       return 1;
3078     }
3079     os::free(s);
3080   }
3081   if (!isRecurse) {
3082     tty->print_cr("type \"%s\" not found", typeName);
3083   }
3084   return 0;
3085 }
3086 
3087 int VMStructs::findType(const char* typeName) {
3088   VMTypeEntry* types = gHotSpotVMTypes;
3089 
3090   return recursiveFindType(types, typeName, false);
3091 }
3092 
3093 void vmStructs_init() {
3094   VMStructs::init();
3095 }
3096 #endif // ASSERT
3097 
3098 void VMStructs::compact_headers_overrides() {
3099   assert(UseCompactObjectHeaders, "Should have been checked before");
3100 
3101   // We cannot allow SA and other facilities to poke into VM internal fields
3102   // expecting the class pointers there. This will crash in the best case,
3103   // or yield incorrect execution in the worst case. This code hides the
3104   // risky fields from external code by replacing their original container
3105   // type to a fake one. The fake type should exist for VMStructs verification
3106   // code to work.
3107 
3108   size_t len = localHotSpotVMStructsLength();
3109   for (size_t off = 0; off < len; off++) {
3110     VMStructEntry* e = &localHotSpotVMStructs[off];
3111     if (e == nullptr) continue;
3112     if (e->typeName == nullptr) continue;
3113     if (e->fieldName == nullptr) continue;
3114 
3115     if (strcmp(e->typeName, "oopDesc") == 0) {
3116       if ((strcmp(e->fieldName, "_metadata._klass") == 0) ||
3117           (strcmp(e->fieldName, "_metadata._compressed_klass") == 0)) {
3118         e->typeName = "fakeOopDesc";
3119       }
3120     }
3121   }
3122 }
< prev index next >