Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 1997-2007 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 */ | |
24 | |
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. | |
28 | |
29 #ifndef CHECK_UNHANDLED_OOPS | |
30 | |
31 typedef class oopDesc* oop; | |
32 typedef class instanceOopDesc* instanceOop; | |
33 typedef class methodOopDesc* methodOop; | |
34 typedef class constMethodOopDesc* constMethodOop; | |
35 typedef class methodDataOopDesc* methodDataOop; | |
36 typedef class arrayOopDesc* arrayOop; | |
37 typedef class constantPoolOopDesc* constantPoolOop; | |
38 typedef class constantPoolCacheOopDesc* constantPoolCacheOop; | |
39 typedef class objArrayOopDesc* objArrayOop; | |
40 typedef class typeArrayOopDesc* typeArrayOop; | |
41 typedef class symbolOopDesc* symbolOop; | |
42 typedef class klassOopDesc* klassOop; | |
43 typedef class markOopDesc* markOop; | |
44 typedef class compiledICHolderOopDesc* compiledICHolderOop; | |
45 | |
46 #else | |
47 | |
48 | |
49 // When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a | |
50 // carefully chosen set of constructors and conversion operators to go | |
51 // to and from the underlying oopDesc pointer type. | |
52 // | |
53 // Because oop and its subclasses <type>Oop are class types, arbitrary | |
54 // conversions are not accepted by the compiler, and you may get a message | |
55 // about overloading ambiguity (between long and int is common when converting | |
56 // from a constant in 64 bit mode), or unable to convert from type to 'oop'. | |
57 // Applying a cast to one of these conversion operators first will get to the | |
58 // underlying oopDesc* type if appropriate. | |
59 // Converting NULL to oop to Handle implicit is no longer accepted by the | |
60 // compiler because there are too many steps in the conversion. Use Handle() | |
61 // instead, which generates less code anyway. | |
62 | |
63 class Thread; | |
64 typedef class markOopDesc* markOop; | |
65 class PromotedObject; | |
66 | |
67 | |
68 class oop { | |
69 oopDesc* _o; | |
70 | |
71 void register_oop(); | |
72 void unregister_oop(); | |
73 | |
74 // friend class markOop; | |
75 public: | |
76 void set_obj(const void* p) { | |
77 raw_set_obj(p); | |
78 if (CheckUnhandledOops) register_oop(); | |
79 } | |
80 void raw_set_obj(const void* p) { _o = (oopDesc*)p; } | |
81 | |
82 oop() { set_obj(NULL); } | |
83 oop(const volatile oop& o) { set_obj(o.obj()); } | |
84 oop(const void* p) { set_obj(p); } | |
85 oop(intptr_t i) { set_obj((void *)i); } | |
86 #ifdef _LP64 | |
87 oop(int i) { set_obj((void *)i); } | |
88 #endif | |
89 ~oop() { | |
90 if (CheckUnhandledOops) unregister_oop(); | |
91 } | |
92 | |
93 oopDesc* obj() const volatile { return _o; } | |
94 | |
95 // General access | |
96 oopDesc* operator->() const { return obj(); } | |
97 bool operator==(const oop o) const { return obj() == o.obj(); } | |
98 bool operator==(void *p) const { return obj() == p; } | |
99 bool operator!=(const oop o) const { return obj() != o.obj(); } | |
100 bool operator!=(void *p) const { return obj() != p; } | |
101 bool operator==(intptr_t p) const { return obj() == (oopDesc*)p; } | |
102 bool operator!=(intptr_t p) const { return obj() != (oopDesc*)p; } | |
103 | |
104 bool operator<(oop o) const { return obj() < o.obj(); } | |
105 bool operator>(oop o) const { return obj() > o.obj(); } | |
106 bool operator<=(oop o) const { return obj() <= o.obj(); } | |
107 bool operator>=(oop o) const { return obj() >= o.obj(); } | |
108 bool operator!() const { return !obj(); } | |
109 | |
110 // Cast | |
111 operator void* () const { return (void *)obj(); } | |
112 operator HeapWord* () const { return (HeapWord*)obj(); } | |
113 operator oopDesc* () const { return obj(); } | |
114 operator intptr_t* () const { return (intptr_t*)obj(); } | |
115 operator PromotedObject* () const { return (PromotedObject*)obj(); } | |
116 operator markOop () const { return markOop(obj()); } | |
117 | |
118 operator address () const { return (address)obj(); } | |
119 operator intptr_t () const { return (intptr_t)obj(); } | |
120 | |
121 // from javaCalls.cpp | |
122 operator jobject () const { return (jobject)obj(); } | |
123 // from javaClasses.cpp | |
124 operator JavaThread* () const { return (JavaThread*)obj(); } | |
125 // from jvm.cpp | |
126 operator jlong* () const { return (jlong*)obj(); } | |
127 | |
128 // from parNewGeneration and other things that want to get to the end of | |
129 // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp) | |
130 operator oop* () const { return (oop *)obj(); } | |
131 }; | |
132 | |
133 #define DEF_OOP(type) \ | |
134 class type##OopDesc; \ | |
135 class type##Oop : public oop { \ | |
136 public: \ | |
137 type##Oop() : oop() {} \ | |
138 type##Oop(const volatile oop& o) : oop(o) {} \ | |
139 type##Oop(const void* p) : oop(p) {} \ | |
140 operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \ | |
141 type##OopDesc* operator->() const { \ | |
142 return (type##OopDesc*)obj(); \ | |
143 } \ | |
144 }; \ | |
145 | |
146 DEF_OOP(instance); | |
147 DEF_OOP(method); | |
148 DEF_OOP(methodData); | |
149 DEF_OOP(array); | |
150 DEF_OOP(constMethod); | |
151 DEF_OOP(constantPool); | |
152 DEF_OOP(constantPoolCache); | |
153 DEF_OOP(objArray); | |
154 DEF_OOP(typeArray); | |
155 DEF_OOP(symbol); | |
156 DEF_OOP(klass); | |
157 DEF_OOP(compiledICHolder); | |
158 | |
159 #endif // CHECK_UNHANDLED_OOPS | |
160 | |
161 // The klass hierarchy is separate from the oop hierarchy. | |
162 | |
163 class Klass; | |
164 class instanceKlass; | |
165 class instanceRefKlass; | |
166 class methodKlass; | |
167 class constMethodKlass; | |
168 class methodDataKlass; | |
169 class klassKlass; | |
170 class instanceKlassKlass; | |
171 class arrayKlassKlass; | |
172 class objArrayKlassKlass; | |
173 class typeArrayKlassKlass; | |
174 class arrayKlass; | |
175 class constantPoolKlass; | |
176 class constantPoolCacheKlass; | |
177 class objArrayKlass; | |
178 class typeArrayKlass; | |
179 class symbolKlass; | |
180 class compiledICHolderKlass; |