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