< prev index next >

src/hotspot/share/oops/oopsHierarchy.hpp

Print this page




  32 
  33 // OBJECT hierarchy
  34 // This hierarchy is a representation hierarchy, i.e. if A is a superclass
  35 // of B, A's representation is a prefix of B's representation.
  36 
  37 typedef juint narrowOop; // Offset instead of address for an oop within a java object
  38 
  39 // If compressed klass pointers then use narrowKlass.
  40 typedef juint  narrowKlass;
  41 
  42 typedef void* OopOrNarrowOopStar;
  43 typedef class   markOopDesc*                markOop;
  44 
  45 #ifndef CHECK_UNHANDLED_OOPS
  46 
  47 typedef class oopDesc*                            oop;
  48 typedef class   instanceOopDesc*            instanceOop;
  49 typedef class   arrayOopDesc*                    arrayOop;
  50 typedef class     objArrayOopDesc*            objArrayOop;
  51 typedef class     typeArrayOopDesc*            typeArrayOop;

  52 
  53 #else
  54 
  55 // When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
  56 // carefully chosen set of constructors and conversion operators to go
  57 // to and from the underlying oopDesc pointer type.
  58 //
  59 // Because oop and its subclasses <type>Oop are class types, arbitrary
  60 // conversions are not accepted by the compiler.  Applying a cast to
  61 // an oop will cause the best matched conversion operator to be
  62 // invoked returning the underlying oopDesc* type if appropriate.
  63 // No copy constructors, explicit user conversions or operators of
  64 // numerical type should be defined within the oop class. Most C++
  65 // compilers will issue a compile time error concerning the overloading
  66 // ambiguity between operators of numerical and pointer types. If
  67 // a conversion to or from an oop to a numerical type is needed,
  68 // use the inline template methods, cast_*_oop, defined below.
  69 //
  70 // Converting NULL to oop to Handle implicit is no longer accepted by the
  71 // compiler because there are too many steps in the conversion.  Use Handle()


 162        }                                                                   \
 163        volatile type##Oop& operator=(const volatile type##Oop& o) volatile {\
 164             (void)const_cast<oop&>(oop::operator=(o));                     \
 165             return *this;                                                  \
 166        }                                                                   \
 167    };                                                                      \
 168                                                                            \
 169    template<>                                                              \
 170    struct PrimitiveConversions::Translate<type##Oop> : public TrueType {   \
 171      typedef type##Oop Value;                                              \
 172      typedef type##OopDesc* Decayed;                                       \
 173                                                                            \
 174      static Decayed decay(Value x) { return (type##OopDesc*)x.obj(); }     \
 175      static Value recover(Decayed x) { return type##Oop(x); }              \
 176    };
 177 
 178 DEF_OOP(instance);
 179 DEF_OOP(array);
 180 DEF_OOP(objArray);
 181 DEF_OOP(typeArray);

 182 
 183 #endif // CHECK_UNHANDLED_OOPS
 184 
 185 // For CHECK_UNHANDLED_OOPS, it is ambiguous C++ behavior to have the oop
 186 // structure contain explicit user defined conversions of both numerical
 187 // and pointer type. Define inline methods to provide the numerical conversions.
 188 template <class T> inline oop cast_to_oop(T value) {
 189   return (oop)(CHECK_UNHANDLED_OOPS_ONLY((void *))(value));
 190 }
 191 template <class T> inline T cast_from_oop(oop o) {
 192   return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o);
 193 }
 194 
 195 inline bool check_obj_alignment(oop obj) {
 196   return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 197 }
 198 
 199 // The metadata hierarchy is separate from the oop hierarchy
 200 
 201 //      class MetaspaceObj
 202 class   ConstMethod;
 203 class   ConstantPoolCache;
 204 class   MethodData;
 205 //      class Metadata
 206 class   Method;
 207 class   ConstantPool;
 208 //      class CHeapObj
 209 class   CompiledICHolder;
 210 
 211 
 212 // The klass hierarchy is separate from the oop hierarchy.
 213 
 214 class Klass;
 215 class   InstanceKlass;
 216 class     InstanceMirrorKlass;
 217 class     InstanceClassLoaderKlass;
 218 class     InstanceRefKlass;

 219 class   ArrayKlass;
 220 class     ObjArrayKlass;
 221 class     TypeArrayKlass;

 222 
 223 #endif // SHARE_OOPS_OOPSHIERARCHY_HPP


  32 
  33 // OBJECT hierarchy
  34 // This hierarchy is a representation hierarchy, i.e. if A is a superclass
  35 // of B, A's representation is a prefix of B's representation.
  36 
  37 typedef juint narrowOop; // Offset instead of address for an oop within a java object
  38 
  39 // If compressed klass pointers then use narrowKlass.
  40 typedef juint  narrowKlass;
  41 
  42 typedef void* OopOrNarrowOopStar;
  43 typedef class   markOopDesc*                markOop;
  44 
  45 #ifndef CHECK_UNHANDLED_OOPS
  46 
  47 typedef class oopDesc*                            oop;
  48 typedef class   instanceOopDesc*            instanceOop;
  49 typedef class   arrayOopDesc*                    arrayOop;
  50 typedef class     objArrayOopDesc*            objArrayOop;
  51 typedef class     typeArrayOopDesc*            typeArrayOop;
  52 typedef class     valueArrayOopDesc*            valueArrayOop;
  53 
  54 #else
  55 
  56 // When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
  57 // carefully chosen set of constructors and conversion operators to go
  58 // to and from the underlying oopDesc pointer type.
  59 //
  60 // Because oop and its subclasses <type>Oop are class types, arbitrary
  61 // conversions are not accepted by the compiler.  Applying a cast to
  62 // an oop will cause the best matched conversion operator to be
  63 // invoked returning the underlying oopDesc* type if appropriate.
  64 // No copy constructors, explicit user conversions or operators of
  65 // numerical type should be defined within the oop class. Most C++
  66 // compilers will issue a compile time error concerning the overloading
  67 // ambiguity between operators of numerical and pointer types. If
  68 // a conversion to or from an oop to a numerical type is needed,
  69 // use the inline template methods, cast_*_oop, defined below.
  70 //
  71 // Converting NULL to oop to Handle implicit is no longer accepted by the
  72 // compiler because there are too many steps in the conversion.  Use Handle()


 163        }                                                                   \
 164        volatile type##Oop& operator=(const volatile type##Oop& o) volatile {\
 165             (void)const_cast<oop&>(oop::operator=(o));                     \
 166             return *this;                                                  \
 167        }                                                                   \
 168    };                                                                      \
 169                                                                            \
 170    template<>                                                              \
 171    struct PrimitiveConversions::Translate<type##Oop> : public TrueType {   \
 172      typedef type##Oop Value;                                              \
 173      typedef type##OopDesc* Decayed;                                       \
 174                                                                            \
 175      static Decayed decay(Value x) { return (type##OopDesc*)x.obj(); }     \
 176      static Value recover(Decayed x) { return type##Oop(x); }              \
 177    };
 178 
 179 DEF_OOP(instance);
 180 DEF_OOP(array);
 181 DEF_OOP(objArray);
 182 DEF_OOP(typeArray);
 183 DEF_OOP(valueArray);
 184 
 185 #endif // CHECK_UNHANDLED_OOPS
 186 
 187 // For CHECK_UNHANDLED_OOPS, it is ambiguous C++ behavior to have the oop
 188 // structure contain explicit user defined conversions of both numerical
 189 // and pointer type. Define inline methods to provide the numerical conversions.
 190 template <class T> inline oop cast_to_oop(T value) {
 191   return (oop)(CHECK_UNHANDLED_OOPS_ONLY((void *))(value));
 192 }
 193 template <class T> inline T cast_from_oop(oop o) {
 194   return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o);
 195 }
 196 
 197 inline bool check_obj_alignment(oop obj) {
 198   return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 199 }
 200 
 201 // The metadata hierarchy is separate from the oop hierarchy
 202 
 203 //      class MetaspaceObj
 204 class   ConstMethod;
 205 class   ConstantPoolCache;
 206 class   MethodData;
 207 //      class Metadata
 208 class   Method;
 209 class   ConstantPool;
 210 //      class CHeapObj
 211 class   CompiledICHolder;
 212 
 213 
 214 // The klass hierarchy is separate from the oop hierarchy.
 215 
 216 class Klass;
 217 class   InstanceKlass;
 218 class     InstanceMirrorKlass;
 219 class     InstanceClassLoaderKlass;
 220 class     InstanceRefKlass;
 221 class     ValueKlass;
 222 class   ArrayKlass;
 223 class     ObjArrayKlass;
 224 class     TypeArrayKlass;
 225 class     ValueArrayKlass;
 226 
 227 #endif // SHARE_OOPS_OOPSHIERARCHY_HPP
< prev index next >