src/hotspot/share/gc/epsilon/epsilonHeap.hpp
author shade
Thu, 03 May 2018 09:43:47 +0200
branchepsilon-gc-branch
changeset 56508 f67f588ebf15
parent 56492 e1871d34a188
child 56576 92316ff16d5c
permissions -rw-r--r--
Merge
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 {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    37
private:
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    38
  EpsilonCollectorPolicy* _policy;
56276
shade
parents: 55979
diff changeset
    39
  SoftRefPolicy _soft_ref_policy;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    40
  EpsilonMonitoringSupport* _monitoring_support;
55975
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    41
  MemoryPool* _pool;
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    42
  GCMemoryManager _memory_manager;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    43
  ContiguousSpace* _space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    44
  VirtualSpace _virtual_space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    45
  size_t _max_tlab_size;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    46
  size_t _last_counter_update;
55979
669f8c047c9c Print heap counters occasionally
shade
parents: 55975
diff changeset
    47
  size_t _last_heap_print;
669f8c047c9c Print heap counters occasionally
shade
parents: 55975
diff changeset
    48
  size_t _step_counter_update;
669f8c047c9c Print heap counters occasionally
shade
parents: 55975
diff changeset
    49
  size_t _step_heap_print;
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    50
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    51
public:
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    52
  static EpsilonHeap* heap();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    53
55975
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    54
  EpsilonHeap(EpsilonCollectorPolicy* p) :
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    55
          _policy(p),
26d15be1c920 Fixup serviceability for Epsilon.
shade
parents: 55974
diff changeset
    56
          _memory_manager("Epsilon Heap", "") {};
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    57
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    58
  virtual Name kind() const {
56422
shade
parents: 56354
diff changeset
    59
    return CollectedHeap::Epsilon;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    60
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    61
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    62
  virtual const char* name() const {
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    63
    return "Epsilon";
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    64
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    65
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
    66
  virtual CollectorPolicy* collector_policy() const {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    67
    return _policy;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    68
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    69
56276
shade
parents: 55979
diff changeset
    70
  virtual SoftRefPolicy* soft_ref_policy() {
shade
parents: 55979
diff changeset
    71
    return &_soft_ref_policy;
shade
parents: 55979
diff changeset
    72
  }
shade
parents: 55979
diff changeset
    73
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    74
  virtual jint initialize();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    75
  virtual void post_initialize();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    76
  virtual void initialize_serviceability();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    77
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    78
  virtual GrowableArray<GCMemoryManager*> memory_managers();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    79
  virtual GrowableArray<MemoryPool*> memory_pools();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    80
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    81
  virtual size_t max_capacity() const { return _virtual_space.reserved_size();  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    82
  virtual size_t capacity()     const { return _virtual_space.committed_size(); }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    83
  virtual size_t used()         const { return _space->used(); }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    84
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    85
  virtual bool is_in(const void* p) const {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    86
    return _space->is_in(p);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    87
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    88
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    89
  virtual bool is_scavengable(oop obj) {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    90
    // No GC is going to happen, therefore no objects ever move.
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    91
    return false;
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    92
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    93
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    94
  virtual bool is_maximal_no_gc() const {
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    95
    // 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
    96
    return used() == capacity();
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    97
  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    98
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
    99
  // Allocation
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   100
  HeapWord* allocate_work(size_t size);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   101
  virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
56508
shade
parents: 56492
diff changeset
   102
  virtual HeapWord* allocate_new_tlab(size_t min_size,
shade
parents: 56492
diff changeset
   103
                                      size_t requested_size,
shade
parents: 56492
diff changeset
   104
                                      size_t* actual_size);
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   105
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   106
  // TLAB allocation
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   107
  virtual bool supports_tlab_allocation()           const { return UseTLAB;        }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   108
  virtual size_t tlab_capacity(Thread* thr)         const { return capacity();     }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   109
  virtual size_t tlab_used(Thread* thr)             const { return used();         }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   110
  virtual size_t max_tlab_size()                    const { return _max_tlab_size; }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   111
  virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   112
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   113
  virtual void collect(GCCause::Cause cause);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   114
  virtual void do_full_collection(bool clear_all_soft_refs);
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   115
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   116
  // Heap walking support
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   117
  virtual void safe_object_iterate(ObjectClosure* cl);
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   118
  virtual void object_iterate(ObjectClosure* cl) {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   119
    safe_object_iterate(cl);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   120
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   121
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   122
  // No support for block parsing.
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   123
  virtual HeapWord* block_start(const void* addr) const { return NULL;  }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   124
  virtual size_t block_size(const HeapWord* addr) const { return 0;     }
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   125
  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
   126
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   127
  // No GC threads
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   128
  virtual void print_gc_threads_on(outputStream* st) const {}
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   129
  virtual void gc_threads_do(ThreadClosure* tc) const {}
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   130
56492
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   131
  // No heap verification
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   132
  virtual void prepare_for_verify() {}
e1871d34a188 Small bugfixes and improvements
shade
parents: 56422
diff changeset
   133
  virtual void verify(VerifyOption option) {}
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   134
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   135
  virtual jlong millis_since_last_gc() {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   136
    // Report time since the VM start
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   137
    return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   138
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   139
56352
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   140
  virtual void print_on(outputStream* st) const;
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   141
  virtual void print_tracing_info() const;
ebb84e128ed3 Whitespace, formatting, dead code elimination
shade
parents: 56350
diff changeset
   142
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   143
};
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   144
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   145
#endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP