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