src/share/vm/gc_implementation/g1/heapRegionSet.hpp

changeset 6422
8ee855b4e667
parent 6385
58fc1b1523dc
child 6680
78bbf4d43a14
     1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSet.hpp	Mon Mar 24 09:14:14 2014 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.hpp	Fri Feb 28 15:27:09 2014 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -191,11 +191,14 @@
    1.11    }
    1.12  };
    1.13  
    1.14 -// A set that links all the regions added to it in a singly-linked
    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  // such lists in performance critical paths. Typically we should
    1.18 -// add / remove one region at a time or concatenate two lists. All
    1.19 -// those operations are done in constant time.
    1.20 +// add / remove one region at a time or concatenate two lists. There are
    1.21 +// two ways to treat your lists, ordered and un-ordered. All un-ordered
    1.22 +// operations are done in constant time. To keep a list ordered only use
    1.23 +// add_ordered() to add elements to the list. If a list is not ordered
    1.24 +// from start, there is no way to sort it later.
    1.25  
    1.26  class FreeRegionListIterator;
    1.27  
    1.28 @@ -206,6 +209,11 @@
    1.29    HeapRegion* _head;
    1.30    HeapRegion* _tail;
    1.31  
    1.32 +  // _last is used to keep track of where we added an element the last
    1.33 +  // time in ordered lists. It helps to improve performance when adding
    1.34 +  // 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 @@ -229,6 +237,11 @@
    1.41  
    1.42    static void set_unrealistically_long_length(uint len);
    1.43  
    1.44 +  // Add hr to the list. The region should not be a member of another set.
    1.45 +  // Assumes that the list is ordered and will preserve that order. The order
    1.46 +  // is determined by hrs_index.
    1.47 +  inline void add_ordered(HeapRegion* hr);
    1.48 +
    1.49    // It adds hr to the list as the new head. The region should not be
    1.50    // a member of another set.
    1.51    inline void add_as_head(HeapRegion* hr);
    1.52 @@ -244,6 +257,20 @@
    1.53    // Convenience method.
    1.54    inline HeapRegion* remove_head_or_null();
    1.55  
    1.56 +  // Removes and returns the last element (_tail) of the list. It assumes
    1.57 +  // that the list isn't empty so that it can return a non-NULL value.
    1.58 +  inline HeapRegion* remove_tail();
    1.59 +
    1.60 +  // Convenience method
    1.61 +  inline HeapRegion* remove_tail_or_null();
    1.62 +
    1.63 +  // Removes from head or tail based on the given argument.
    1.64 +  inline HeapRegion* remove_region(bool from_head);
    1.65 +
    1.66 +  // Merge two ordered lists. The result is also ordered. The order is
    1.67 +  // determined by hrs_index.
    1.68 +  void add_ordered(FreeRegionList* from_list);
    1.69 +
    1.70    // It moves the regions from from_list to this list and empties
    1.71    // from_list. The new regions will appear in the same order as they
    1.72    // were in from_list and be linked in the beginning of this list.
    1.73 @@ -276,7 +303,7 @@
    1.74  class FreeRegionListIterator : public StackObj {
    1.75  private:
    1.76    FreeRegionList* _list;
    1.77 -  HeapRegion*           _curr;
    1.78 +  HeapRegion*     _curr;
    1.79  
    1.80  public:
    1.81    bool more_available() {
    1.82 @@ -296,8 +323,7 @@
    1.83      return hr;
    1.84    }
    1.85  
    1.86 -  FreeRegionListIterator(FreeRegionList* list)
    1.87 -    : _curr(NULL), _list(list) {
    1.88 +  FreeRegionListIterator(FreeRegionList* list) : _curr(NULL), _list(list) {
    1.89      _curr = list->head();
    1.90    }
    1.91  };

mercurial