annotate src/share/vm/oops/oopsHierarchy.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // OBJECT hierarchy
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // This hierarchy is a representation hierarchy, i.e. if A is a superclass
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // of B, A's representation is a prefix of B's representation.
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 #ifndef CHECK_UNHANDLED_OOPS
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 typedef class oopDesc* oop;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 typedef class instanceOopDesc* instanceOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 typedef class methodOopDesc* methodOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 typedef class constMethodOopDesc* constMethodOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 typedef class methodDataOopDesc* methodDataOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 typedef class arrayOopDesc* arrayOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 typedef class constantPoolOopDesc* constantPoolOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 typedef class constantPoolCacheOopDesc* constantPoolCacheOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 typedef class objArrayOopDesc* objArrayOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 typedef class typeArrayOopDesc* typeArrayOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 typedef class symbolOopDesc* symbolOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 typedef class klassOopDesc* klassOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 typedef class markOopDesc* markOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 typedef class compiledICHolderOopDesc* compiledICHolderOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // carefully chosen set of constructors and conversion operators to go
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // to and from the underlying oopDesc pointer type.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Because oop and its subclasses <type>Oop are class types, arbitrary
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // conversions are not accepted by the compiler, and you may get a message
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // about overloading ambiguity (between long and int is common when converting
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // from a constant in 64 bit mode), or unable to convert from type to 'oop'.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Applying a cast to one of these conversion operators first will get to the
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // underlying oopDesc* type if appropriate.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Converting NULL to oop to Handle implicit is no longer accepted by the
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // compiler because there are too many steps in the conversion. Use Handle()
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // instead, which generates less code anyway.
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 class Thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 typedef class markOopDesc* markOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 class PromotedObject;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 class oop {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 oopDesc* _o;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void register_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void unregister_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // friend class markOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void set_obj(const void* p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 raw_set_obj(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (CheckUnhandledOops) register_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void raw_set_obj(const void* p) { _o = (oopDesc*)p; }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 oop() { set_obj(NULL); }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 oop(const volatile oop& o) { set_obj(o.obj()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 oop(const void* p) { set_obj(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 oop(intptr_t i) { set_obj((void *)i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
87 oop(int i) { set_obj((void *)i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ~oop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (CheckUnhandledOops) unregister_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 oopDesc* obj() const volatile { return _o; }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // General access
a61af66fc99e Initial load
duke
parents:
diff changeset
96 oopDesc* operator->() const { return obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 bool operator==(const oop o) const { return obj() == o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 bool operator==(void *p) const { return obj() == p; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 bool operator!=(const oop o) const { return obj() != o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 bool operator!=(void *p) const { return obj() != p; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 bool operator==(intptr_t p) const { return obj() == (oopDesc*)p; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 bool operator!=(intptr_t p) const { return obj() != (oopDesc*)p; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 bool operator<(oop o) const { return obj() < o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool operator>(oop o) const { return obj() > o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 bool operator<=(oop o) const { return obj() <= o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 bool operator>=(oop o) const { return obj() >= o.obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 bool operator!() const { return !obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Cast
a61af66fc99e Initial load
duke
parents:
diff changeset
111 operator void* () const { return (void *)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 operator HeapWord* () const { return (HeapWord*)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 operator oopDesc* () const { return obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 operator intptr_t* () const { return (intptr_t*)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 operator PromotedObject* () const { return (PromotedObject*)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 operator markOop () const { return markOop(obj()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 operator address () const { return (address)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 operator intptr_t () const { return (intptr_t)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // from javaCalls.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
122 operator jobject () const { return (jobject)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // from javaClasses.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
124 operator JavaThread* () const { return (JavaThread*)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // from jvm.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
126 operator jlong* () const { return (jlong*)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // from parNewGeneration and other things that want to get to the end of
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 operator oop* () const { return (oop *)obj(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 };
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #define DEF_OOP(type) \
a61af66fc99e Initial load
duke
parents:
diff changeset
134 class type##OopDesc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
135 class type##Oop : public oop { \
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public: \
a61af66fc99e Initial load
duke
parents:
diff changeset
137 type##Oop() : oop() {} \
a61af66fc99e Initial load
duke
parents:
diff changeset
138 type##Oop(const volatile oop& o) : oop(o) {} \
a61af66fc99e Initial load
duke
parents:
diff changeset
139 type##Oop(const void* p) : oop(p) {} \
a61af66fc99e Initial load
duke
parents:
diff changeset
140 operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \
a61af66fc99e Initial load
duke
parents:
diff changeset
141 type##OopDesc* operator->() const { \
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return (type##OopDesc*)obj(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
143 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }; \
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 DEF_OOP(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 DEF_OOP(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 DEF_OOP(methodData);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 DEF_OOP(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 DEF_OOP(constMethod);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 DEF_OOP(constantPool);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 DEF_OOP(constantPoolCache);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 DEF_OOP(objArray);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 DEF_OOP(typeArray);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 DEF_OOP(symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 DEF_OOP(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 DEF_OOP(compiledICHolder);
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 #endif // CHECK_UNHANDLED_OOPS
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // The klass hierarchy is separate from the oop hierarchy.
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 class Klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 class instanceKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 class instanceRefKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 class methodKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 class constMethodKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 class methodDataKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 class klassKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 class instanceKlassKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 class arrayKlassKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 class objArrayKlassKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 class typeArrayKlassKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 class arrayKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 class constantPoolKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 class constantPoolCacheKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 class objArrayKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 class typeArrayKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 class symbolKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 class compiledICHolderKlass;