namespace mirror { classClass; class Object;
} // namespace mirror
namespace gc { class Heap;
namespace space { class ContinuousMemMapAllocSpace; class ContinuousSpace;
} // namespace space
namespace collector { class SemiSpace : public GarbageCollector { public: // If true, use remembered sets in the generational mode. static constexpr bool kUseRememberedSet = true;
// Sets which space we will be copying objects to. void SetToSpace(space::ContinuousMemMapAllocSpace* to_space);
// Set the space where we copy objects from. void SetFromSpace(space::ContinuousMemMapAllocSpace* from_space);
// Set whether or not we swap the semi spaces in the heap. This needs to be done with mutators // suspended. void SetSwapSemiSpaces(bool swap_semi_spaces) {
swap_semi_spaces_ = swap_semi_spaces;
}
// Initializes internal structures. void Init();
// Find the default mark bitmap. void FindDefaultMarkBitmap();
// Updates obj_ptr if the object has moved. Takes either an ObjectReference or a HeapReference. template<typename CompressedReferenceType> void MarkObject(CompressedReferenceType* obj_ptr)
REQUIRES(Locks::heap_bitmap_lock_, Locks::mutator_lock_);
// Marks the root set at the start of a garbage collection. void MarkRoots()
REQUIRES(Locks::heap_bitmap_lock_, Locks::mutator_lock_);
// Bind the live bits to the mark bits of bitmaps for spaces that are never collected, ie // the image. Mark that portion of the heap as immune. virtualvoid BindBitmaps() REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::heap_bitmap_lock_);
// Schedules an unmarked object for reference processing. void DelayReferenceReferent(ObjPtr<mirror::Class> klass, ObjPtr<mirror::Reference> reference)
override REQUIRES_SHARED(Locks::heap_bitmap_lock_, Locks::mutator_lock_);
protected: // Returns null if the object is not marked, otherwise returns the forwarding address (same as // object for non movable things).
mirror::Object* IsMarked(mirror::Object* object) override
REQUIRES(Locks::mutator_lock_)
REQUIRES_SHARED(Locks::heap_bitmap_lock_);
// Marks or unmarks a large object based on whether or not set is true. If set is true, then we // mark, otherwise we unmark. bool MarkLargeObject(const mirror::Object* obj)
REQUIRES(Locks::heap_bitmap_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
// Expand mark stack to 2x its current size. void ResizeMarkStack(size_t new_size) REQUIRES_SHARED(Locks::mutator_lock_);
// Returns true if we should sweep the space. virtualbool ShouldSweepSpace(space::ContinuousSpace* space) const;
// Push an object onto the mark stack. void MarkStackPush(mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
// Revoke all the thread-local buffers. void RevokeAllThreadLocalBuffers() override;
// Current space, we check this space first to avoid searching for the appropriate space for an // object.
accounting::ObjectStack* mark_stack_;
// Every object inside the immune spaces is assumed to be marked.
ImmuneSpaces immune_spaces_;
// Destination and source spaces (can be any type of ContinuousMemMapAllocSpace which either has // a live bitmap or doesn't).
space::ContinuousMemMapAllocSpace* to_space_; // Cached live bitmap as an optimization.
accounting::ContinuousSpaceBitmap* to_space_live_bitmap_;
space::ContinuousMemMapAllocSpace* from_space_; // Cached mark bitmap as an optimization.
accounting::HeapBitmap* mark_bitmap_;
Thread* self_;
// The space which we copy to if the to_space_ is full.
space::ContinuousMemMapAllocSpace* fallback_space_;
// How many objects and bytes we moved, used so that we don't need to Get the size of the // to_space_ when calculating how many objects and bytes we freed.
size_t bytes_moved_;
size_t objects_moved_;
// How many bytes we avoided dirtying.
size_t saved_bytes_;
// The name of the collector.
std::string collector_name_;
// Used for the generational mode. The default interval of the whole // heap collection. If N, the whole heap collection occurs every N // collections. static constexpr int kDefaultWholeHeapCollectionInterval = 5;
// Whether or not we swap the semi spaces in the heap during the marking phase. bool swap_semi_spaces_;
private: class BitmapSetSlowPathVisitor; class MarkObjectVisitor; class VerifyNoFromSpaceReferencesVisitor;
DISALLOW_IMPLICIT_CONSTRUCTORS(SemiSpace);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.