提交 8333cd87 编写于 作者: M mgerdin

8038405: Clean up some virtual fucntions in Space class hierarchy

Summary: Get rid of some duplicated implementations and change nonsense implementations to pure virtuals
Reviewed-by: stefank, jmasa
上级 dcb118c0
...@@ -337,10 +337,6 @@ class CompactibleFreeListSpace: public CompactibleSpace { ...@@ -337,10 +337,6 @@ class CompactibleFreeListSpace: public CompactibleSpace {
unallocated_block() : end()); unallocated_block() : end());
} }
bool is_in(const void* p) const {
return used_region().contains(p);
}
virtual bool is_free_block(const HeapWord* p) const; virtual bool is_free_block(const HeapWord* p) const;
// Resizing support // Resizing support
......
...@@ -306,10 +306,6 @@ void ContiguousSpace::clear(bool mangle_space) { ...@@ -306,10 +306,6 @@ void ContiguousSpace::clear(bool mangle_space) {
CompactibleSpace::clear(mangle_space); CompactibleSpace::clear(mangle_space);
} }
bool ContiguousSpace::is_in(const void* p) const {
return _bottom <= p && p < _top;
}
bool ContiguousSpace::is_free_block(const HeapWord* p) const { bool ContiguousSpace::is_free_block(const HeapWord* p) const {
return p >= _top; return p >= _top;
} }
......
...@@ -104,6 +104,12 @@ class Space: public CHeapObj<mtGC> { ...@@ -104,6 +104,12 @@ class Space: public CHeapObj<mtGC> {
void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; } void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; }
// Returns true if this object has been allocated since a
// generation's "save_marks" call.
virtual bool obj_allocated_since_save_marks(const oop obj) const {
return (HeapWord*)obj >= saved_mark_word();
}
MemRegionClosure* preconsumptionDirtyCardClosure() const { MemRegionClosure* preconsumptionDirtyCardClosure() const {
return _preconsumptionDirtyCardClosure; return _preconsumptionDirtyCardClosure;
} }
...@@ -111,9 +117,9 @@ class Space: public CHeapObj<mtGC> { ...@@ -111,9 +117,9 @@ class Space: public CHeapObj<mtGC> {
_preconsumptionDirtyCardClosure = cl; _preconsumptionDirtyCardClosure = cl;
} }
// Returns a subregion of the space containing all the objects in // Returns a subregion of the space containing only the allocated objects in
// the space. // the space.
virtual MemRegion used_region() const { return MemRegion(bottom(), end()); } virtual MemRegion used_region() const = 0;
// Returns a region that is guaranteed to contain (at least) all objects // Returns a region that is guaranteed to contain (at least) all objects
// allocated at the time of the last call to "save_marks". If the space // allocated at the time of the last call to "save_marks". If the space
...@@ -123,7 +129,7 @@ class Space: public CHeapObj<mtGC> { ...@@ -123,7 +129,7 @@ class Space: public CHeapObj<mtGC> {
// saved mark. Otherwise, the "obj_allocated_since_save_marks" method of // saved mark. Otherwise, the "obj_allocated_since_save_marks" method of
// the space must distiguish between objects in the region allocated before // the space must distiguish between objects in the region allocated before
// and after the call to save marks. // and after the call to save marks.
virtual MemRegion used_region_at_save_marks() const { MemRegion used_region_at_save_marks() const {
return MemRegion(bottom(), saved_mark_word()); return MemRegion(bottom(), saved_mark_word());
} }
...@@ -156,7 +162,9 @@ class Space: public CHeapObj<mtGC> { ...@@ -156,7 +162,9 @@ class Space: public CHeapObj<mtGC> {
// expensive operation. To prevent performance problems // expensive operation. To prevent performance problems
// on account of its inadvertent use in product jvm's, // on account of its inadvertent use in product jvm's,
// we restrict its use to assertion checks only. // we restrict its use to assertion checks only.
virtual bool is_in(const void* p) const = 0; bool is_in(const void* p) const {
return used_region().contains(p);
}
// Returns true iff the given reserved memory of the space contains the // Returns true iff the given reserved memory of the space contains the
// given address. // given address.
...@@ -228,10 +236,6 @@ class Space: public CHeapObj<mtGC> { ...@@ -228,10 +236,6 @@ class Space: public CHeapObj<mtGC> {
// Allocation (return NULL if full). Enforces mutual exclusion internally. // Allocation (return NULL if full). Enforces mutual exclusion internally.
virtual HeapWord* par_allocate(size_t word_size) = 0; virtual HeapWord* par_allocate(size_t word_size) = 0;
// Returns true if this object has been allocated since a
// generation's "save_marks" call.
virtual bool obj_allocated_since_save_marks(const oop obj) const = 0;
// Mark-sweep-compact support: all spaces can update pointers to objects // Mark-sweep-compact support: all spaces can update pointers to objects
// moving as a part of compaction. // moving as a part of compaction.
virtual void adjust_pointers(); virtual void adjust_pointers();
...@@ -363,7 +367,7 @@ public: ...@@ -363,7 +367,7 @@ public:
// Perform operations on the space needed after a compaction // Perform operations on the space needed after a compaction
// has been performed. // has been performed.
virtual void reset_after_compaction() {} virtual void reset_after_compaction() = 0;
// Returns the next space (in the current generation) to be compacted in // Returns the next space (in the current generation) to be compacted in
// the global compaction order. Also is used to select the next // the global compaction order. Also is used to select the next
...@@ -428,7 +432,7 @@ protected: ...@@ -428,7 +432,7 @@ protected:
HeapWord* _end_of_live; HeapWord* _end_of_live;
// Minimum size of a free block. // Minimum size of a free block.
virtual size_t minimum_free_block_size() const = 0; virtual size_t minimum_free_block_size() const { return 0; }
// This the function is invoked when an allocation of an object covering // This the function is invoked when an allocation of an object covering
// "start" to "end occurs crosses the threshold; returns the next // "start" to "end occurs crosses the threshold; returns the next
...@@ -478,7 +482,7 @@ class ContiguousSpace: public CompactibleSpace { ...@@ -478,7 +482,7 @@ class ContiguousSpace: public CompactibleSpace {
HeapWord* top() const { return _top; } HeapWord* top() const { return _top; }
void set_top(HeapWord* value) { _top = value; } void set_top(HeapWord* value) { _top = value; }
virtual void set_saved_mark() { _saved_mark_word = top(); } void set_saved_mark() { _saved_mark_word = top(); }
void reset_saved_mark() { _saved_mark_word = bottom(); } void reset_saved_mark() { _saved_mark_word = bottom(); }
WaterMark bottom_mark() { return WaterMark(this, bottom()); } WaterMark bottom_mark() { return WaterMark(this, bottom()); }
...@@ -513,27 +517,16 @@ class ContiguousSpace: public CompactibleSpace { ...@@ -513,27 +517,16 @@ class ContiguousSpace: public CompactibleSpace {
size_t used() const { return byte_size(bottom(), top()); } size_t used() const { return byte_size(bottom(), top()); }
size_t free() const { return byte_size(top(), end()); } size_t free() const { return byte_size(top(), end()); }
// Override from space.
bool is_in(const void* p) const;
virtual bool is_free_block(const HeapWord* p) const; virtual bool is_free_block(const HeapWord* p) const;
// In a contiguous space we have a more obvious bound on what parts // In a contiguous space we have a more obvious bound on what parts
// contain objects. // contain objects.
MemRegion used_region() const { return MemRegion(bottom(), top()); } MemRegion used_region() const { return MemRegion(bottom(), top()); }
MemRegion used_region_at_save_marks() const {
return MemRegion(bottom(), saved_mark_word());
}
// Allocation (return NULL if full) // Allocation (return NULL if full)
virtual HeapWord* allocate(size_t word_size); virtual HeapWord* allocate(size_t word_size);
virtual HeapWord* par_allocate(size_t word_size); virtual HeapWord* par_allocate(size_t word_size);
virtual bool obj_allocated_since_save_marks(const oop obj) const {
return (HeapWord*)obj >= saved_mark_word();
}
// Iteration // Iteration
void oop_iterate(ExtendedOopClosure* cl); void oop_iterate(ExtendedOopClosure* cl);
void object_iterate(ObjectClosure* blk); void object_iterate(ObjectClosure* blk);
...@@ -578,7 +571,6 @@ class ContiguousSpace: public CompactibleSpace { ...@@ -578,7 +571,6 @@ class ContiguousSpace: public CompactibleSpace {
// set new iteration safe limit // set new iteration safe limit
set_concurrent_iteration_safe_limit(compaction_top()); set_concurrent_iteration_safe_limit(compaction_top());
} }
virtual size_t minimum_free_block_size() const { return 0; }
// Override. // Override.
DirtyCardToOopClosure* new_dcto_cl(ExtendedOopClosure* cl, DirtyCardToOopClosure* new_dcto_cl(ExtendedOopClosure* cl,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册