src/share/vm/oops/oopsHierarchy.hpp

changeset 435
a61af66fc99e
child 548
ba764ed4b6f2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/oopsHierarchy.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,180 @@
     1.4 +/*
     1.5 + * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// OBJECT hierarchy
    1.29 +// This hierarchy is a representation hierarchy, i.e. if A is a superclass
    1.30 +// of B, A's representation is a prefix of B's representation.
    1.31 +
    1.32 +#ifndef CHECK_UNHANDLED_OOPS
    1.33 +
    1.34 +typedef class oopDesc*                      oop;
    1.35 +typedef class   instanceOopDesc*            instanceOop;
    1.36 +typedef class   methodOopDesc*              methodOop;
    1.37 +typedef class   constMethodOopDesc*         constMethodOop;
    1.38 +typedef class   methodDataOopDesc*          methodDataOop;
    1.39 +typedef class   arrayOopDesc*               arrayOop;
    1.40 +typedef class     constantPoolOopDesc*      constantPoolOop;
    1.41 +typedef class     constantPoolCacheOopDesc* constantPoolCacheOop;
    1.42 +typedef class     objArrayOopDesc*          objArrayOop;
    1.43 +typedef class     typeArrayOopDesc*         typeArrayOop;
    1.44 +typedef class   symbolOopDesc*              symbolOop;
    1.45 +typedef class   klassOopDesc*               klassOop;
    1.46 +typedef class   markOopDesc*                markOop;
    1.47 +typedef class   compiledICHolderOopDesc*    compiledICHolderOop;
    1.48 +
    1.49 +#else
    1.50 +
    1.51 +
    1.52 +// When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
    1.53 +// carefully chosen set of constructors and conversion operators to go
    1.54 +// to and from the underlying oopDesc pointer type.
    1.55 +//
    1.56 +// Because oop and its subclasses <type>Oop are class types, arbitrary
    1.57 +// conversions are not accepted by the compiler, and you may get a message
    1.58 +// about overloading ambiguity (between long and int is common when converting
    1.59 +// from a constant in 64 bit mode), or unable to convert from type to 'oop'.
    1.60 +// Applying a cast to one of these conversion operators first will get to the
    1.61 +// underlying oopDesc* type if appropriate.
    1.62 +// Converting NULL to oop to Handle implicit is no longer accepted by the
    1.63 +// compiler because there are too many steps in the conversion.  Use Handle()
    1.64 +// instead, which generates less code anyway.
    1.65 +
    1.66 +class Thread;
    1.67 +typedef class   markOopDesc*                markOop;
    1.68 +class PromotedObject;
    1.69 +
    1.70 +
    1.71 +class oop {
    1.72 +  oopDesc* _o;
    1.73 +
    1.74 +  void register_oop();
    1.75 +  void unregister_oop();
    1.76 +
    1.77 +  // friend class markOop;
    1.78 +public:
    1.79 +  void set_obj(const void* p)         {
    1.80 +    raw_set_obj(p);
    1.81 +    if (CheckUnhandledOops) register_oop();
    1.82 +  }
    1.83 +  void raw_set_obj(const void* p)     { _o = (oopDesc*)p; }
    1.84 +
    1.85 +  oop()                               { set_obj(NULL); }
    1.86 +  oop(const volatile oop& o)          { set_obj(o.obj()); }
    1.87 +  oop(const void* p)                  { set_obj(p); }
    1.88 +  oop(intptr_t i)                     { set_obj((void *)i); }
    1.89 +#ifdef _LP64
    1.90 +  oop(int i)                          { set_obj((void *)i); }
    1.91 +#endif
    1.92 +  ~oop()                              {
    1.93 +    if (CheckUnhandledOops) unregister_oop();
    1.94 +  }
    1.95 +
    1.96 +  oopDesc* obj()  const volatile      { return _o; }
    1.97 +
    1.98 +  // General access
    1.99 +  oopDesc*  operator->() const        { return obj(); }
   1.100 +  bool operator==(const oop o) const  { return obj() == o.obj(); }
   1.101 +  bool operator==(void *p) const      { return obj() == p; }
   1.102 +  bool operator!=(const oop o) const  { return obj() != o.obj(); }
   1.103 +  bool operator!=(void *p) const      { return obj() != p; }
   1.104 +  bool operator==(intptr_t p) const   { return obj() == (oopDesc*)p; }
   1.105 +  bool operator!=(intptr_t p) const   { return obj() != (oopDesc*)p; }
   1.106 +
   1.107 +  bool operator<(oop o) const         { return obj() < o.obj(); }
   1.108 +  bool operator>(oop o) const         { return obj() > o.obj(); }
   1.109 +  bool operator<=(oop o) const        { return obj() <= o.obj(); }
   1.110 +  bool operator>=(oop o) const        { return obj() >= o.obj(); }
   1.111 +  bool operator!() const              { return !obj(); }
   1.112 +
   1.113 +  // Cast
   1.114 +  operator void* () const             { return (void *)obj(); }
   1.115 +  operator HeapWord* () const         { return (HeapWord*)obj(); }
   1.116 +  operator oopDesc* () const          { return obj(); }
   1.117 +  operator intptr_t* () const         { return (intptr_t*)obj(); }
   1.118 +  operator PromotedObject* () const   { return (PromotedObject*)obj(); }
   1.119 +  operator markOop () const           { return markOop(obj()); }
   1.120 +
   1.121 +  operator address   () const         { return (address)obj(); }
   1.122 +  operator intptr_t () const          { return (intptr_t)obj(); }
   1.123 +
   1.124 +  // from javaCalls.cpp
   1.125 +  operator jobject () const           { return (jobject)obj(); }
   1.126 +  // from javaClasses.cpp
   1.127 +  operator JavaThread* () const       { return (JavaThread*)obj(); }
   1.128 +  // from jvm.cpp
   1.129 +  operator jlong* () const            { return (jlong*)obj(); }
   1.130 +
   1.131 +  // from parNewGeneration and other things that want to get to the end of
   1.132 +  // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
   1.133 +  operator oop* () const              { return (oop *)obj(); }
   1.134 +};
   1.135 +
   1.136 +#define DEF_OOP(type)                                                      \
   1.137 +   class type##OopDesc;                                                    \
   1.138 +   class type##Oop : public oop {                                          \
   1.139 +     public:                                                               \
   1.140 +       type##Oop() : oop() {}                                              \
   1.141 +       type##Oop(const volatile oop& o) : oop(o) {}                        \
   1.142 +       type##Oop(const void* p) : oop(p) {}                                \
   1.143 +       operator type##OopDesc* () const { return (type##OopDesc*)obj(); }  \
   1.144 +       type##OopDesc* operator->() const {                                 \
   1.145 +            return (type##OopDesc*)obj();                                  \
   1.146 +       }                                                                   \
   1.147 +   };                                                                      \
   1.148 +
   1.149 +DEF_OOP(instance);
   1.150 +DEF_OOP(method);
   1.151 +DEF_OOP(methodData);
   1.152 +DEF_OOP(array);
   1.153 +DEF_OOP(constMethod);
   1.154 +DEF_OOP(constantPool);
   1.155 +DEF_OOP(constantPoolCache);
   1.156 +DEF_OOP(objArray);
   1.157 +DEF_OOP(typeArray);
   1.158 +DEF_OOP(symbol);
   1.159 +DEF_OOP(klass);
   1.160 +DEF_OOP(compiledICHolder);
   1.161 +
   1.162 +#endif // CHECK_UNHANDLED_OOPS
   1.163 +
   1.164 +// The klass hierarchy is separate from the oop hierarchy.
   1.165 +
   1.166 +class Klass;
   1.167 +class   instanceKlass;
   1.168 +class     instanceRefKlass;
   1.169 +class   methodKlass;
   1.170 +class   constMethodKlass;
   1.171 +class   methodDataKlass;
   1.172 +class   klassKlass;
   1.173 +class     instanceKlassKlass;
   1.174 +class     arrayKlassKlass;
   1.175 +class       objArrayKlassKlass;
   1.176 +class       typeArrayKlassKlass;
   1.177 +class   arrayKlass;
   1.178 +class     constantPoolKlass;
   1.179 +class     constantPoolCacheKlass;
   1.180 +class     objArrayKlass;
   1.181 +class     typeArrayKlass;
   1.182 +class       symbolKlass;
   1.183 +class   compiledICHolderKlass;

mercurial