comparison src/share/vm/gc_implementation/shared/markSweep.hpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents da91efe96a93
children b735136e0d82
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
74 74
75 class MarkAndPushClosure: public OopClosure { 75 class MarkAndPushClosure: public OopClosure {
76 public: 76 public:
77 virtual void do_oop(oop* p); 77 virtual void do_oop(oop* p);
78 virtual void do_oop(narrowOop* p); 78 virtual void do_oop(narrowOop* p);
79 virtual const bool should_remember_mdo() const { return true; } 79 };
80 virtual void remember_mdo(DataLayout* p) { MarkSweep::revisit_mdo(p); } 80
81 // The one and only place to start following the classes.
82 // Should only be applied to the ClassLoaderData klasses list.
83 class FollowKlassClosure : public KlassClosure {
84 public:
85 void do_klass(Klass* klass);
86 };
87 class AdjustKlassClosure : public KlassClosure {
88 public:
89 void do_klass(Klass* klass);
81 }; 90 };
82 91
83 class FollowStackClosure: public VoidClosure { 92 class FollowStackClosure: public VoidClosure {
84 public: 93 public:
85 virtual void do_void(); 94 virtual void do_void();
119 128
120 // 129 //
121 // Vars 130 // Vars
122 // 131 //
123 protected: 132 protected:
133 // Total invocations of a MarkSweep collection
134 static unsigned int _total_invocations;
135
124 // Traversal stacks used during phase1 136 // Traversal stacks used during phase1
125 static Stack<oop, mtGC> _marking_stack; 137 static Stack<oop, mtGC> _marking_stack;
126 static Stack<ObjArrayTask, mtGC> _objarray_stack; 138 static Stack<ObjArrayTask, mtGC> _objarray_stack;
127 // Stack for live klasses to revisit at end of marking phase
128 static Stack<Klass*, mtGC> _revisit_klass_stack;
129 // Set (stack) of MDO's to revisit at end of marking phase
130 static Stack<DataLayout*, mtGC> _revisit_mdo_stack;
131 139
132 // Space for storing/restoring mark word 140 // Space for storing/restoring mark word
133 static Stack<markOop, mtGC> _preserved_mark_stack; 141 static Stack<markOop, mtGC> _preserved_mark_stack;
134 static Stack<oop, mtGC> _preserved_oop_stack; 142 static Stack<oop, mtGC> _preserved_oop_stack;
135 static size_t _preserved_count; 143 static size_t _preserved_count;
165 static GrowableArray<HeapWord*> * _last_gc_live_oops_moved_to; 173 static GrowableArray<HeapWord*> * _last_gc_live_oops_moved_to;
166 static GrowableArray<size_t>* _last_gc_live_oops_size; 174 static GrowableArray<size_t>* _last_gc_live_oops_size;
167 #endif 175 #endif
168 176
169 // Non public closures 177 // Non public closures
170 static IsAliveClosure is_alive;
171 static KeepAliveClosure keep_alive; 178 static KeepAliveClosure keep_alive;
172
173 // Class unloading. Update subklass/sibling/implementor links at end of marking phase.
174 static void follow_weak_klass_links();
175
176 // Class unloading. Clear weak refs in MDO's (ProfileData)
177 // at the end of the marking phase.
178 static void follow_mdo_weak_refs();
179 179
180 // Debugging 180 // Debugging
181 static void trace(const char* msg) PRODUCT_RETURN; 181 static void trace(const char* msg) PRODUCT_RETURN;
182 182
183 public: 183 public:
184 // Public closures 184 // Public closures
185 static IsAliveClosure is_alive;
185 static FollowRootClosure follow_root_closure; 186 static FollowRootClosure follow_root_closure;
186 static CodeBlobToOopClosure follow_code_root_closure; // => follow_root_closure 187 static CodeBlobToOopClosure follow_code_root_closure; // => follow_root_closure
187 static MarkAndPushClosure mark_and_push_closure; 188 static MarkAndPushClosure mark_and_push_closure;
189 static FollowKlassClosure follow_klass_closure;
188 static FollowStackClosure follow_stack_closure; 190 static FollowStackClosure follow_stack_closure;
189 static AdjustPointerClosure adjust_root_pointer_closure; 191 static AdjustPointerClosure adjust_root_pointer_closure;
190 static AdjustPointerClosure adjust_pointer_closure; 192 static AdjustPointerClosure adjust_pointer_closure;
193 static AdjustKlassClosure adjust_klass_closure;
194
195 // Accessors
196 static unsigned int total_invocations() { return _total_invocations; }
191 197
192 // Reference Processing 198 // Reference Processing
193 static ReferenceProcessor* const ref_processor() { return _ref_processor; } 199 static ReferenceProcessor* const ref_processor() { return _ref_processor; }
194 200
195 // Call backs for marking 201 // Call backs for marking
196 static void mark_object(oop obj); 202 static void mark_object(oop obj);
197 // Mark pointer and follow contents. Empty marking stack afterwards. 203 // Mark pointer and follow contents. Empty marking stack afterwards.
198 template <class T> static inline void follow_root(T* p); 204 template <class T> static inline void follow_root(T* p);
205
199 // Check mark and maybe push on marking stack 206 // Check mark and maybe push on marking stack
200 template <class T> static inline void mark_and_push(T* p); 207 template <class T> static void mark_and_push(T* p);
208
201 static inline void push_objarray(oop obj, size_t index); 209 static inline void push_objarray(oop obj, size_t index);
202 210
203 static void follow_stack(); // Empty marking stack. 211 static void follow_stack(); // Empty marking stack.
212
213 static void follow_klass(Klass* klass);
214 static void adjust_klass(Klass* klass);
215
216 static void follow_class_loader(ClassLoaderData* cld);
217 static void adjust_class_loader(ClassLoaderData* cld);
204 218
205 static void preserve_mark(oop p, markOop mark); 219 static void preserve_mark(oop p, markOop mark);
206 // Save the mark word so it can be restored later 220 // Save the mark word so it can be restored later
207 static void adjust_marks(); // Adjust the pointers in the preserved marks table 221 static void adjust_marks(); // Adjust the pointers in the preserved marks table
208 static void restore_marks(); // Restore the marks that we saved in preserve_mark 222 static void restore_marks(); // Restore the marks that we saved in preserve_mark
217 static void track_adjusted_pointer(void* p, bool isroot); 231 static void track_adjusted_pointer(void* p, bool isroot);
218 static void check_adjust_pointer(void* p); 232 static void check_adjust_pointer(void* p);
219 static void track_interior_pointers(oop obj); 233 static void track_interior_pointers(oop obj);
220 static void check_interior_pointers(); 234 static void check_interior_pointers();
221 235
222 static void reset_live_oop_tracking(bool at_perm); 236 static void reset_live_oop_tracking();
223 static void register_live_oop(oop p, size_t size); 237 static void register_live_oop(oop p, size_t size);
224 static void validate_live_oop(oop p, size_t size); 238 static void validate_live_oop(oop p, size_t size);
225 static void live_oop_moved_to(HeapWord* q, size_t size, HeapWord* compaction_top); 239 static void live_oop_moved_to(HeapWord* q, size_t size, HeapWord* compaction_top);
226 static void compaction_complete(); 240 static void compaction_complete();
227 241
229 // Finds and prints the current base oop and offset for a word 243 // Finds and prints the current base oop and offset for a word
230 // within an oop that was live during the last GC. Helpful for 244 // within an oop that was live during the last GC. Helpful for
231 // tracking down heap stomps. 245 // tracking down heap stomps.
232 static void print_new_location_of_heap_address(HeapWord* q); 246 static void print_new_location_of_heap_address(HeapWord* q);
233 #endif 247 #endif
234
235 // Call backs for class unloading
236 // Update subklass/sibling/implementor links at end of marking.
237 static void revisit_weak_klass_link(Klass* k);
238 // For weak refs clearing in MDO's
239 static void revisit_mdo(DataLayout* p);
240 }; 248 };
241 249
242 class PreservedMark VALUE_OBJ_CLASS_SPEC { 250 class PreservedMark VALUE_OBJ_CLASS_SPEC {
243 private: 251 private:
244 oop _obj; 252 oop _obj;