hotspot/src/share/vm/gc/parallel/psScavenge.cpp
author stefank
Tue, 11 Apr 2017 23:45:37 +0200
changeset 46565 8dcbf532ea00
parent 40096 246c62cd9180
child 46795 623a5e42deb6
permissions -rw-r--r--
8178490: Usages of is_object_aligned with pointers are broken Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    25
#include "precompiled.hpp"
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents: 24092
diff changeset
    26
#include "classfile/stringTable.hpp"
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 11636
diff changeset
    27
#include "code/codeCache.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    28
#include "gc/parallel/cardTableExtension.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    29
#include "gc/parallel/gcTaskManager.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    30
#include "gc/parallel/parallelScavengeHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    31
#include "gc/parallel/psAdaptiveSizePolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    32
#include "gc/parallel/psMarkSweep.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
    33
#include "gc/parallel/psParallelCompact.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    34
#include "gc/parallel/psScavenge.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    35
#include "gc/parallel/psTasks.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    36
#include "gc/shared/collectorPolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    37
#include "gc/shared/gcCause.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    38
#include "gc/shared/gcHeapSummary.hpp"
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 33105
diff changeset
    39
#include "gc/shared/gcId.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    40
#include "gc/shared/gcLocker.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    41
#include "gc/shared/gcTimer.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    42
#include "gc/shared/gcTrace.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
    43
#include "gc/shared/gcTraceTime.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    44
#include "gc/shared/isGCActiveMark.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    45
#include "gc/shared/referencePolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    46
#include "gc/shared/referenceProcessor.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    47
#include "gc/shared/spaceDecorator.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    48
#include "memory/resourceArea.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
    49
#include "logging/log.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    50
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    51
#include "runtime/biasedLocking.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    52
#include "runtime/fprofiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    53
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    54
#include "runtime/threadCritical.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    55
#include "runtime/vmThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    56
#include "runtime/vm_operations.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    57
#include "services/memoryService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    58
#include "utilities/stack.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
HeapWord*                  PSScavenge::_to_space_top_before_gc = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
int                        PSScavenge::_consecutive_skipped_scavenges = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
ReferenceProcessor*        PSScavenge::_ref_processor = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
CardTableExtension*        PSScavenge::_card_table = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
bool                       PSScavenge::_survivor_overflow = false;
13925
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13924
diff changeset
    65
uint                       PSScavenge::_tenuring_threshold = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
HeapWord*                  PSScavenge::_young_generation_boundary = NULL;
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 17846
diff changeset
    67
uintptr_t                  PSScavenge::_young_generation_boundary_compressed = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
elapsedTimer               PSScavenge::_accumulated_time;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    69
STWGCTimer                 PSScavenge::_gc_timer;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    70
ParallelScavengeTracer     PSScavenge::_gc_tracer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
CollectorCounters*         PSScavenge::_counters = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// Define before use
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
class PSIsAliveClosure: public BoolObjectClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  bool do_object_b(oop p) {
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 17846
diff changeset
    77
    return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
PSIsAliveClosure PSScavenge::_is_alive_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
class PSKeepAliveClosure: public OopClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  MutableSpace* _to_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  PSPromotionManager* _promotion_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  PSKeepAliveClosure(PSPromotionManager* pm) : _promotion_manager(pm) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
    90
    ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    _to_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    assert(_promotion_manager != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    96
  template <class T> void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    97
    assert (!oopDesc::is_null(*p), "expected non-null ref");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    98
    assert ((oopDesc::load_decode_heap_oop_not_null(p))->is_oop(),
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    99
            "expected an oop while scanning weak refs");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    // Weak refs may be visited more than once.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   102
    if (PSScavenge::should_scavenge(p, _to_space)) {
29208
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 28212
diff changeset
   103
      _promotion_manager->copy_and_push_safe_barrier<T, /*promote_immediately=*/false>(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
  virtual void do_oop(oop* p)       { PSKeepAliveClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
  virtual void do_oop(narrowOop* p) { PSKeepAliveClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
class PSEvacuateFollowersClosure: public VoidClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  PSPromotionManager* _promotion_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  PSEvacuateFollowersClosure(PSPromotionManager* pm) : _promotion_manager(pm) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   116
  virtual void do_void() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    assert(_promotion_manager != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    _promotion_manager->drain_stacks(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    guarantee(_promotion_manager->stacks_empty(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
              "stacks should be empty at this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
class PSRefProcTaskProxy: public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  ProcessTask & _rp_task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  uint          _work_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  PSRefProcTaskProxy(ProcessTask & rp_task, uint work_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    : _rp_task(rp_task),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      _work_id(work_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  virtual char* name() { return (char *)"Process referents by policy in parallel"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
void PSRefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  PSPromotionManager* promotion_manager =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    PSPromotionManager::gc_thread_promotion_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  assert(promotion_manager != NULL, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  PSKeepAliveClosure keep_alive(promotion_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  PSEvacuateFollowersClosure evac_followers(promotion_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  PSIsAliveClosure is_alive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  _rp_task.work(_work_id, is_alive, keep_alive, evac_followers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
class PSRefEnqueueTaskProxy: public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  EnqueueTask& _enq_task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  uint         _work_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  PSRefEnqueueTaskProxy(EnqueueTask& enq_task, uint work_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    : _enq_task(enq_task),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      _work_id(work_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  virtual char* name() { return (char *)"Enqueue reference objects in parallel"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  virtual void do_it(GCTaskManager* manager, uint which)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    _enq_task.work(_work_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
class PSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  virtual void execute(ProcessTask& task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  virtual void execute(EnqueueTask& task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
void PSRefProcTaskExecutor::execute(ProcessTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  GCTaskQueue* q = GCTaskQueue::create();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   176
  GCTaskManager* manager = ParallelScavengeHeap::gc_task_manager();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   177
  for(uint i=0; i < manager->active_workers(); i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    q->enqueue(new PSRefProcTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   180
  ParallelTaskTerminator terminator(manager->active_workers(),
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5918
diff changeset
   181
                 (TaskQueueSetSuper*) PSPromotionManager::stack_array_depth());
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   182
  if (task.marks_oops_alive() && manager->active_workers() > 1) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   183
    for (uint j = 0; j < manager->active_workers(); j++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      q->enqueue(new StealTask(&terminator));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   187
  manager->execute_and_wait(q);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
void PSRefProcTaskExecutor::execute(EnqueueTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  GCTaskQueue* q = GCTaskQueue::create();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   194
  GCTaskManager* manager = ParallelScavengeHeap::gc_task_manager();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   195
  for(uint i=0; i < manager->active_workers(); i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    q->enqueue(new PSRefEnqueueTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  }
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   198
  manager->execute_and_wait(q);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
// This method contains all heap specific policy for invoking scavenge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
// PSScavenge::invoke_no_policy() will do nothing but attempt to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
// scavenge. It will not clean up after failed promotions, bail out if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
// we've exceeded policy time limits, or any other special behavior.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
// All such policy should be placed here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
// Note that this method should only be called from the vm_thread while
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
// at a safepoint!
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   209
bool PSScavenge::invoke() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   212
  assert(!ParallelScavengeHeap::heap()->is_gc_active(), "not reentrant");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   214
  ParallelScavengeHeap* const heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  PSAdaptiveSizePolicy* policy = heap->size_policy();
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   216
  IsGCActiveMark mark;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   218
  const bool scavenge_done = PSScavenge::invoke_no_policy();
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   219
  const bool need_full_gc = !scavenge_done ||
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   220
    policy->should_full_GC(heap->old_gen()->free_in_bytes());
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   221
  bool full_gc_done = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   223
  if (UsePerfData) {
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   224
    PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   225
    const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped;
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   226
    counters->update_full_follows_scavenge(ffs_val);
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   227
  }
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   228
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   229
  if (need_full_gc) {
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   230
    GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   231
    CollectorPolicy* cp = heap->collector_policy();
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   232
    const bool clear_all_softrefs = cp->should_clear_all_soft_refs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   234
    if (UseParallelOldGC) {
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   235
      full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   236
    } else {
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   237
      full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  }
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   240
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   241
  return full_gc_done;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// This method contains no policy. You should probably
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
// be calling invoke() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
bool PSScavenge::invoke_no_policy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
21767
41eaa9a17059 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 20317
diff changeset
   250
  _gc_timer.register_gc_start();
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   251
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  TimeStamp scavenge_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  TimeStamp scavenge_midpoint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  TimeStamp scavenge_exit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  scavenge_entry.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35061
diff changeset
   258
  if (GCLocker::check_active_before_gc()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   262
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  GCCause::Cause gc_cause = heap->gc_cause();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // Check for potential problems.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  if (!should_attempt_scavenge()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 33105
diff changeset
   270
  GCIdMark gc_id_mark;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   271
  _gc_tracer.report_gc_start(heap->gc_cause(), _gc_timer.gc_start());
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   272
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  bool promotion_failure_occurred = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  PSYoungGen* young_gen = heap->young_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  PSOldGen* old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  PSAdaptiveSizePolicy* size_policy = heap->size_policy();
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   278
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  heap->increment_total_collections();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
31634
0aa645cd8cc3 7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents: 31330
diff changeset
   281
  if (AdaptiveSizePolicy::should_update_eden_stats(gc_cause)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    // Gather the feedback data for eden occupancy.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    young_gen->eden_space()->accumulate_statistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11174
diff changeset
   286
  heap->print_heap_before_gc();
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   287
  heap->trace_heap_before_gc(&_gc_tracer);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  assert(!NeverTenure || _tenuring_threshold == markOopDesc::max_age + 1, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  assert(!AlwaysTenure || _tenuring_threshold == 0, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // Fill in TLABs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  heap->accumulate_statistics_all_tlabs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  heap->ensure_parsability(true);  // retire TLABs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    HandleMark hm;  // Discard invalid handles created during verification
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   298
    Universe::verify("Before GC");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    HandleMark hm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   305
    GCTraceCPUTime tcpu;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   306
    GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    TraceCollectorStats tcs(counters());
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8728
diff changeset
   308
    TraceMemoryManagerStats tms(false /* not full GC */,gc_cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
24941
4ebbe176a7b1 8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents: 24845
diff changeset
   310
    if (TraceYoungGenTime) accumulated_time()->start();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    // Let the size policy know we're starting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    size_policy->minor_collection_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    // Verify the object start arrays.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    if (VerifyObjectStartArray &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
        VerifyBeforeGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
      old_gen->verify_object_start_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    // Verify no unmarked old->young roots
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    if (VerifyRememberedSets) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      CardTableExtension::verify_all_young_refs_imprecise();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
33227
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   326
    assert(young_gen->to_space()->is_empty(),
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   327
           "Attempt to scavenge with live objects in to_space");
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   328
    young_gen->to_space()->clear(SpaceDecorator::Mangle);
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   329
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    save_to_space_top_before_gc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   332
#if defined(COMPILER2) || INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   333
    DerivedPointerTable::clear();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   334
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
28212
647b7d0efb88 8066827: Remove ReferenceProcessor::clean_up_discovered_references()
kbarrett
parents: 27887
diff changeset
   336
    reference_processor()->enable_discovery();
1610
5dddd195cc86 6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents: 1606
diff changeset
   337
    reference_processor()->setup_policy(false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   339
    PreGCValues pre_gc_values(heap);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    // Reset our survivor overflow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    set_survivor_overflow(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   344
    // We need to save the old top values before
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    // creating the promotion_manager. We pass the top
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    // values to the card_table, to prevent it from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    // straying into the promotion labs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    HeapWord* old_top = old_gen->object_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    // Release all previously held resources
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    gc_task_manager()->release_all_resources();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   353
    // Set the number of GC threads to be used in this collection
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   354
    gc_task_manager()->set_active_gang();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   355
    gc_task_manager()->task_idle_workers();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   356
    // Get the active number of workers here and use that value
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   357
    // throughout the methods.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   358
    uint active_workers = gc_task_manager()->active_workers();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   359
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    PSPromotionManager::pre_scavenge();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    // We'll use the promotion manager again later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   365
      GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   366
      ParallelScavengeHeap::ParStrongRootsScope psrs;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   370
      if (!old_gen->object_space()->is_empty()) {
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   371
        // There are only old-to-young pointers if there are objects
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   372
        // in the old gen.
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   373
        uint stripe_total = active_workers;
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   374
        for(uint i=0; i < stripe_total; i++) {
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   375
          q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   376
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      // We scan the thread roots in parallel
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
      Threads::create_thread_roots_tasks(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::flat_profiler));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 17625
diff changeset
   387
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti));
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   389
      q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      ParallelTaskTerminator terminator(
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   392
        active_workers,
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5918
diff changeset
   393
                  (TaskQueueSetSuper*) promotion_manager->stack_array_depth());
40096
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   394
        // If active_workers can exceed 1, add a StrealTask.
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   395
        // PSPromotionManager::drain_stacks_depth() does not fully drain its
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   396
        // stacks and expects a StealTask to complete the draining if
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   397
        // ParallelGCThreads is > 1.
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   398
        if (gc_task_manager()->workers() > 1) {
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   399
          for (uint j = 0; j < active_workers; j++) {
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   400
            q->enqueue(new StealTask(&terminator));
246c62cd9180 8159073: : Error handling incomplete when creating GC threads lazily
jmasa
parents: 38080
diff changeset
   401
          }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    scavenge_midpoint.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    // Process reference objects discovered during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    {
37146
209e0fe518bb 8152100: Rework and unify the GC phase logging
stefank
parents: 37045
diff changeset
   411
      GCTraceTime(Debug, gc, phases) tm("Reference Processing", &_gc_timer);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   412
1610
5dddd195cc86 6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents: 1606
diff changeset
   413
      reference_processor()->setup_policy(false); // not always_clear
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   414
      reference_processor()->set_active_mt_degree(active_workers);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      PSKeepAliveClosure keep_alive(promotion_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      PSEvacuateFollowersClosure evac_followers(promotion_manager);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   417
      ReferenceProcessorStats stats;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
      if (reference_processor()->processing_is_mt()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
        PSRefProcTaskExecutor task_executor;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   420
        stats = reference_processor()->process_discovered_references(
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   421
          &_is_alive_closure, &keep_alive, &evac_followers, &task_executor,
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 33105
diff changeset
   422
          &_gc_timer);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      } else {
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   424
        stats = reference_processor()->process_discovered_references(
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 33105
diff changeset
   425
          &_is_alive_closure, &keep_alive, &evac_followers, NULL, &_gc_timer);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   426
      }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   427
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   428
      _gc_tracer.report_gc_reference_stats(stats);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   429
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   430
      // Enqueue reference objects discovered during scavenge.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   431
      if (reference_processor()->processing_is_mt()) {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   432
        PSRefProcTaskExecutor task_executor;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   433
        reference_processor()->enqueue_discovered_references(&task_executor);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   434
      } else {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   435
        reference_processor()->enqueue_discovered_references(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
22205
8ee59199b85d 8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents: 21767
diff changeset
   439
    {
37146
209e0fe518bb 8152100: Rework and unify the GC phase logging
stefank
parents: 37045
diff changeset
   440
      GCTraceTime(Debug, gc, phases) tm("Scrub String Table", &_gc_timer);
22205
8ee59199b85d 8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents: 21767
diff changeset
   441
      // Unlink any dead interned Strings and process the remaining live ones.
8ee59199b85d 8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents: 21767
diff changeset
   442
      PSScavengeRootsClosure root_closure(promotion_manager);
8ee59199b85d 8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents: 21767
diff changeset
   443
      StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure);
8ee59199b85d 8027364: PSScavenge accounts too large code section to StringTable unlink
tschatzl
parents: 21767
diff changeset
   444
    }
8728
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 8688
diff changeset
   445
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    // Finally, flush the promotion_manager's labs, and deallocate its stacks.
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   447
    promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    if (promotion_failure_occurred) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      clean_up_failed_promotion();
38080
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37146
diff changeset
   450
      log_info(gc, promotion)("Promotion failed");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
33143
2083f82acec8 8139134: Wrong tenuring threshold in young GC trace event
ehelin
parents: 33107
diff changeset
   453
    _gc_tracer.report_tenuring_threshold(tenuring_threshold());
2083f82acec8 8139134: Wrong tenuring threshold in young GC trace event
ehelin
parents: 33107
diff changeset
   454
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    // Let the size policy know we're done.  Note that we count promotion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    // failure cleanup time as part of the collection (otherwise, we're
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    // implicitly saying it's mutator time).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    size_policy->minor_collection_end(gc_cause);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    if (!promotion_failure_occurred) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
      // Swap the survivor spaces.
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 360
diff changeset
   462
      young_gen->eden_space()->clear(SpaceDecorator::Mangle);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 360
diff changeset
   463
      young_gen->from_space()->clear(SpaceDecorator::Mangle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
      young_gen->swap_spaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      size_t survived = young_gen->from_space()->used_in_bytes();
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   467
      size_t promoted = old_gen->used_in_bytes() - pre_gc_values.old_gen_used();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
      size_policy->update_averages(_survivor_overflow, survived, promoted);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
5343
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   470
      // A successful scavenge should restart the GC time limit count which is
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   471
      // for full GC's.
95a5c4b89273 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 3908
diff changeset
   472
      size_policy->reset_gc_overhead_limit_count();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
      if (UseAdaptiveSizePolicy) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
        // Calculate the new survivor size and tenuring threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   476
        log_debug(gc, ergo)("AdaptiveSizeStart:  collection: %d ", heap->total_collections());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   477
        log_trace(gc, ergo)("old_gen_capacity: " SIZE_FORMAT " young_gen_capacity: " SIZE_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   478
                            old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
        if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
          PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
          counters->update_old_eden_size(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
            size_policy->calculated_eden_size_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
          counters->update_old_promo_size(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
            size_policy->calculated_promo_size_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
          counters->update_old_capacity(old_gen->capacity_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
          counters->update_young_capacity(young_gen->capacity_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
          counters->update_survived(survived);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
          counters->update_promoted(promoted);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
          counters->update_survivor_overflowed(_survivor_overflow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   493
        size_t max_young_size = young_gen->max_size();
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   494
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   495
        // Deciding a free ratio in the young generation is tricky, so if
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   496
        // MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   497
        // that the old generation size may have been limited because of them) we
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   498
        // should then limit our young generation size using NewRatio to have it
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   499
        // follow the old generation size.
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   500
        if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) {
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   501
          max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size());
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   502
        }
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   503
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
        size_t survivor_limit =
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   505
          size_policy->max_survivor_size(max_young_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
        _tenuring_threshold =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
          size_policy->compute_survivor_space_size_and_threshold(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
                                                           _survivor_overflow,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
                                                           _tenuring_threshold,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
                                                           survivor_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   512
       log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max threshold " UINTX_FORMAT ")",
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   513
                          size_policy->calculated_survivor_size_in_bytes(),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   514
                          _tenuring_threshold, MaxTenuringThreshold);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
          PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
          counters->update_tenuring_threshold(_tenuring_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
          counters->update_survivor_size_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        // Do call at minor collections?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
        // Don't check if the size_policy is ready at this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
        // level.  Let the size_policy check that internally.
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   525
        if (UseAdaptiveGenerationSizePolicyAtMinorCollection &&
31634
0aa645cd8cc3 7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents: 31330
diff changeset
   526
            (AdaptiveSizePolicy::should_update_eden_stats(gc_cause))) {
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22205
diff changeset
   527
          // Calculate optimal free space amounts
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
          assert(young_gen->max_size() >
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
            young_gen->from_space()->capacity_in_bytes() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
            young_gen->to_space()->capacity_in_bytes(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
            "Sizes of space in young gen are out-of-bounds");
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   532
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   533
          size_t young_live = young_gen->used_in_bytes();
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   534
          size_t eden_live = young_gen->eden_space()->used_in_bytes();
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   535
          size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   536
          size_t max_old_gen_size = old_gen->max_gen_size();
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 22551
diff changeset
   537
          size_t max_eden_size = max_young_size -
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
            young_gen->from_space()->capacity_in_bytes() -
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
            young_gen->to_space()->capacity_in_bytes();
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   540
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   541
          // Used for diagnostics
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   542
          size_policy->clear_generation_free_space_flags();
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   543
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   544
          size_policy->compute_eden_space_size(young_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   545
                                               eden_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   546
                                               cur_eden,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   547
                                               max_eden_size,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   548
                                               false /* not full gc*/);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
17393
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   550
          size_policy->check_gc_overhead_limit(young_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   551
                                               eden_live,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   552
                                               max_old_gen_size,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   553
                                               max_eden_size,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   554
                                               false /* not full gc*/,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   555
                                               gc_cause,
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   556
                                               heap->collector_policy());
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   557
7e99f263902c 8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents: 17112
diff changeset
   558
          size_policy->decay_supplemental_growth(false /* not full gc*/);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
        // Resize the young generation at every collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
        // even if new sizes have not been calculated.  This is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
        // to allow resizes that may have been inhibited by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
        // relative location of the "to" and "from" spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31634
diff changeset
   565
        // Resizing the old gen at young collections can cause increases
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
        // that don't feed back to the generation sizing policy until
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31634
diff changeset
   567
        // a full collection.  Don't resize the old gen here.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
                        size_policy->calculated_survivor_size_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   572
        log_debug(gc, ergo)("AdaptiveSizeStop: collection: %d ", heap->total_collections());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
      // Update the structure of the eden. With NUMA-eden CPU hotplugging or offlining can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
      // cause the change of the heap layout. Make sure eden is reshaped if that's the case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      // Also update() will case adaptive NUMA chunk resizing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
      assert(young_gen->eden_space()->is_empty(), "eden space should be empty now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      young_gen->eden_space()->update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      heap->gc_policy_counters()->update_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      heap->resize_all_tlabs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      assert(young_gen->to_space()->is_empty(), "to space should be empty now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   588
#if defined(COMPILER2) || INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   589
    DerivedPointerTable::update_pointers();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32623
diff changeset
   590
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    // Re-verify object start arrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    if (VerifyObjectStartArray &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
        VerifyAfterGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
      old_gen->verify_object_start_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    // Verify all old -> young cards are now precise
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    if (VerifyRememberedSets) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      // Precise verification will give false positives. Until this is fixed,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      // use imprecise verification.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      // CardTableExtension::verify_all_young_refs_precise();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
      CardTableExtension::verify_all_young_refs_imprecise();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
24941
4ebbe176a7b1 8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents: 24845
diff changeset
   608
    if (TraceYoungGenTime) accumulated_time()->stop();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   610
    young_gen->print_used_change(pre_gc_values.young_gen_used());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   611
    old_gen->print_used_change(pre_gc_values.old_gen_used());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   612
    MetaspaceAux::print_metaspace_change(pre_gc_values.metadata_used());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    // Track memory usage and detect low memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    MemoryService::track_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    heap->update_counters();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   617
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   618
    gc_task_manager()->release_idle_workers();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    HandleMark hm;  // Discard invalid handles created during verification
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   623
    Universe::verify("After GC");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11174
diff changeset
   626
  heap->print_heap_after_gc();
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   627
  heap->trace_heap_after_gc(&_gc_tracer);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  scavenge_exit.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   631
  log_debug(gc, task, time)("VM-Thread " JLONG_FORMAT " " JLONG_FORMAT " " JLONG_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   632
                            scavenge_entry.ticks(), scavenge_midpoint.ticks(),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   633
                            scavenge_exit.ticks());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   634
  gc_task_manager()->print_task_time_stamps();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
2010
c13462bbad17 6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents: 1610
diff changeset
   636
#ifdef TRACESPINNING
c13462bbad17 6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents: 1610
diff changeset
   637
  ParallelTaskTerminator::print_termination_counts();
c13462bbad17 6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents: 1610
diff changeset
   638
#endif
c13462bbad17 6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents: 1610
diff changeset
   639
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   640
  AdaptiveSizePolicyOutput::print(size_policy, heap->total_collections());
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   641
21767
41eaa9a17059 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 20317
diff changeset
   642
  _gc_timer.register_gc_end();
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   643
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   644
  _gc_tracer.report_gc_end(_gc_timer.gc_end(), _gc_timer.time_partitions());
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   645
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  return !promotion_failure_occurred;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
// This method iterates over all objects in the young generation,
37045
41e3f98fa3dc 8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents: 36591
diff changeset
   650
// removing all forwarding references. It then restores any preserved marks.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
void PSScavenge::clean_up_failed_promotion() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   652
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  PSYoungGen* young_gen = heap->young_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
37045
41e3f98fa3dc 8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents: 36591
diff changeset
   655
  RemoveForwardedPointerClosure remove_fwd_ptr_closure;
41e3f98fa3dc 8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents: 36591
diff changeset
   656
  young_gen->object_iterate(&remove_fwd_ptr_closure);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
37045
41e3f98fa3dc 8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents: 36591
diff changeset
   658
  PSPromotionManager::restore_preserved_marks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  // Reset the PromotionFailureALot counters.
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   661
  NOT_PRODUCT(heap->reset_promotion_should_fail();)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
bool PSScavenge::should_attempt_scavenge() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   665
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
    counters->update_scavenge_skipped(not_skipped);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  PSYoungGen* young_gen = heap->young_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  PSOldGen* old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
33227
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   675
  // Do not attempt to promote unless to_space is empty
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   676
  if (!young_gen->to_space()->is_empty()) {
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   677
    _consecutive_skipped_scavenges++;
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   678
    if (UsePerfData) {
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   679
      counters->update_scavenge_skipped(to_space_not_empty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    }
33227
b00ec45f8c2c 8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents: 33143
diff changeset
   681
    return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  // Test to see if the scavenge will likely fail.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  PSAdaptiveSizePolicy* policy = heap->size_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  // A similar test is done in the policy's should_full_GC().  If this is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  // changed, decide if that test should also be changed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  size_t avg_promoted = (size_t) policy->padded_average_promoted_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  size_t promotion_estimate = MIN2(avg_promoted, young_gen->used_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  bool result = promotion_estimate < old_gen->free_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   693
  log_trace(ergo)("%s scavenge: average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   694
                result ? "Do" : "Skip", (size_t) policy->average_promoted_in_bytes(),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   695
                (size_t) policy->padded_average_promoted_in_bytes(),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   696
                old_gen->free_in_bytes());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   697
  if (young_gen->used_in_bytes() < (size_t) policy->padded_average_promoted_in_bytes()) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33230
diff changeset
   698
    log_trace(ergo)(" padded_promoted_average is greater than maximum promotion = " SIZE_FORMAT, young_gen->used_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  if (result) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    _consecutive_skipped_scavenges = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    _consecutive_skipped_scavenges++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      counters->update_scavenge_skipped(promoted_too_large);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  // Used to add tasks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
GCTaskManager* const PSScavenge::gc_task_manager() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  assert(ParallelScavengeHeap::gc_task_manager() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
   "shouldn't return NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  return ParallelScavengeHeap::gc_task_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   719
// Adaptive size policy support.  When the young generation/old generation
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   720
// boundary moves, _young_generation_boundary must be reset
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   721
void PSScavenge::set_young_generation_boundary(HeapWord* v) {
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   722
  _young_generation_boundary = v;
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   723
  if (UseCompressedOops) {
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   724
    _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   725
  }
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   726
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35492
diff changeset
   727
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
void PSScavenge::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  // Arguments must have been parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
23506
9b98355e9060 6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents: 22555
diff changeset
   731
  if (AlwaysTenure || NeverTenure) {
9b98355e9060 6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents: 22555
diff changeset
   732
    assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   733
           "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is %d", (int) MaxTenuringThreshold);
23506
9b98355e9060 6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents: 22555
diff changeset
   734
    _tenuring_threshold = MaxTenuringThreshold;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    // We want to smooth out our startup times for the AdaptiveSizePolicy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
    _tenuring_threshold = (UseAdaptiveSizePolicy) ? InitialTenuringThreshold :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
                                                    MaxTenuringThreshold;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   741
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  PSYoungGen* young_gen = heap->young_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  PSOldGen* old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  // Set boundary between young_gen and old_gen
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
         "old above young");
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 17846
diff changeset
   748
  set_young_generation_boundary(young_gen->eden_space()->bottom());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  // Initialize ref handling object for scavenging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  MemRegion mr = young_gen->reserved();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10670
diff changeset
   752
8688
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7658
diff changeset
   753
  _ref_processor =
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7658
diff changeset
   754
    new ReferenceProcessor(mr,                         // span
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7658
diff changeset
   755
                           ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
31330
77061bb01b18 8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents: 31032
diff changeset
   756
                           ParallelGCThreads,          // mt processing degree
8688
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7658
diff changeset
   757
                           true,                       // mt discovery
31330
77061bb01b18 8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents: 31032
diff changeset
   758
                           ParallelGCThreads,          // mt discovery degree
8688
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7658
diff changeset
   759
                           true,                       // atomic_discovery
24845
e8b8894a77df 8043239: G1: Missing post barrier in processing of j.l.ref.Reference objects
brutisso
parents: 24429
diff changeset
   760
                           NULL);                      // header provides liveness info
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  // Cache the cardtable
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29208
diff changeset
   763
  _card_table = barrier_set_cast<CardTableExtension>(heap->barrier_set());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  _counters = new CollectorCounters("PSScavenge", 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
}