src/hotspot/share/gc/epsilon/epsilonHeap.cpp
author shade
Thu, 11 Oct 2018 10:42:17 +0200
changeset 52091 b25bfa10f52f
parent 50523 7b7c75d87f9b
child 52150 f586d225bd0b
permissions -rw-r--r--
8212005: Epsilon elastic TLAB sizing may cause misalignment Reviewed-by: rkennke, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50523
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     1
/*
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     2
 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     3
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     6
 * published by the Free Software Foundation.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     7
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    12
 * accompanied this code).
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    13
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    17
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    20
 * questions.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    21
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    22
 */
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    23
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    24
#include "precompiled.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    25
#include "gc/epsilon/epsilonHeap.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    26
#include "gc/epsilon/epsilonMemoryPool.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    27
#include "gc/epsilon/epsilonThreadLocalData.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    28
#include "memory/allocation.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    29
#include "memory/allocation.inline.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    30
#include "memory/resourceArea.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    31
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    32
jint EpsilonHeap::initialize() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    33
  size_t align = _policy->heap_alignment();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    34
  size_t init_byte_size = align_up(_policy->initial_heap_byte_size(), align);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    35
  size_t max_byte_size  = align_up(_policy->max_heap_byte_size(), align);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    36
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    37
  // Initialize backing storage
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    38
  ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size, align);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    39
  _virtual_space.initialize(heap_rs, init_byte_size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    40
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    41
  MemRegion committed_region((HeapWord*)_virtual_space.low(),          (HeapWord*)_virtual_space.high());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    42
  MemRegion  reserved_region((HeapWord*)_virtual_space.low_boundary(), (HeapWord*)_virtual_space.high_boundary());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    43
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    44
  initialize_reserved_region(reserved_region.start(), reserved_region.end());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    45
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    46
  _space = new ContiguousSpace();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    47
  _space->initialize(committed_region, /* clear_space = */ true, /* mangle_space = */ true);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    48
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    49
  // Precompute hot fields
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    50
  _max_tlab_size = MIN2(CollectedHeap::max_tlab_size(), EpsilonMaxTLABSize / HeapWordSize);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    51
  _step_counter_update = MIN2<size_t>(max_byte_size / 16, EpsilonUpdateCountersStep);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    52
  _step_heap_print = (EpsilonPrintHeapSteps == 0) ? SIZE_MAX : (max_byte_size / EpsilonPrintHeapSteps);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    53
  _decay_time_ns = (int64_t) EpsilonTLABDecayTime * NANOSECS_PER_MILLISEC;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    54
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    55
  // Enable monitoring
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    56
  _monitoring_support = new EpsilonMonitoringSupport(this);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    57
  _last_counter_update = 0;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    58
  _last_heap_print = 0;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    59
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    60
  // Install barrier set
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    61
  BarrierSet::set_barrier_set(new EpsilonBarrierSet());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    62
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    63
  // All done, print out the configuration
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    64
  if (init_byte_size != max_byte_size) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    65
    log_info(gc)("Resizeable heap; starting at " SIZE_FORMAT "M, max: " SIZE_FORMAT "M, step: " SIZE_FORMAT "M",
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    66
                 init_byte_size / M, max_byte_size / M, EpsilonMinHeapExpand / M);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    67
  } else {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    68
    log_info(gc)("Non-resizeable heap; start/max: " SIZE_FORMAT "M", init_byte_size / M);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    69
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    70
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    71
  if (UseTLAB) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    72
    log_info(gc)("Using TLAB allocation; max: " SIZE_FORMAT "K", _max_tlab_size * HeapWordSize / K);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    73
    if (EpsilonElasticTLAB) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    74
      log_info(gc)("Elastic TLABs enabled; elasticity: %.2fx", EpsilonTLABElasticity);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    75
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    76
    if (EpsilonElasticTLABDecay) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    77
      log_info(gc)("Elastic TLABs decay enabled; decay time: " SIZE_FORMAT "ms", EpsilonTLABDecayTime);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    78
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    79
  } else {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    80
    log_info(gc)("Not using TLAB allocation");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    81
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    82
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    83
  return JNI_OK;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    84
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    85
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    86
void EpsilonHeap::post_initialize() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    87
  CollectedHeap::post_initialize();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    88
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    89
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    90
void EpsilonHeap::initialize_serviceability() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    91
  _pool = new EpsilonMemoryPool(this);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    92
  _memory_manager.add_pool(_pool);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    93
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    94
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    95
GrowableArray<GCMemoryManager*> EpsilonHeap::memory_managers() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    96
  GrowableArray<GCMemoryManager*> memory_managers(1);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    97
  memory_managers.append(&_memory_manager);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    98
  return memory_managers;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    99
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   100
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   101
GrowableArray<MemoryPool*> EpsilonHeap::memory_pools() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   102
  GrowableArray<MemoryPool*> memory_pools(1);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   103
  memory_pools.append(_pool);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   104
  return memory_pools;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   105
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   106
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   107
size_t EpsilonHeap::unsafe_max_tlab_alloc(Thread* thr) const {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   108
  // Return max allocatable TLAB size, and let allocation path figure out
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   109
  // the actual TLAB allocation size.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   110
  return _max_tlab_size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   111
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   112
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   113
EpsilonHeap* EpsilonHeap::heap() {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   114
  CollectedHeap* heap = Universe::heap();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   115
  assert(heap != NULL, "Uninitialized access to EpsilonHeap::heap()");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   116
  assert(heap->kind() == CollectedHeap::Epsilon, "Not an Epsilon heap");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   117
  return (EpsilonHeap*)heap;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   118
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   119
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   120
HeapWord* EpsilonHeap::allocate_work(size_t size) {
52091
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   121
  assert(is_object_aligned(size), "Allocation size should be aligned: " SIZE_FORMAT, size);
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   122
50523
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   123
  HeapWord* res = _space->par_allocate(size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   124
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   125
  while (res == NULL) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   126
    // Allocation failed, attempt expansion, and retry:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   127
    MutexLockerEx ml(Heap_lock);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   128
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   129
    size_t space_left = max_capacity() - capacity();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   130
    size_t want_space = MAX2(size, EpsilonMinHeapExpand);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   131
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   132
    if (want_space < space_left) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   133
      // Enough space to expand in bulk:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   134
      bool expand = _virtual_space.expand_by(want_space);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   135
      assert(expand, "Should be able to expand");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   136
    } else if (size < space_left) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   137
      // No space to expand in bulk, and this allocation is still possible,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   138
      // take all the remaining space:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   139
      bool expand = _virtual_space.expand_by(space_left);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   140
      assert(expand, "Should be able to expand");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   141
    } else {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   142
      // No space left:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   143
      return NULL;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   144
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   145
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   146
    _space->set_end((HeapWord *) _virtual_space.high());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   147
    res = _space->par_allocate(size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   148
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   149
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   150
  size_t used = _space->used();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   151
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   152
  // Allocation successful, update counters
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   153
  {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   154
    size_t last = _last_counter_update;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   155
    if ((used - last >= _step_counter_update) && Atomic::cmpxchg(used, &_last_counter_update, last) == last) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   156
      _monitoring_support->update_counters();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   157
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   158
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   159
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   160
  // ...and print the occupancy line, if needed
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   161
  {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   162
    size_t last = _last_heap_print;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   163
    if ((used - last >= _step_heap_print) && Atomic::cmpxchg(used, &_last_heap_print, last) == last) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   164
      log_info(gc)("Heap: " SIZE_FORMAT "M reserved, " SIZE_FORMAT "M (%.2f%%) committed, " SIZE_FORMAT "M (%.2f%%) used",
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   165
                   max_capacity() / M,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   166
                   capacity() / M,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   167
                   capacity() * 100.0 / max_capacity(),
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   168
                   used / M,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   169
                   used * 100.0 / max_capacity());
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   170
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   171
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   172
52091
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   173
  assert(is_object_aligned(res), "Object should be aligned: " PTR_FORMAT, p2i(res));
50523
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   174
  return res;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   175
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   176
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   177
HeapWord* EpsilonHeap::allocate_new_tlab(size_t min_size,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   178
                                         size_t requested_size,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   179
                                         size_t* actual_size) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   180
  Thread* thread = Thread::current();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   181
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   182
  // Defaults in case elastic paths are not taken
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   183
  bool fits = true;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   184
  size_t size = requested_size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   185
  size_t ergo_tlab = requested_size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   186
  int64_t time = 0;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   187
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   188
  if (EpsilonElasticTLAB) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   189
    ergo_tlab = EpsilonThreadLocalData::ergo_tlab_size(thread);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   190
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   191
    if (EpsilonElasticTLABDecay) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   192
      int64_t last_time = EpsilonThreadLocalData::last_tlab_time(thread);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   193
      time = (int64_t) os::javaTimeNanos();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   194
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   195
      assert(last_time <= time, "time should be monotonic");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   196
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   197
      // If the thread had not allocated recently, retract the ergonomic size.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   198
      // This conserves memory when the thread had initial burst of allocations,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   199
      // and then started allocating only sporadically.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   200
      if (last_time != 0 && (time - last_time > _decay_time_ns)) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   201
        ergo_tlab = 0;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   202
        EpsilonThreadLocalData::set_ergo_tlab_size(thread, 0);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   203
      }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   204
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   205
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   206
    // If we can fit the allocation under current TLAB size, do so.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   207
    // Otherwise, we want to elastically increase the TLAB size.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   208
    fits = (requested_size <= ergo_tlab);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   209
    if (!fits) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   210
      size = (size_t) (ergo_tlab * EpsilonTLABElasticity);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   211
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   212
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   213
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   214
  // Always honor boundaries
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   215
  size = MAX2(min_size, MIN2(_max_tlab_size, size));
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   216
52091
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   217
  // Always honor alignment
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   218
  size = align_up(size, MinObjAlignment);
b25bfa10f52f 8212005: Epsilon elastic TLAB sizing may cause misalignment
shade
parents: 50523
diff changeset
   219
50523
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   220
  if (log_is_enabled(Trace, gc)) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   221
    ResourceMark rm;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   222
    log_trace(gc)("TLAB size for \"%s\" (Requested: " SIZE_FORMAT "K, Min: " SIZE_FORMAT
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   223
                          "K, Max: " SIZE_FORMAT "K, Ergo: " SIZE_FORMAT "K) -> " SIZE_FORMAT "K",
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   224
                  thread->name(),
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   225
                  requested_size * HeapWordSize / K,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   226
                  min_size * HeapWordSize / K,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   227
                  _max_tlab_size * HeapWordSize / K,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   228
                  ergo_tlab * HeapWordSize / K,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   229
                  size * HeapWordSize / K);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   230
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   231
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   232
  // All prepared, let's do it!
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   233
  HeapWord* res = allocate_work(size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   234
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   235
  if (res != NULL) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   236
    // Allocation successful
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   237
    *actual_size = size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   238
    if (EpsilonElasticTLABDecay) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   239
      EpsilonThreadLocalData::set_last_tlab_time(thread, time);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   240
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   241
    if (EpsilonElasticTLAB && !fits) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   242
      // If we requested expansion, this is our new ergonomic TLAB size
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   243
      EpsilonThreadLocalData::set_ergo_tlab_size(thread, size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   244
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   245
  } else {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   246
    // Allocation failed, reset ergonomics to try and fit smaller TLABs
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   247
    if (EpsilonElasticTLAB) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   248
      EpsilonThreadLocalData::set_ergo_tlab_size(thread, 0);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   249
    }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   250
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   251
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   252
  return res;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   253
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   254
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   255
HeapWord* EpsilonHeap::mem_allocate(size_t size, bool *gc_overhead_limit_was_exceeded) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   256
  *gc_overhead_limit_was_exceeded = false;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   257
  return allocate_work(size);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   258
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   259
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   260
void EpsilonHeap::collect(GCCause::Cause cause) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   261
  log_info(gc)("GC request for \"%s\" is ignored", GCCause::to_string(cause));
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   262
  _monitoring_support->update_counters();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   263
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   264
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   265
void EpsilonHeap::do_full_collection(bool clear_all_soft_refs) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   266
  log_info(gc)("Full GC request for \"%s\" is ignored", GCCause::to_string(gc_cause()));
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   267
  _monitoring_support->update_counters();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   268
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   269
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   270
void EpsilonHeap::safe_object_iterate(ObjectClosure *cl) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   271
  _space->safe_object_iterate(cl);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   272
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   273
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   274
void EpsilonHeap::print_on(outputStream *st) const {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   275
  st->print_cr("Epsilon Heap");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   276
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   277
  // Cast away constness:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   278
  ((VirtualSpace)_virtual_space).print_on(st);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   279
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   280
  st->print_cr("Allocation space:");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   281
  _space->print_on(st);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   282
}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   283
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   284
void EpsilonHeap::print_tracing_info() const {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   285
  Log(gc) log;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   286
  size_t allocated_kb = used() / K;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   287
  log.info("Total allocated: " SIZE_FORMAT " KB",
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   288
           allocated_kb);
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   289
  log.info("Average allocation rate: " SIZE_FORMAT " KB/sec",
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   290
           (size_t)(allocated_kb * NANOSECS_PER_SEC / os::elapsed_counter()));
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
   291
}