< prev index next >

src/hotspot/share/oops/oopsHierarchy.hpp

Print this page

 30 
 31 #include <type_traits>
 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 // Global offset instead of address for an oop within a java object.
 38 enum class narrowOop : uint32_t { null = 0 };
 39 
 40 typedef void* OopOrNarrowOopStar;
 41 
 42 #ifndef CHECK_UNHANDLED_OOPS
 43 
 44 typedef class oopDesc*                    oop;
 45 typedef class   instanceOopDesc*            instanceOop;
 46 typedef class     stackChunkOopDesc*          stackChunkOop;
 47 typedef class   arrayOopDesc*               arrayOop;
 48 typedef class     objArrayOopDesc*            objArrayOop;
 49 typedef class     typeArrayOopDesc*           typeArrayOop;

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

138        type##Oop& operator=(const type##Oop& o) {                              \
139             oop::operator=(o);                                                 \
140             return *this;                                                      \
141        }                                                                       \
142    };                                                                          \
143                                                                                \
144    template<>                                                                  \
145    struct PrimitiveConversions::Translate<type##Oop> : public std::true_type { \
146      typedef type##Oop Value;                                                  \
147      typedef type##OopDesc* Decayed;                                           \
148                                                                                \
149      static Decayed decay(Value x) { return (type##OopDesc*)x.obj(); }         \
150      static Value recover(Decayed x) { return type##Oop(x); }                  \
151    };
152 
153 DEF_OOP(instance);
154 DEF_OOP(stackChunk);
155 DEF_OOP(array);
156 DEF_OOP(objArray);
157 DEF_OOP(typeArray);

158 
159 #endif // CHECK_UNHANDLED_OOPS
160 
161 // Cast functions to convert to and from oops.
162 template <typename T> inline oop cast_to_oop(T value) {
163   return (oopDesc*)value;
164 }
165 template <typename T> inline T cast_from_oop(oop o) {
166   return (T)(CHECK_UNHANDLED_OOPS_ONLY((oopDesc*))o);
167 }
168 
169 inline intptr_t p2i(narrowOop o) {
170   return static_cast<intptr_t>(o);
171 }
172 
173 // The metadata hierarchy is separate from the oop hierarchy
174 
175 //      class MetaspaceObj
176 class   ConstMethod;
177 class   ConstantPoolCache;
178 class   MethodData;
179 //      class Metadata
180 class   Method;
181 class   ConstantPool;
182 
183 // The klass hierarchy is separate from the oop hierarchy.
184 
185 class Klass;
186 class   InstanceKlass;

187 class     InstanceMirrorKlass;
188 class     InstanceClassLoaderKlass;
189 class     InstanceRefKlass;
190 class     InstanceStackChunkKlass;
191 class   ArrayKlass;
192 class     ObjArrayKlass;
193 class     TypeArrayKlass;

194 
195 #endif // SHARE_OOPS_OOPSHIERARCHY_HPP

 30 
 31 #include <type_traits>
 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 // Global offset instead of address for an oop within a java object.
 38 enum class narrowOop : uint32_t { null = 0 };
 39 
 40 typedef void* OopOrNarrowOopStar;
 41 
 42 #ifndef CHECK_UNHANDLED_OOPS
 43 
 44 typedef class oopDesc*                    oop;
 45 typedef class   instanceOopDesc*            instanceOop;
 46 typedef class     stackChunkOopDesc*          stackChunkOop;
 47 typedef class   arrayOopDesc*               arrayOop;
 48 typedef class     objArrayOopDesc*            objArrayOop;
 49 typedef class     typeArrayOopDesc*           typeArrayOop;
 50 typedef class     flatArrayOopDesc*           flatArrayOop;
 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()

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