Mon, 09 Jun 2008 11:51:19 -0400
6687581: Make CMS work with compressed oops
Summary: Make FreeChunk read markword instead of LSB in _klass pointer to indicate that it's a FreeChunk for compressed oops.
Reviewed-by: ysr, jmasa
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 */
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(); }
129 // from jvm.cpp
130 operator jlong* () const { return (jlong*)obj(); }
132 // from parNewGeneration and other things that want to get to the end of
133 // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
134 operator oop* () const { return (oop *)obj(); }
135 };
137 #define DEF_OOP(type) \
138 class type##OopDesc; \
139 class type##Oop : public oop { \
140 public: \
141 type##Oop() : oop() {} \
142 type##Oop(const volatile oop& o) : oop(o) {} \
143 type##Oop(const void* p) : oop(p) {} \
144 operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \
145 type##OopDesc* operator->() const { \
146 return (type##OopDesc*)obj(); \
147 } \
148 }; \
150 DEF_OOP(instance);
151 DEF_OOP(method);
152 DEF_OOP(methodData);
153 DEF_OOP(array);
154 DEF_OOP(constMethod);
155 DEF_OOP(constantPool);
156 DEF_OOP(constantPoolCache);
157 DEF_OOP(objArray);
158 DEF_OOP(typeArray);
159 DEF_OOP(symbol);
160 DEF_OOP(klass);
161 DEF_OOP(compiledICHolder);
163 #endif // CHECK_UNHANDLED_OOPS
165 // The klass hierarchy is separate from the oop hierarchy.
167 class Klass;
168 class instanceKlass;
169 class instanceRefKlass;
170 class methodKlass;
171 class constMethodKlass;
172 class methodDataKlass;
173 class klassKlass;
174 class instanceKlassKlass;
175 class arrayKlassKlass;
176 class objArrayKlassKlass;
177 class typeArrayKlassKlass;
178 class arrayKlass;
179 class objArrayKlass;
180 class typeArrayKlass;
181 class constantPoolKlass;
182 class constantPoolCacheKlass;
183 class symbolKlass;
184 class compiledICHolderKlass;