src/hotspot/share/gc/cms/cmsHeap.hpp
author rkennke
Thu, 12 Oct 2017 15:08:19 +0200
changeset 47622 817f2a7019e4
child 47636 52d46d7e3454
permissions -rw-r--r--
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass Reviewed-by: ehelin, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47622
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     1
/*
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     4
 *
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     8
 *
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    13
 * accompanied this code).
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    14
 *
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    18
 *
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    21
 * questions.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    22
 *
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    23
 */
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    24
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_CMS_CMSHEAP_HPP
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    26
#define SHARE_VM_GC_CMS_CMSHEAP_HPP
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    27
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    28
#include "gc/cms/concurrentMarkSweepGeneration.hpp"
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    29
#include "gc/shared/collectedHeap.hpp"
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    30
#include "gc/shared/gcCause.hpp"
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    31
#include "gc/shared/genCollectedHeap.hpp"
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    32
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    33
class CLDClosure;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    34
class GenCollectorPolicy;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    35
class OopsInGenClosure;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    36
class outputStream;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    37
class StrongRootsScope;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    38
class ThreadClosure;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    39
class WorkGang;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    40
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    41
class CMSHeap : public GenCollectedHeap {
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    42
public:
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    43
  CMSHeap(GenCollectorPolicy *policy);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    44
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    45
  // Returns JNI_OK on success
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    46
  virtual jint initialize();
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    47
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    48
  virtual void check_gen_kinds();
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    49
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    50
  // Convenience function to be used in situations where the heap type can be
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    51
  // asserted to be this type.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    52
  static CMSHeap* heap();
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    53
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    54
  virtual Name kind() const {
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    55
    return CollectedHeap::CMSHeap;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    56
  }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    57
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    58
  virtual const char* name() const {
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    59
    return "Concurrent Mark Sweep";
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    60
  }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    61
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    62
  WorkGang* workers() const { return _workers; }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    63
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    64
  virtual void print_gc_threads_on(outputStream* st) const;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    65
  virtual void gc_threads_do(ThreadClosure* tc) const;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    66
  virtual void print_on_error(outputStream* st) const;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    67
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    68
  // Perform a full collection of the heap; intended for use in implementing
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    69
  // "System.gc". This implies as full a collection as the CollectedHeap
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    70
  // supports. Caller does not hold the Heap_lock on entry.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    71
  void collect(GCCause::Cause cause);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    72
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    73
  bool is_in_closed_subset(const void* p) const {
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    74
    return is_in_reserved(p);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    75
  }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    76
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    77
  bool card_mark_must_follow_store() const {
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    78
    return true;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    79
  }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    80
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    81
  void stop();
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    82
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    83
  // If "young_gen_as_roots" is false, younger generations are
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    84
  // not scanned as roots; in this case, the caller must be arranging to
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    85
  // scan the younger generations itself.  (For example, a generation might
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    86
  // explicitly mark reachable objects in younger generations, to avoid
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    87
  // excess storage retention.)
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    88
  void cms_process_roots(StrongRootsScope* scope,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    89
                         bool young_gen_as_roots,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    90
                         ScanningOption so,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    91
                         bool only_strong_roots,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    92
                         OopsInGenClosure* root_closure,
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    93
                         CLDClosure* cld_closure);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    94
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    95
private:
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    96
  WorkGang* _workers;
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    97
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    98
  virtual void gc_prologue(bool full);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    99
  virtual void gc_epilogue(bool full);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   100
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   101
  // Accessor for memory state verification support
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   102
  NOT_PRODUCT(
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   103
    virtual size_t skip_header_HeapWords() { return CMSCollector::skip_header_HeapWords(); }
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   104
  )
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   105
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   106
  // Returns success or failure.
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   107
  void create_cms_collector();
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   108
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   109
  // In support of ExplicitGCInvokesConcurrent functionality
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   110
  bool should_do_concurrent_full_gc(GCCause::Cause cause);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   111
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   112
  void collect_mostly_concurrent(GCCause::Cause cause);
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   113
};
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   114
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
   115
#endif // SHARE_VM_GC_CMS_CMSHEAP_HPP