src/hotspot/share/gc/epsilon/epsilonHeap.hpp
author shade
Thu, 07 Dec 2017 13:05:31 +0100
branchepsilon-gc-branch
changeset 55974 06122633fead
parent 55939 c5c3e1a5c3f0
child 55975 26d15be1c920
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
/*
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
     2
 * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
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"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    28
#include "gc/shared/space.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    29
#include "gc/epsilon/epsilonCollectorPolicy.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    30
#include "gc/epsilon/epsilonMonitoringSupport.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    31
#include "gc/epsilon/epsilonBarrierSet.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    32
#include "gc/epsilon/epsilon_globals.hpp"
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    33
55939
c5c3e1a5c3f0 Rename EpsilonCollectedHeap to EpsilonHeap.
shade
parents: 55767
diff changeset
    34
class EpsilonHeap : public CollectedHeap {
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    35
private:
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    36
  EpsilonCollectorPolicy* _policy;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    37
  EpsilonMonitoringSupport* _monitoring_support;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    38
  ContiguousSpace* _space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    39
  VirtualSpace _virtual_space;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    40
  size_t _max_tlab_size;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    41
  size_t _last_counter_update;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    42
public:
55939
c5c3e1a5c3f0 Rename EpsilonCollectedHeap to EpsilonHeap.
shade
parents: 55767
diff changeset
    43
  EpsilonHeap(EpsilonCollectorPolicy* p) : _policy(p) {};
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    44
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    45
  virtual Name kind() const {
55939
c5c3e1a5c3f0 Rename EpsilonCollectedHeap to EpsilonHeap.
shade
parents: 55767
diff changeset
    46
    return CollectedHeap::EpsilonHeap;
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    47
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    48
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    49
  virtual const char *name() const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    50
    return "Epsilon GC";
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    51
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    52
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    53
  virtual jint initialize();
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    54
55974
shade
parents: 55939
diff changeset
    55
  virtual void post_initialize();
shade
parents: 55939
diff changeset
    56
shade
parents: 55939
diff changeset
    57
  virtual void initialize_serviceability();
shade
parents: 55939
diff changeset
    58
  virtual GrowableArray<GCMemoryManager*> memory_managers();
shade
parents: 55939
diff changeset
    59
  virtual GrowableArray<MemoryPool*> memory_pools();
55767
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    60
55939
c5c3e1a5c3f0 Rename EpsilonCollectedHeap to EpsilonHeap.
shade
parents: 55767
diff changeset
    61
  static EpsilonHeap* heap();
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
  virtual size_t capacity()     const { return _virtual_space.committed_size(); }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    64
  virtual size_t used()         const { return _space->used(); }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    65
  virtual size_t max_capacity() const { return _virtual_space.reserved_size(); }
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
  virtual bool is_maximal_no_gc() const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    68
    // No GC is going to happen, unless we are at capacity.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    69
    // At which point we will fail anyway.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    70
    return used() == capacity();
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    71
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    72
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    73
  virtual bool is_in(const void *p) const { return _space->is_in(p); }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    74
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    75
  virtual bool is_scavengable(oop obj) {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    76
    // Epsilon does not move objects, no objects are scavengable.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    77
    return false;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    78
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    79
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    80
  HeapWord* allocate_work(size_t size);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    81
  virtual HeapWord* mem_allocate(size_t size, bool *gc_overhead_limit_was_exceeded);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    82
  virtual HeapWord* allocate_new_tlab(size_t size);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    83
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    84
  // TLAB allocations
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    85
  virtual bool supports_tlab_allocation()           const { return UseTLAB; }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    86
  virtual size_t tlab_capacity(Thread *thr)         const { return capacity(); }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    87
  virtual size_t tlab_used(Thread *thr)             const { return used(); }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    88
  virtual size_t max_tlab_size()                    const { return _max_tlab_size; }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    89
  virtual size_t unsafe_max_tlab_alloc(Thread *thr) const;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    90
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    91
  virtual bool can_elide_tlab_store_barriers() const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    92
    // No store barriers for Epsilon, allow elision
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    93
    return true;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    94
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    95
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    96
  virtual bool can_elide_initializing_store_barrier(oop new_obj) {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    97
    // No card marks for Epsilon, can elide them all.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    98
    return true;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
    99
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   100
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   101
  virtual bool card_mark_must_follow_store() const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   102
    // No card marks for Epsilon.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   103
    return false;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   104
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   105
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   106
  virtual void collect(GCCause::Cause cause);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   107
  virtual void do_full_collection(bool clear_all_soft_refs);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   108
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   109
  virtual AdaptiveSizePolicy *size_policy() {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   110
    // No such thing for Epsilon
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   111
    return NULL;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   112
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   113
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   114
  virtual CollectorPolicy *collector_policy() const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   115
    return _policy;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   116
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   117
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   118
  virtual void object_iterate(ObjectClosure *cl) {
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
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   122
  virtual void safe_object_iterate(ObjectClosure *cl);
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   123
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   124
  virtual HeapWord* block_start(const void *addr) const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   125
    // Epsilon does not support block parsing.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   126
    return NULL;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   127
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   128
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   129
  virtual size_t block_size(const HeapWord *addr) const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   130
    // Epsilon does not support block parsing.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   131
    return 0;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   132
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   133
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   134
  virtual bool block_is_obj(const HeapWord *addr) const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   135
    // Epsilon does not support block parsing.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   136
    return false;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   137
  }
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
  virtual jlong millis_since_last_gc() {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   140
    // Report time since the VM start
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   141
    return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   142
  }
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
  virtual void prepare_for_verify() {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   145
    // No heap verification.
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
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   148
  virtual void print_gc_threads_on(outputStream *st) const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   149
    // No GC threads.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   150
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   151
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   152
  virtual void gc_threads_do(ThreadClosure *tc) const {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   153
    // No GC threads.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   154
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   155
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   156
  virtual void print_on(outputStream *st) const;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   157
  virtual void print_tracing_info() const;
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   158
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   159
  virtual void verify(VerifyOption option) {
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   160
    // No heap verification for Epsilon.
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   161
  }
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   162
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   163
};
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   164
8e22715afabc Initial import of Epsilon sources from jdk10/sandbox
shade
parents:
diff changeset
   165
#endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP