hotspot/src/share/vm/gc/g1/youngList.hpp
author tschatzl
Wed, 25 Nov 2015 14:43:29 +0100
changeset 34300 6075c1e0e913
parent 33203 e1034e5d33eb
child 36365 bcc9c9afda49
permissions -rw-r--r--
8136679: JFR event for adaptive IHOP Reviewed-by: tbenson, mgerdin, sangheki, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     1
/*
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     4
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     8
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    13
 * accompanied this code).
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    14
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    18
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    21
 * questions.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    22
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    23
 */
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    24
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_YOUNGLIST_HPP
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_YOUNGLIST_HPP
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    27
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    28
#include "memory/allocation.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    29
#include "runtime/globals.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    30
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    31
class YoungList : public CHeapObj<mtGC> {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    32
private:
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    33
  G1CollectedHeap* _g1h;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    34
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    35
  HeapRegion* _head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    36
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    37
  HeapRegion* _survivor_head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    38
  HeapRegion* _survivor_tail;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    39
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    40
  HeapRegion* _curr;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    41
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    42
  uint        _length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    43
  uint        _survivor_length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    44
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    45
  size_t      _last_sampled_rs_lengths;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    46
  size_t      _sampled_rs_lengths;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    47
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    48
  void         empty_list(HeapRegion* list);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    49
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    50
public:
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    51
  YoungList(G1CollectedHeap* g1h);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    52
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    53
  void         push_region(HeapRegion* hr);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    54
  void         add_survivor_region(HeapRegion* hr);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    55
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    56
  void         empty_list();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    57
  bool         is_empty() { return _length == 0; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    58
  uint         length() { return _length; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    59
  uint         eden_length() { return length() - survivor_length(); }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    60
  uint         survivor_length() { return _survivor_length; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    61
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    62
  // Currently we do not keep track of the used byte sum for the
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    63
  // young list and the survivors and it'd be quite a lot of work to
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    64
  // do so. When we'll eventually replace the young list with
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    65
  // instances of HeapRegionLinkedList we'll get that for free. So,
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    66
  // we'll report the more accurate information then.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    67
  size_t       eden_used_bytes() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    68
    assert(length() >= survivor_length(), "invariant");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    69
    return (size_t) eden_length() * HeapRegion::GrainBytes;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    70
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    71
  size_t       survivor_used_bytes() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    72
    return (size_t) survivor_length() * HeapRegion::GrainBytes;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    73
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    74
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    75
  void rs_length_sampling_init();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    76
  bool rs_length_sampling_more();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    77
  void rs_length_sampling_next();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    78
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    79
  void reset_sampled_info() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    80
    _last_sampled_rs_lengths =   0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    81
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    82
  size_t sampled_rs_lengths() { return _last_sampled_rs_lengths; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    83
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    84
  // for development purposes
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    85
  void reset_auxilary_lists();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    86
  void clear() { _head = NULL; _length = 0; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    87
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    88
  void clear_survivors() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    89
    _survivor_head    = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    90
    _survivor_tail    = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    91
    _survivor_length  = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    92
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    93
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    94
  HeapRegion* first_region() { return _head; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    95
  HeapRegion* first_survivor_region() { return _survivor_head; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    96
  HeapRegion* last_survivor_region() { return _survivor_tail; }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    97
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    98
  // debugging
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    99
  bool          check_list_well_formed();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   100
  bool          check_list_empty(bool check_sample = true);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   101
  void          print();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   102
};
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   103
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   104
#endif // SHARE_VM_GC_G1_YOUNGLIST_HPP