src/hotspot/share/gc/epsilon/epsilonHeap.hpp
author shade
Thu, 31 May 2018 15:43:02 +0200
branchepsilon-gc-branch
changeset 56641 ecdf81479e0f
parent 56627 43bfde126ee6
permissions -rw-r--r--
Multiple threads should print/update counters once
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     1
/*
56350
56014b46de69 Update copyrights
shade
parents: 56277
diff changeset
     2
 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     3
 *
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     6
 * published by the Free Software Foundation.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     7
 *
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    12
 * accompanied this code).
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    13
 *
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    17
 *
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    20
 * questions.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    21
 *
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    22
 */
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    23
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    24
#ifndef SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    25
#define SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    26
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    27
#include "gc/shared/collectedHeap.hpp"
56354
4b9449c330fb Fix non-PCH build
shade
parents: 56352
diff changeset
    28
#include "gc/shared/softRefPolicy.hpp"
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    29
#include "gc/shared/space.hpp"
55975
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    30
#include "services/memoryManager.hpp"
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    31
#include "gc/epsilon/epsilonCollectorPolicy.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    32
#include "gc/epsilon/epsilonMonitoringSupport.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    33
#include "gc/epsilon/epsilonBarrierSet.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    34
#include "gc/epsilon/epsilon_globals.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    35
55939
c5c3e1a5c3f0 Rename EpsilonCollectedHeap to EpsilonHeap.
shade
parents: 55767
diff changeset
    36
class EpsilonHeap : public CollectedHeap {
56576
92316ff16d5c Serviceability support for Epsilon
shade
parents: 56508
diff changeset
    37
  friend class VMStructs;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    38
private:
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    39
  EpsilonCollectorPolicy* _policy;
56276
shade
parents: 55979
diff changeset
    40
  SoftRefPolicy _soft_ref_policy;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    41
  EpsilonMonitoringSupport* _monitoring_support;
55975
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    42
  MemoryPool* _pool;
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    43
  GCMemoryManager _memory_manager;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    44
  ContiguousSpace* _space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    45
  VirtualSpace _virtual_space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    46
  size_t _max_tlab_size;
55979
669f8c047c9c Print heap counters occasionally
shade
parents: 55975
diff changeset
    47
  size_t _step_counter_update;
669f8c047c9c Print heap counters occasionally
shade
parents: 55975
diff changeset
    48
  size_t _step_heap_print;
56577
338a117fb65c Elastic TLAB machinery should handle decays
shade
parents: 56576
diff changeset
    49
  int64_t _decay_time_ns;
56641
ecdf81479e0f Multiple threads should print/update counters once
shade
parents: 56627
diff changeset
    50
  volatile size_t _last_counter_update;
ecdf81479e0f Multiple threads should print/update counters once
shade
parents: 56627
diff changeset
    51
  volatile size_t _last_heap_print;
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    52
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    53
public:
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    54
  static EpsilonHeap* heap();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    55
55975
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    56
  EpsilonHeap(EpsilonCollectorPolicy* p) :
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    57
          _policy(p),
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    58
          _memory_manager("Epsilon Heap", "") {};
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    59
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    60
  virtual Name kind() const {
56422
shade
parents: 56354
diff changeset
    61
    return CollectedHeap::Epsilon;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    62
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    63
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    64
  virtual const char* name() const {
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    65
    return "Epsilon";
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    66
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    67
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    68
  virtual CollectorPolicy* collector_policy() const {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    69
    return _policy;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    70
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    71
56276
shade
parents: 55979
diff changeset
    72
  virtual SoftRefPolicy* soft_ref_policy() {
shade
parents: 55979
diff changeset
    73
    return &_soft_ref_policy;
shade
parents: 55979
diff changeset
    74
  }
shade
parents: 55979
diff changeset
    75
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    76
  virtual jint initialize();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    77
  virtual void post_initialize();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    78
  virtual void initialize_serviceability();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    79
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    80
  virtual GrowableArray<GCMemoryManager*> memory_managers();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    81
  virtual GrowableArray<MemoryPool*> memory_pools();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    82
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    83
  virtual size_t max_capacity() const { return _virtual_space.reserved_size();  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    84
  virtual size_t capacity()     const { return _virtual_space.committed_size(); }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    85
  virtual size_t used()         const { return _space->used(); }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    86
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    87
  virtual bool is_in(const void* p) const {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    88
    return _space->is_in(p);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    89
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    90
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    91
  virtual bool is_scavengable(oop obj) {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    92
    // No GC is going to happen, therefore no objects ever move.
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    93
    return false;
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    94
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    95
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    96
  virtual bool is_maximal_no_gc() const {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    97
    // No GC is going to happen. Return "we are at max", when we are about to fail.
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    98
    return used() == capacity();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    99
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   100
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   101
  // Allocation
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   102
  HeapWord* allocate_work(size_t size);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   103
  virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
56508
shade
parents: 56492
diff changeset
   104
  virtual HeapWord* allocate_new_tlab(size_t min_size,
shade
parents: 56492
diff changeset
   105
                                      size_t requested_size,
shade
parents: 56492
diff changeset
   106
                                      size_t* actual_size);
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   107
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   108
  // TLAB allocation
56627
43bfde126ee6 Remove UseTLAB from supports_tlab_allocation
shade
parents: 56577
diff changeset
   109
  virtual bool supports_tlab_allocation()           const { return true;           }
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   110
  virtual size_t tlab_capacity(Thread* thr)         const { return capacity();     }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   111
  virtual size_t tlab_used(Thread* thr)             const { return used();         }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   112
  virtual size_t max_tlab_size()                    const { return _max_tlab_size; }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   113
  virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   114
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   115
  virtual void collect(GCCause::Cause cause);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   116
  virtual void do_full_collection(bool clear_all_soft_refs);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   117
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   118
  // Heap walking support
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   119
  virtual void safe_object_iterate(ObjectClosure* cl);
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   120
  virtual void object_iterate(ObjectClosure* cl) {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   121
    safe_object_iterate(cl);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   122
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   123
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   124
  // No support for block parsing.
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   125
  virtual HeapWord* block_start(const void* addr) const { return NULL;  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   126
  virtual size_t block_size(const HeapWord* addr) const { return 0;     }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   127
  virtual bool block_is_obj(const HeapWord* addr) const { return false; }
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   128
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   129
  // No GC threads
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   130
  virtual void print_gc_threads_on(outputStream* st) const {}
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   131
  virtual void gc_threads_do(ThreadClosure* tc) const {}
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   132
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   133
  // No heap verification
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   134
  virtual void prepare_for_verify() {}
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   135
  virtual void verify(VerifyOption option) {}
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   136
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   137
  virtual jlong millis_since_last_gc() {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   138
    // Report time since the VM start
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   139
    return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   140
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   141
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   142
  virtual void print_on(outputStream* st) const;
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   143
  virtual void print_tracing_info() const;
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   144
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   145
};
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   146
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   147
#endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP