< prev index next >

src/hotspot/share/oops/oopsHierarchy.hpp

Print this page




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

  51 
  52 #else
  53 
  54 // When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
  55 // carefully chosen set of constructors and conversion operators to go
  56 // to and from the underlying oopDesc pointer type.
  57 //
  58 // Because oop and its subclasses <type>Oop are class types, arbitrary
  59 // conversions are not accepted by the compiler.  Applying a cast to
  60 // an oop will cause the best matched conversion operator to be
  61 // invoked returning the underlying oopDesc* type if appropriate.
  62 // No copy constructors, explicit user conversions or operators of
  63 // numerical type should be defined within the oop class. Most C++
  64 // compilers will issue a compile time error concerning the overloading
  65 // ambiguity between operators of numerical and pointer types. If
  66 // a conversion to or from an oop to a numerical type is needed,
  67 // use the inline template methods, cast_*_oop, defined below.
  68 //
  69 // Converting NULL to oop to Handle implicit is no longer accepted by the
  70 // 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 
 184 #endif // CHECK_UNHANDLED_OOPS
 185 
 186 // For CHECK_UNHANDLED_OOPS, it is ambiguous C++ behavior to have the oop
 187 // structure contain explicit user defined conversions of both numerical
 188 // and pointer type. Define inline methods to provide the numerical conversions.
 189 template <class T> inline oop cast_to_oop(T value) {
 190   return (oop)(CHECK_UNHANDLED_OOPS_ONLY((void *))(value));
 191 }
 192 template <class T> inline T cast_from_oop(oop o) {
 193   return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o);
 194 }
 195 
 196 inline bool check_obj_alignment(oop obj) {
 197   return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 198 }
 199 
 200 // The metadata hierarchy is separate from the oop hierarchy
 201 
 202 //      class MetaspaceObj
 203 class   ConstMethod;
 204 class   ConstantPoolCache;
 205 class   MethodData;
 206 //      class Metadata
 207 class   Method;
 208 class   ConstantPool;
 209 //      class CHeapObj
 210 class   CompiledICHolder;
 211 
 212 
 213 // The klass hierarchy is separate from the oop hierarchy.
 214 
 215 class Klass;
 216 class   InstanceKlass;
 217 class     InstanceMirrorKlass;
 218 class     InstanceClassLoaderKlass;
 219 class     InstanceRefKlass;

 220 class   ArrayKlass;
 221 class     ObjArrayKlass;
 222 class     TypeArrayKlass;

 223 
 224 #endif // SHARE_OOPS_OOPSHIERARCHY_HPP


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


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