< 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 // Global offset instead of address for an oop within a java object.
 37 enum class narrowOop : uint32_t { null = 0 };
 38 
 39 // If compressed klass pointers then use narrowKlass.
 40 typedef juint  narrowKlass;
 41 
 42 typedef void* OopOrNarrowOopStar;
 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()

129        }                                                                   \
130        type##Oop& operator=(const type##Oop& o) {                          \
131             oop::operator=(o);                                             \
132             return *this;                                                  \
133        }                                                                   \
134    };                                                                      \
135                                                                            \
136    template<>                                                              \
137    struct PrimitiveConversions::Translate<type##Oop> : public TrueType {   \
138      typedef type##Oop Value;                                              \
139      typedef type##OopDesc* Decayed;                                       \
140                                                                            \
141      static Decayed decay(Value x) { return (type##OopDesc*)x.obj(); }     \
142      static Value recover(Decayed x) { return type##Oop(x); }              \
143    };
144 
145 DEF_OOP(instance);
146 DEF_OOP(array);
147 DEF_OOP(objArray);
148 DEF_OOP(typeArray);

149 
150 #endif // CHECK_UNHANDLED_OOPS
151 
152 // Cast functions to convert to and from oops.
153 template <typename T> inline oop cast_to_oop(T value) {
154   return (oopDesc*)value;
155 }
156 template <typename T> inline T cast_from_oop(oop o) {
157   return (T)(CHECK_UNHANDLED_OOPS_ONLY((oopDesc*))o);
158 }
159 
160 // The metadata hierarchy is separate from the oop hierarchy
161 
162 //      class MetaspaceObj
163 class   ConstMethod;
164 class   ConstantPoolCache;
165 class   MethodData;
166 //      class Metadata
167 class   Method;
168 class   ConstantPool;
169 //      class CHeapObj
170 class   CompiledICHolder;
171 
172 
173 // The klass hierarchy is separate from the oop hierarchy.
174 
175 class Klass;
176 class   InstanceKlass;
177 class     InstanceMirrorKlass;
178 class     InstanceClassLoaderKlass;
179 class     InstanceRefKlass;

180 class   ArrayKlass;
181 class     ObjArrayKlass;
182 class     TypeArrayKlass;

183 
184 #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 // Global offset instead of address for an oop within a java object.
 37 enum class narrowOop : uint32_t { null = 0 };
 38 
 39 // If compressed klass pointers then use narrowKlass.
 40 typedef juint  narrowKlass;
 41 
 42 typedef void* OopOrNarrowOopStar;
 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     flatArrayOopDesc*           flatArrayOop;
 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()

130        }                                                                   \
131        type##Oop& operator=(const type##Oop& o) {                          \
132             oop::operator=(o);                                             \
133             return *this;                                                  \
134        }                                                                   \
135    };                                                                      \
136                                                                            \
137    template<>                                                              \
138    struct PrimitiveConversions::Translate<type##Oop> : public TrueType {   \
139      typedef type##Oop Value;                                              \
140      typedef type##OopDesc* Decayed;                                       \
141                                                                            \
142      static Decayed decay(Value x) { return (type##OopDesc*)x.obj(); }     \
143      static Value recover(Decayed x) { return type##Oop(x); }              \
144    };
145 
146 DEF_OOP(instance);
147 DEF_OOP(array);
148 DEF_OOP(objArray);
149 DEF_OOP(typeArray);
150 DEF_OOP(flatArray);
151 
152 #endif // CHECK_UNHANDLED_OOPS
153 
154 // Cast functions to convert to and from oops.
155 template <typename T> inline oop cast_to_oop(T value) {
156   return (oopDesc*)value;
157 }
158 template <typename T> inline T cast_from_oop(oop o) {
159   return (T)(CHECK_UNHANDLED_OOPS_ONLY((oopDesc*))o);
160 }
161 
162 // The metadata hierarchy is separate from the oop hierarchy
163 
164 //      class MetaspaceObj
165 class   ConstMethod;
166 class   ConstantPoolCache;
167 class   MethodData;
168 //      class Metadata
169 class   Method;
170 class   ConstantPool;
171 //      class CHeapObj
172 class   CompiledICHolder;
173 
174 
175 // The klass hierarchy is separate from the oop hierarchy.
176 
177 class Klass;
178 class   InstanceKlass;
179 class     InstanceMirrorKlass;
180 class     InstanceClassLoaderKlass;
181 class     InstanceRefKlass;
182 class     InlineKlass;
183 class   ArrayKlass;
184 class     ObjArrayKlass;
185 class     TypeArrayKlass;
186 class     FlatArrayKlass;
187 
188 #endif // SHARE_OOPS_OOPSHIERARCHY_HPP
< prev index next >