/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "gc_interface/collectedHeap.hpp"
#include "memory/universe.hpp"
#include "oops/markOop.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/taskqueue.hpp"
class ReferenceProcessor;
class DataLayout;
class SerialOldTracer;
class STWGCTimer;
// MarkSweep takes care of global mark-compact garbage collection for a
// GenCollectedHeap using a four-phase pointer forwarding algorithm. All
// generations are assumed to support marking; those that can also support
// compaction.
//
// Class unloading will only occur when a full gc is invoked.
// If VALIDATE_MARK_SWEEP is defined, the -XX:+ValidateMarkSweep flag will
// be operational, and will provide slow but comprehensive self-checks within
// the GC. This is not enabled by default in product or release builds,
// since the extra call to track_adjusted_pointer() in _adjust_pointer()
// would be too much overhead, and would disturb performance measurement.
// However, debug builds are sometimes way too slow to run GC tests!
#ifdef ASSERT
#endif
#ifdef VALIDATE_MARK_SWEEP
#else
#endif
// declared at end
class PreservedMark;
//
// Inline closure decls
//
public:
};
public:
virtual const bool should_remember_mdo() const { return true; }
};
public:
virtual void do_void();
};
private:
bool _is_root;
public:
};
public:
virtual bool do_object_b(oop p);
};
protected:
template <class T> void do_oop_work(T* p);
public:
};
//
// Friend decls
//
friend class AdjustPointerClosure;
friend class KeepAliveClosure;
friend class VM_MarkSweep;
friend void marksweep_init();
//
// Vars
//
protected:
// Traversal stacks used during phase1
// Stack for live klasses to revisit at end of marking phase
// Set (stack) of MDO's to revisit at end of marking phase
// Reference processing (used in ...follow_contents)
#ifdef VALIDATE_MARK_SWEEP
static bool _pointer_tracking;
static bool _root_tracking;
// The following arrays are saved since the time of the last GC and
// assist in tracking down problems where someone has done an errant
// store into the heap, usually to an oop that wasn't properly
// handleized across a GC. If we crash or otherwise fail before the
// next GC, we can query these arrays to find out the object we had
// intended to do the store to (assuming it is still alive) and the
// offset within that object. Covered under RecordMarkSweepCompaction.
#endif
// Non public closures
// Class unloading. Update subklass/sibling/implementor links at end of marking phase.
static void follow_weak_klass_links();
// Class unloading. Clear weak refs in MDO's (ProfileData)
// at the end of the marking phase.
static void follow_mdo_weak_refs();
// Debugging
public:
// Public closures
// Reference Processing
// Call backs for marking
// Mark pointer and follow contents. Empty marking stack afterwards.
template <class T> static inline void follow_root(T* p);
// Check mark and maybe push on marking stack
template <class T> static inline void mark_and_push(T* p);
static void follow_stack(); // Empty marking stack.
// Save the mark word so it can be restored later
static void adjust_marks(); // Adjust the pointers in the preserved marks table
static void restore_marks(); // Restore the marks that we saved in preserve_mark
template <class T> static inline void adjust_pointer(T* p, bool isroot);
#ifdef VALIDATE_MARK_SWEEP
static void track_adjusted_pointer(void* p, bool isroot);
static void check_adjust_pointer(void* p);
static void check_interior_pointers();
static void reset_live_oop_tracking(bool at_perm);
static void compaction_complete();
// Querying operation of RecordMarkSweepCompaction results.
// Finds and prints the current base oop and offset for a word
// within an oop that was live during the last GC. Helpful for
// tracking down heap stomps.
static void print_new_location_of_heap_address(HeapWord* q);
#endif
// Call backs for class unloading
// Update subklass/sibling/implementor links at end of marking.
static void revisit_weak_klass_link(Klass* k);
// For weak refs clearing in MDO's
static void revisit_mdo(DataLayout* p);
};
private:
public:
}
void adjust_pointer() {
}
void restore() {
}
};
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP