1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Tue Aug 19 12:39:06 2014 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Tue Aug 19 10:50:27 2014 +0200 1.3 @@ -162,7 +162,7 @@ 1.4 // diagnosing failures. 1.5 class hrs_ext_msg : public hrs_err_msg { 1.6 public: 1.7 - hrs_ext_msg(HeapRegionSetBase* set, const char* message) : hrs_err_msg("%s","") { 1.8 + hrs_ext_msg(HeapRegionSetBase* set, const char* message) : hrs_err_msg("%s", "") { 1.9 set->fill_in_ext_msg(this, message); 1.10 } 1.11 }; 1.12 @@ -192,13 +192,9 @@ 1.13 }; 1.14 1.15 // A set that links all the regions added to it in a doubly-linked 1.16 -// list. We should try to avoid doing operations that iterate over 1.17 +// sorted list. We should try to avoid doing operations that iterate over 1.18 // such lists in performance critical paths. Typically we should 1.19 -// add / remove one region at a time or concatenate two lists. There are 1.20 -// two ways to treat your lists, ordered and un-ordered. All un-ordered 1.21 -// operations are done in constant time. To keep a list ordered only use 1.22 -// add_ordered() to add elements to the list. If a list is not ordered 1.23 -// from start, there is no way to sort it later. 1.24 +// add / remove one region at a time or concatenate two lists. 1.25 1.26 class FreeRegionListIterator; 1.27 1.28 @@ -210,13 +206,13 @@ 1.29 HeapRegion* _tail; 1.30 1.31 // _last is used to keep track of where we added an element the last 1.32 - // time in ordered lists. It helps to improve performance when adding 1.33 - // several ordered items in a row. 1.34 + // time. It helps to improve performance when adding several ordered items in a row. 1.35 HeapRegion* _last; 1.36 1.37 static uint _unrealistically_long_length; 1.38 1.39 - void add_as_head_or_tail(FreeRegionList* from_list, bool as_head); 1.40 + inline HeapRegion* remove_from_head_impl(); 1.41 + inline HeapRegion* remove_from_tail_impl(); 1.42 1.43 protected: 1.44 virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg); 1.45 @@ -232,8 +228,11 @@ 1.46 1.47 void verify_list(); 1.48 1.49 - HeapRegion* head() { return _head; } 1.50 - HeapRegion* tail() { return _tail; } 1.51 +#ifdef ASSERT 1.52 + bool contains(HeapRegion* hr) const { 1.53 + return hr->containing_set() == this; 1.54 + } 1.55 +#endif 1.56 1.57 static void set_unrealistically_long_length(uint len); 1.58 1.59 @@ -242,55 +241,20 @@ 1.60 // is determined by hrs_index. 1.61 inline void add_ordered(HeapRegion* hr); 1.62 1.63 - // It adds hr to the list as the new head. The region should not be 1.64 - // a member of another set. 1.65 - inline void add_as_head(HeapRegion* hr); 1.66 - 1.67 - // It adds hr to the list as the new tail. The region should not be 1.68 - // a member of another set. 1.69 - inline void add_as_tail(HeapRegion* hr); 1.70 - 1.71 - // It removes and returns the head of the list. It assumes that the 1.72 - // list is not empty so it will return a non-NULL value. 1.73 - inline HeapRegion* remove_head(); 1.74 - 1.75 - // Convenience method. 1.76 - inline HeapRegion* remove_head_or_null(); 1.77 - 1.78 - // Removes and returns the last element (_tail) of the list. It assumes 1.79 - // that the list isn't empty so that it can return a non-NULL value. 1.80 - inline HeapRegion* remove_tail(); 1.81 - 1.82 - // Convenience method 1.83 - inline HeapRegion* remove_tail_or_null(); 1.84 - 1.85 // Removes from head or tail based on the given argument. 1.86 - inline HeapRegion* remove_region(bool from_head); 1.87 + HeapRegion* remove_region(bool from_head); 1.88 1.89 // Merge two ordered lists. The result is also ordered. The order is 1.90 // determined by hrs_index. 1.91 void add_ordered(FreeRegionList* from_list); 1.92 1.93 - // It moves the regions from from_list to this list and empties 1.94 - // from_list. The new regions will appear in the same order as they 1.95 - // were in from_list and be linked in the beginning of this list. 1.96 - void add_as_head(FreeRegionList* from_list); 1.97 - 1.98 - // It moves the regions from from_list to this list and empties 1.99 - // from_list. The new regions will appear in the same order as they 1.100 - // were in from_list and be linked in the end of this list. 1.101 - void add_as_tail(FreeRegionList* from_list); 1.102 - 1.103 // It empties the list by removing all regions from it. 1.104 void remove_all(); 1.105 1.106 - // It removes all regions in the list that are pending for removal 1.107 - // (i.e., they have been tagged with "pending_removal"). The list 1.108 - // must not be empty, target_count should reflect the exact number 1.109 - // of regions that are pending for removal in the list, and 1.110 - // target_count should be > 1 (currently, we never need to remove a 1.111 - // single region using this). 1.112 - void remove_all_pending(uint target_count); 1.113 + // Remove all (contiguous) regions from first to first + num_regions -1 from 1.114 + // this list. 1.115 + // Num_regions must be > 1. 1.116 + void remove_starting_at(HeapRegion* first, uint num_regions); 1.117 1.118 virtual void verify(); 1.119 1.120 @@ -298,7 +262,7 @@ 1.121 }; 1.122 1.123 // Iterator class that provides a convenient way to iterate over the 1.124 -// regions of a HeapRegionLinkedList instance. 1.125 +// regions of a FreeRegionList. 1.126 1.127 class FreeRegionListIterator : public StackObj { 1.128 private: 1.129 @@ -324,7 +288,7 @@ 1.130 } 1.131 1.132 FreeRegionListIterator(FreeRegionList* list) : _curr(NULL), _list(list) { 1.133 - _curr = list->head(); 1.134 + _curr = list->_head; 1.135 } 1.136 }; 1.137