hotspot/src/share/vm/oops/oopsHierarchy.hpp
author never
Fri, 18 Mar 2011 16:00:34 -0700
changeset 8725 8c1e3dd5fe1b
parent 8076 96d498ec7ae1
child 13728 882756847a04
permissions -rw-r--r--
7017732: move static fields into Class to prepare for perm gen removal Reviewed-by: kvn, coleenp, twisti, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8076
diff changeset
     2
 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_OOPS_OOPSHIERARCHY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OOPS_OOPSHIERARCHY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// OBJECT hierarchy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// This hierarchy is a representation hierarchy, i.e. if A is a superclass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// of B, A's representation is a prefix of B's representation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    35
typedef juint narrowOop; // Offset instead of address for an oop within a java object
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    36
typedef class klassOopDesc* wideKlassOop; // to keep SA happy and unhandled oop
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    37
                                          // detector happy.
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 2105
diff changeset
    38
typedef void* OopOrNarrowOopStar;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    39
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
#ifndef CHECK_UNHANDLED_OOPS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    42
typedef class oopDesc*                            oop;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
typedef class   instanceOopDesc*            instanceOop;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    44
typedef class   methodOopDesc*                    methodOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    45
typedef class   constMethodOopDesc*            constMethodOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    46
typedef class   methodDataOopDesc*            methodDataOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    47
typedef class   arrayOopDesc*                    arrayOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
typedef class     objArrayOopDesc*            objArrayOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
typedef class     typeArrayOopDesc*            typeArrayOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    50
typedef class   constantPoolOopDesc*            constantPoolOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    51
typedef class   constantPoolCacheOopDesc*   constantPoolCacheOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    52
typedef class   klassOopDesc*                    klassOop;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    53
typedef class   markOopDesc*                    markOop;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
typedef class   compiledICHolderOopDesc*    compiledICHolderOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// carefully chosen set of constructors and conversion operators to go
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// to and from the underlying oopDesc pointer type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// Because oop and its subclasses <type>Oop are class types, arbitrary
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// conversions are not accepted by the compiler, and you may get a message
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// about overloading ambiguity (between long and int is common when converting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// from a constant in 64 bit mode), or unable to convert from type to 'oop'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// Applying a cast to one of these conversion operators first will get to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// underlying oopDesc* type if appropriate.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// Converting NULL to oop to Handle implicit is no longer accepted by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// compiler because there are too many steps in the conversion.  Use Handle()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// instead, which generates less code anyway.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class Thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
typedef class   markOopDesc*                markOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
class PromotedObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
class oop {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  oopDesc* _o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void register_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void unregister_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // friend class markOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void set_obj(const void* p)         {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    raw_set_obj(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    if (CheckUnhandledOops) register_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  void raw_set_obj(const void* p)     { _o = (oopDesc*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  oop()                               { set_obj(NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  oop(const volatile oop& o)          { set_obj(o.obj()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  oop(const void* p)                  { set_obj(p); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  oop(intptr_t i)                     { set_obj((void *)i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  oop(int i)                          { set_obj((void *)i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  ~oop()                              {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    if (CheckUnhandledOops) unregister_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  oopDesc* obj()  const volatile      { return _o; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // General access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  oopDesc*  operator->() const        { return obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  bool operator==(const oop o) const  { return obj() == o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  bool operator==(void *p) const      { return obj() == p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  bool operator!=(const oop o) const  { return obj() != o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  bool operator!=(void *p) const      { return obj() != p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  bool operator==(intptr_t p) const   { return obj() == (oopDesc*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  bool operator!=(intptr_t p) const   { return obj() != (oopDesc*)p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  bool operator<(oop o) const         { return obj() < o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  bool operator>(oop o) const         { return obj() > o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  bool operator<=(oop o) const        { return obj() <= o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool operator>=(oop o) const        { return obj() >= o.obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  bool operator!() const              { return !obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Cast
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  operator void* () const             { return (void *)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  operator HeapWord* () const         { return (HeapWord*)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  operator oopDesc* () const          { return obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  operator intptr_t* () const         { return (intptr_t*)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  operator PromotedObject* () const   { return (PromotedObject*)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  operator markOop () const           { return markOop(obj()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  operator address   () const         { return (address)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  operator intptr_t () const          { return (intptr_t)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // from javaCalls.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  operator jobject () const           { return (jobject)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // from javaClasses.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  operator JavaThread* () const       { return (JavaThread*)obj(); }
1889
24b003a6fe46 6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents: 670
diff changeset
   135
24b003a6fe46 6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents: 670
diff changeset
   136
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // from jvm.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  operator jlong* () const            { return (jlong*)obj(); }
1889
24b003a6fe46 6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents: 670
diff changeset
   139
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // from parNewGeneration and other things that want to get to the end of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  operator oop* () const              { return (oop *)obj(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
#define DEF_OOP(type)                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
   class type##OopDesc;                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
   class type##Oop : public oop {                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
     public:                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
       type##Oop() : oop() {}                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
       type##Oop(const volatile oop& o) : oop(o) {}                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
       type##Oop(const void* p) : oop(p) {}                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
       operator type##OopDesc* () const { return (type##OopDesc*)obj(); }  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
       type##OopDesc* operator->() const {                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
            return (type##OopDesc*)obj();                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
       }                                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
   };                                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
DEF_OOP(instance);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
DEF_OOP(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
DEF_OOP(methodData);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
DEF_OOP(array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
DEF_OOP(constMethod);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
DEF_OOP(constantPool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
DEF_OOP(constantPoolCache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
DEF_OOP(objArray);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
DEF_OOP(typeArray);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
DEF_OOP(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
DEF_OOP(compiledICHolder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
#endif // CHECK_UNHANDLED_OOPS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
// The klass hierarchy is separate from the oop hierarchy.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
class Klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
class   instanceKlass;
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8076
diff changeset
   177
class     instanceMirrorKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
class     instanceRefKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
class   methodKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
class   constMethodKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
class   methodDataKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
class   klassKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
class     instanceKlassKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
class     arrayKlassKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
class       objArrayKlassKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
class       typeArrayKlassKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
class   arrayKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
class     objArrayKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
class     typeArrayKlass;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   190
class   constantPoolKlass;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   191
class   constantPoolCacheKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
class   compiledICHolderKlass;
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   193
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   194
#endif // SHARE_VM_OOPS_OOPSHIERARCHY_HPP