Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/shared/markSweep.hpp @ 113:ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author | coleenp |
---|---|
date | Sun, 13 Apr 2008 17:43:42 -0400 |
parents | a61af66fc99e |
children | d1605aabd0a1 |
comparison
equal
deleted
inserted
replaced
110:a49a647afe9a | 113:ba764ed4b6f2 |
---|---|
44 #define VALIDATE_MARK_SWEEP_ONLY(code) code | 44 #define VALIDATE_MARK_SWEEP_ONLY(code) code |
45 #else | 45 #else |
46 #define VALIDATE_MARK_SWEEP_ONLY(code) | 46 #define VALIDATE_MARK_SWEEP_ONLY(code) |
47 #endif | 47 #endif |
48 | 48 |
49 | |
50 // declared at end | 49 // declared at end |
51 class PreservedMark; | 50 class PreservedMark; |
52 | 51 |
53 class MarkSweep : AllStatic { | 52 class MarkSweep : AllStatic { |
54 // | 53 // |
55 // In line closure decls | 54 // Inline closure decls |
56 // | 55 // |
57 | 56 class FollowRootClosure: public OopsInGenClosure { |
58 class FollowRootClosure: public OopsInGenClosure{ | 57 public: |
59 public: | 58 virtual void do_oop(oop* p); |
60 void do_oop(oop* p) { follow_root(p); } | 59 virtual void do_oop(narrowOop* p); |
61 virtual const bool do_nmethods() const { return true; } | 60 virtual const bool do_nmethods() const { return true; } |
62 }; | 61 }; |
63 | 62 |
64 class MarkAndPushClosure: public OopClosure { | 63 class MarkAndPushClosure: public OopClosure { |
65 public: | 64 public: |
66 void do_oop(oop* p) { mark_and_push(p); } | 65 virtual void do_oop(oop* p); |
66 virtual void do_oop(narrowOop* p); | |
67 virtual const bool do_nmethods() const { return true; } | 67 virtual const bool do_nmethods() const { return true; } |
68 }; | 68 }; |
69 | 69 |
70 class FollowStackClosure: public VoidClosure { | 70 class FollowStackClosure: public VoidClosure { |
71 public: | 71 public: |
72 void do_void() { follow_stack(); } | 72 virtual void do_void(); |
73 }; | 73 }; |
74 | 74 |
75 class AdjustPointerClosure: public OopsInGenClosure { | 75 class AdjustPointerClosure: public OopsInGenClosure { |
76 private: | |
76 bool _is_root; | 77 bool _is_root; |
77 public: | 78 public: |
78 AdjustPointerClosure(bool is_root) : _is_root(is_root) {} | 79 AdjustPointerClosure(bool is_root) : _is_root(is_root) {} |
79 void do_oop(oop* p) { _adjust_pointer(p, _is_root); } | 80 virtual void do_oop(oop* p); |
81 virtual void do_oop(narrowOop* p); | |
80 }; | 82 }; |
81 | 83 |
82 // Used for java/lang/ref handling | 84 // Used for java/lang/ref handling |
83 class IsAliveClosure: public BoolObjectClosure { | 85 class IsAliveClosure: public BoolObjectClosure { |
84 public: | 86 public: |
85 void do_object(oop p) { assert(false, "don't call"); } | 87 virtual void do_object(oop p); |
86 bool do_object_b(oop p) { return p->is_gc_marked(); } | 88 virtual bool do_object_b(oop p); |
87 }; | 89 }; |
88 | 90 |
89 class KeepAliveClosure: public OopClosure { | 91 class KeepAliveClosure: public OopClosure { |
90 public: | 92 protected: |
91 void do_oop(oop* p); | 93 template <class T> void do_oop_work(T* p); |
94 public: | |
95 virtual void do_oop(oop* p); | |
96 virtual void do_oop(narrowOop* p); | |
92 }; | 97 }; |
93 | 98 |
94 // | 99 // |
95 // Friend decls | 100 // Friend decls |
96 // | 101 // |
97 | |
98 friend class AdjustPointerClosure; | 102 friend class AdjustPointerClosure; |
99 friend class KeepAliveClosure; | 103 friend class KeepAliveClosure; |
100 friend class VM_MarkSweep; | 104 friend class VM_MarkSweep; |
101 friend void marksweep_init(); | 105 friend void marksweep_init(); |
102 | 106 |
118 | 122 |
119 // Reference processing (used in ...follow_contents) | 123 // Reference processing (used in ...follow_contents) |
120 static ReferenceProcessor* _ref_processor; | 124 static ReferenceProcessor* _ref_processor; |
121 | 125 |
122 #ifdef VALIDATE_MARK_SWEEP | 126 #ifdef VALIDATE_MARK_SWEEP |
123 static GrowableArray<oop*>* _root_refs_stack; | 127 static GrowableArray<void*>* _root_refs_stack; |
124 static GrowableArray<oop> * _live_oops; | 128 static GrowableArray<oop> * _live_oops; |
125 static GrowableArray<oop> * _live_oops_moved_to; | 129 static GrowableArray<oop> * _live_oops_moved_to; |
126 static GrowableArray<size_t>* _live_oops_size; | 130 static GrowableArray<size_t>* _live_oops_size; |
127 static size_t _live_oops_index; | 131 static size_t _live_oops_index; |
128 static size_t _live_oops_index_at_perm; | 132 static size_t _live_oops_index_at_perm; |
129 static GrowableArray<oop*>* _other_refs_stack; | 133 static GrowableArray<void*>* _other_refs_stack; |
130 static GrowableArray<oop*>* _adjusted_pointers; | 134 static GrowableArray<void*>* _adjusted_pointers; |
131 static bool _pointer_tracking; | 135 static bool _pointer_tracking; |
132 static bool _root_tracking; | 136 static bool _root_tracking; |
133 | 137 |
134 // The following arrays are saved since the time of the last GC and | 138 // The following arrays are saved since the time of the last GC and |
135 // assist in tracking down problems where someone has done an errant | 139 // assist in tracking down problems where someone has done an errant |
144 static GrowableArray<HeapWord*> * _last_gc_live_oops; | 148 static GrowableArray<HeapWord*> * _last_gc_live_oops; |
145 static GrowableArray<HeapWord*> * _last_gc_live_oops_moved_to; | 149 static GrowableArray<HeapWord*> * _last_gc_live_oops_moved_to; |
146 static GrowableArray<size_t>* _last_gc_live_oops_size; | 150 static GrowableArray<size_t>* _last_gc_live_oops_size; |
147 #endif | 151 #endif |
148 | 152 |
149 | |
150 // Non public closures | 153 // Non public closures |
151 static IsAliveClosure is_alive; | 154 static IsAliveClosure is_alive; |
152 static KeepAliveClosure keep_alive; | 155 static KeepAliveClosure keep_alive; |
153 | 156 |
154 // Class unloading. Update subklass/sibling/implementor links at end of marking phase. | 157 // Class unloading. Update subklass/sibling/implementor links at end of marking phase. |
155 static void follow_weak_klass_links(); | 158 static void follow_weak_klass_links(); |
156 | 159 |
157 // Debugging | 160 // Debugging |
158 static void trace(const char* msg) PRODUCT_RETURN; | 161 static void trace(const char* msg) PRODUCT_RETURN; |
159 | 162 |
160 public: | 163 public: |
161 // Public closures | 164 // Public closures |
162 static FollowRootClosure follow_root_closure; | 165 static FollowRootClosure follow_root_closure; |
163 static MarkAndPushClosure mark_and_push_closure; | 166 static MarkAndPushClosure mark_and_push_closure; |
164 static FollowStackClosure follow_stack_closure; | 167 static FollowStackClosure follow_stack_closure; |
165 static AdjustPointerClosure adjust_root_pointer_closure; | 168 static AdjustPointerClosure adjust_root_pointer_closure; |
166 static AdjustPointerClosure adjust_pointer_closure; | 169 static AdjustPointerClosure adjust_pointer_closure; |
167 | 170 |
168 // Reference Processing | 171 // Reference Processing |
169 static ReferenceProcessor* const ref_processor() { return _ref_processor; } | 172 static ReferenceProcessor* const ref_processor() { return _ref_processor; } |
170 | 173 |
171 // Call backs for marking | 174 // Call backs for marking |
172 static void mark_object(oop obj); | 175 static void mark_object(oop obj); |
173 static void follow_root(oop* p); // Mark pointer and follow contents. Empty marking | 176 // Mark pointer and follow contents. Empty marking stack afterwards. |
174 | 177 template <class T> static inline void follow_root(T* p); |
175 // stack afterwards. | 178 // Mark pointer and follow contents. |
176 | 179 template <class T> static inline void mark_and_follow(T* p); |
177 static void mark_and_follow(oop* p); // Mark pointer and follow contents. | 180 // Check mark and maybe push on marking stack |
178 static void _mark_and_push(oop* p); // Mark pointer and push obj on | 181 template <class T> static inline void mark_and_push(T* p); |
179 // marking stack. | 182 |
180 | 183 static void follow_stack(); // Empty marking stack. |
181 | 184 |
182 static void mark_and_push(oop* p) { // Check mark and maybe push on | 185 static void preserve_mark(oop p, markOop mark); |
183 // marking stack | 186 // Save the mark word so it can be restored later |
184 // assert(Universe::is_reserved_heap((oop)p), "we should only be traversing objects here"); | 187 static void adjust_marks(); // Adjust the pointers in the preserved marks table |
185 oop m = *p; | 188 static void restore_marks(); // Restore the marks that we saved in preserve_mark |
186 if (m != NULL && !m->mark()->is_marked()) { | 189 |
187 _mark_and_push(p); | 190 template <class T> static inline void adjust_pointer(T* p, bool isroot); |
188 } | 191 |
189 } | 192 static void adjust_root_pointer(oop* p) { adjust_pointer(p, true); } |
190 | 193 static void adjust_pointer(oop* p) { adjust_pointer(p, false); } |
191 static void follow_stack(); // Empty marking stack. | 194 static void adjust_pointer(narrowOop* p) { adjust_pointer(p, false); } |
192 | |
193 | |
194 static void preserve_mark(oop p, markOop mark); // Save the mark word so it can be restored later | |
195 static void adjust_marks(); // Adjust the pointers in the preserved marks table | |
196 static void restore_marks(); // Restore the marks that we saved in preserve_mark | |
197 | |
198 static void _adjust_pointer(oop* p, bool isroot); | |
199 | |
200 static void adjust_root_pointer(oop* p) { _adjust_pointer(p, true); } | |
201 static void adjust_pointer(oop* p) { _adjust_pointer(p, false); } | |
202 | 195 |
203 #ifdef VALIDATE_MARK_SWEEP | 196 #ifdef VALIDATE_MARK_SWEEP |
204 static void track_adjusted_pointer(oop* p, oop newobj, bool isroot); | 197 static void track_adjusted_pointer(void* p, bool isroot); |
205 static void check_adjust_pointer(oop* p); // Adjust this pointer | 198 static void check_adjust_pointer(void* p); |
206 static void track_interior_pointers(oop obj); | 199 static void track_interior_pointers(oop obj); |
207 static void check_interior_pointers(); | 200 static void check_interior_pointers(); |
208 | 201 |
209 static void reset_live_oop_tracking(bool at_perm); | 202 static void reset_live_oop_tracking(bool at_perm); |
210 static void register_live_oop(oop p, size_t size); | 203 static void register_live_oop(oop p, size_t size); |
221 | 214 |
222 // Call backs for class unloading | 215 // Call backs for class unloading |
223 static void revisit_weak_klass_link(Klass* k); // Update subklass/sibling/implementor links at end of marking. | 216 static void revisit_weak_klass_link(Klass* k); // Update subklass/sibling/implementor links at end of marking. |
224 }; | 217 }; |
225 | 218 |
226 | |
227 class PreservedMark VALUE_OBJ_CLASS_SPEC { | 219 class PreservedMark VALUE_OBJ_CLASS_SPEC { |
228 private: | 220 private: |
229 oop _obj; | 221 oop _obj; |
230 markOop _mark; | 222 markOop _mark; |
231 | 223 |