hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp
author tschatzl
Thu, 28 Jan 2016 13:30:12 +0100
changeset 35877 a2a62511d0f8
parent 35061 be6025ebffea
child 35901 f5028c67e7cb
permissions -rw-r--r--
8146987: Improve Parallel GC Full GC by caching results of live_words_in_range() Summary: A large part of time in the parallel scavenge collector is spent finding out the amount of live words within memory ranges to find out where to move an object to. Try to incrementally calculate this value. Reviewed-by: tschatzl, mgerdin, jmasa Contributed-by: ray alex <sky1young@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
29702
9ed339a5e096 8075809: Add missing includes of stack.inline.hpp
stefank
parents: 29208
diff changeset
     2
 * Copyright (c) 2002, 2015, 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: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
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: 2105
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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    26
#include "gc/parallel/mutableSpace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    27
#include "gc/parallel/parallelScavengeHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    28
#include "gc/parallel/psOldGen.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    29
#include "gc/parallel/psPromotionManager.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    30
#include "gc/parallel/psScavenge.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    31
#include "gc/shared/gcTrace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    32
#include "gc/shared/taskqueue.inline.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
    33
#include "logging/log.hpp"
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    34
#include "memory/allocation.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    35
#include "memory/memRegion.hpp"
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    36
#include "memory/padded.inline.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
    37
#include "oops/instanceKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
    38
#include "oops/instanceMirrorKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
    39
#include "oops/objArrayKlass.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    40
#include "oops/oop.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    42
PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    43
OopStarTaskQueueSet*           PSPromotionManager::_stack_array_depth = NULL;
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    44
PSOldGen*                      PSPromotionManager::_old_gen = NULL;
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    45
MutableSpace*                  PSPromotionManager::_young_space = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
void PSPromotionManager::initialize() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
    48
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  _old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  _young_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    53
  // To prevent false sharing, we pad the PSPromotionManagers
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    54
  // and make sure that the first instance starts at a cache line.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  assert(_manager_array == NULL, "Attempt to initialize twice");
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    56
  _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(ParallelGCThreads + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  guarantee(_manager_array != NULL, "Could not initialize promotion manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
    59
  _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
    60
  guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // Create and register the PSPromotionManager(s) for the worker threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  for(uint i=0; i<ParallelGCThreads; i++) {
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    64
    stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // The VMThread gets its own PSPromotionManager, which is not available
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // for work stealing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
29208
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    70
// Helper functions to get around the circular dependency between
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    71
// psScavenge.inline.hpp and psPromotionManager.inline.hpp.
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    72
bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) {
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    73
  return PSScavenge::should_scavenge(p, check_to_space);
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    74
}
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    75
bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) {
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    76
  return PSScavenge::should_scavenge(p, check_to_space);
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    77
}
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 27154
diff changeset
    78
31330
77061bb01b18 8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents: 30764
diff changeset
    79
PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) {
77061bb01b18 8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents: 30764
diff changeset
    80
  assert(index < ParallelGCThreads, "index out of range");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  assert(_manager_array != NULL, "Sanity");
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    82
  return &_manager_array[index];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  assert(_manager_array != NULL, "Sanity");
19285
0a3b3f115402 8022880: False sharing between PSPromotionManager instances
stefank
parents: 18025
diff changeset
    87
  return &_manager_array[ParallelGCThreads];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
void PSPromotionManager::pre_scavenge() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
    91
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  _young_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  for(uint i=0; i<ParallelGCThreads+1; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    manager_array(i)->reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   100
bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   101
  bool promotion_failure_occurred = false;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   102
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   103
  TASKQUEUE_STATS_ONLY(print_taskqueue_stats());
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   104
  for (uint i = 0; i < ParallelGCThreads + 1; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    PSPromotionManager* manager = manager_array(i);
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   106
    assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   107
    if (manager->_promotion_failed_info.has_failed()) {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   108
      gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   109
      promotion_failure_occurred = true;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   110
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    manager->flush_labs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   113
  return promotion_failure_occurred;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   116
#if TASKQUEUE_STATS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
void
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   118
PSPromotionManager::print_local_stats(outputStream* const out, uint i) const {
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   119
  #define FMT " " SIZE_FORMAT_W(10)
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   120
  out->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals,
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   121
                _arrays_chunked, _array_chunks_processed);
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   122
  #undef FMT
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   123
}
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   124
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   125
static const char* const pm_stats_hdr[] = {
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   126
  "    --------masked-------     arrays      array",
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   127
  "thr       push      steal    chunked     chunks",
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   128
  "--- ---------- ---------- ---------- ----------"
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   129
};
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   130
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   131
void
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   132
PSPromotionManager::print_taskqueue_stats() {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   133
  if (!develop_log_is_enabled(Trace, gc, task, stats)) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   134
    return;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   135
  }
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   136
  LogHandle(gc, task, stats) log;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   137
  ResourceMark rm;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   138
  outputStream* out = log.trace_stream();
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   139
  out->print_cr("== GC Tasks Stats, GC %3d",
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   140
                ParallelScavengeHeap::heap()->total_collections());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   142
  TaskQueueStats totals;
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   143
  out->print("thr "); TaskQueueStats::print_header(1, out); out->cr();
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   144
  out->print("--- "); TaskQueueStats::print_header(2, out); out->cr();
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   145
  for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   146
    TaskQueueStats& next = manager_array(i)->_claimed_stack_depth.stats;
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   147
    out->print("%3d ", i); next.print(out); out->cr();
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   148
    totals += next;
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   149
  }
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   150
  out->print("tot "); totals.print(out); out->cr();
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   151
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   152
  const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]);
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   153
  for (uint i = 0; i < hlines; ++i) out->print_cr("%s", pm_stats_hdr[i]);
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   154
  for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
27154
ccf8883e01be 8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents: 24424
diff changeset
   155
    manager_array(i)->print_local_stats(out, i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   159
void
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   160
PSPromotionManager::reset_stats() {
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   161
  claimed_stack_depth()->stats.reset();
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   162
  _masked_pushes = _masked_steals = 0;
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   163
  _arrays_chunked = _array_chunks_processed = 0;
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   164
}
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   165
#endif // TASKQUEUE_STATS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
PSPromotionManager::PSPromotionManager() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   168
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // We set the old lab's start array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  _old_lab.set_start_array(old_gen()->start_array());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  uint queue_size;
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   174
  claimed_stack_depth()->initialize();
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   175
  queue_size = claimed_stack_depth()->max_elems();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  _totally_drain = (ParallelGCThreads == 1) || (GCDrainStackTargetSize == 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  if (_totally_drain) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    _target_stack_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    // don't let the target stack size to be more than 1/4 of the entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    _target_stack_size = (uint) MIN2((uint) GCDrainStackTargetSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
                                     (uint) (queue_size / 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  _array_chunk_size = ParGCArrayScanChunk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // let's choose 1.5x the chunk size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  _min_array_size_for_chunking = 3 * _array_chunk_size / 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
void PSPromotionManager::reset() {
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   194
  assert(stacks_empty(), "reset of non-empty stack");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // We need to get an assert in here to make sure the labs are always flushed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   198
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // Do not prefill the LAB's, save heap wastage!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  HeapWord* lab_base = young_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  _young_lab.initialize(MemRegion(lab_base, (size_t)0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  _young_gen_is_full = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  lab_base = old_gen()->object_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  _old_lab.initialize(MemRegion(lab_base, (size_t)0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  _old_gen_is_full = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   209
  _promotion_failed_info.reset();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   210
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   211
  TASKQUEUE_STATS_ONLY(reset_stats());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   214
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  totally_drain = totally_drain || _totally_drain;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
#ifdef ASSERT
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   219
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  MutableSpace* to_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  MutableSpace* old_space = heap->old_gen()->object_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   224
  OopStarTaskQueue* const tq = claimed_stack_depth();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  do {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   226
    StarTask p;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    // Drain overflow stack first, so other threads can steal from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    // claimed stack while we work.
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   230
    while (tq->pop_overflow(p)) {
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   231
      process_popped_location_depth(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    if (totally_drain) {
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   235
      while (tq->pop_local(p)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        process_popped_location_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    } else {
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   239
      while (tq->size() > _target_stack_size && tq->pop_local(p)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        process_popped_location_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    }
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   243
  } while (totally_drain && !tq->taskqueue_empty() || !tq->overflow_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   245
  assert(!totally_drain || tq->taskqueue_empty(), "Sanity");
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   246
  assert(totally_drain || tq->size() <= _target_stack_size, "Sanity");
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   247
  assert(tq->overflow_empty(), "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
void PSPromotionManager::flush_labs() {
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   251
  assert(stacks_empty(), "Attempt to flush lab with live stack");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // If either promotion lab fills up, we can flush the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // lab but not refill it, so check first.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  assert(!_young_lab.is_flushed() || _young_gen_is_full, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  if (!_young_lab.is_flushed())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    _young_lab.flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  if (!_old_lab.is_flushed())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    _old_lab.flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // Let PSScavenge know if we overflowed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  if (_young_gen_is_full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    PSScavenge::set_survivor_overflow(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   269
template <class T> void PSPromotionManager::process_array_chunk_work(
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   270
                                                 oop obj,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   271
                                                 int start, int end) {
8685
f8edcc58cca7 6820066: Check that -XX:ParGCArrayScanChunk has a value larger than zero.
jwilhelm
parents: 7397
diff changeset
   272
  assert(start <= end, "invariant");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   273
  T* const base      = (T*)objArrayOop(obj)->base();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   274
  T* p               = base + start;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   275
  T* const chunk_end = base + end;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   276
  while (p < chunk_end) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   277
    if (PSScavenge::should_scavenge(p)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   278
      claim_or_forward_depth(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   279
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   280
    ++p;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   281
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   282
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   283
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
void PSPromotionManager::process_array_chunk(oop old) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  assert(PSChunkLargeArrays, "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  assert(old->is_objArray(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  assert(old->is_forwarded(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   289
  TASKQUEUE_STATS_ONLY(++_array_chunks_processed);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  oop const obj = old->forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  int start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  int const end = arrayOop(old)->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  if (end > (int) _min_array_size_for_chunking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    // we'll chunk more
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    start = end - _array_chunk_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    assert(start > 0, "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    arrayOop(old)->set_length(start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    push_depth(mask_chunked_array_oop(old));
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5918
diff changeset
   301
    TASKQUEUE_STATS_ONLY(++_masked_pushes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    // this is the final chunk for this array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    start = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    int const actual_length = arrayOop(obj)->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    arrayOop(old)->set_length(actual_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   309
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   310
    process_array_chunk_work<narrowOop>(obj, start, end);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   311
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   312
    process_array_chunk_work<oop>(obj, start, end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   316
class PushContentsClosure : public ExtendedOopClosure {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   317
  PSPromotionManager* _pm;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   318
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   319
  PushContentsClosure(PSPromotionManager* pm) : _pm(pm) {}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   320
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   321
  template <typename T> void do_oop_nv(T* p) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   322
    if (PSScavenge::should_scavenge(p)) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   323
      _pm->claim_or_forward_depth(p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   324
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   325
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   326
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   327
  virtual void do_oop(oop* p)       { do_oop_nv(p); }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   328
  virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   329
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   330
  // Don't use the oop verification code in the oop_oop_iterate framework.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   331
  debug_only(virtual bool should_verify_oops() { return false; })
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   332
};
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   333
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   334
void InstanceKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   335
  PushContentsClosure cl(pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   336
  oop_oop_iterate_oop_maps_reverse<true>(obj, &cl);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   337
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   338
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   339
void InstanceMirrorKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   340
    // Note that we don't have to follow the mirror -> klass pointer, since all
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   341
    // klasses that are dirty will be scavenged when we iterate over the
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   342
    // ClassLoaderData objects.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   343
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   344
  InstanceKlass::oop_ps_push_contents(obj, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   345
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   346
  PushContentsClosure cl(pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   347
  oop_oop_iterate_statics<true>(obj, &cl);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   348
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   349
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   350
void InstanceClassLoaderKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   351
  InstanceKlass::oop_ps_push_contents(obj, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   352
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   353
  // This is called by the young collector. It will already have taken care of
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   354
  // all class loader data. So, we don't have to follow the class loader ->
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   355
  // class loader data link.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   356
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   357
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   358
template <class T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   359
static void oop_ps_push_contents_specialized(oop obj, InstanceRefKlass *klass, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   360
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   361
  if (PSScavenge::should_scavenge(referent_addr)) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   362
    ReferenceProcessor* rp = PSScavenge::reference_processor();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   363
    if (rp->discover_reference(obj, klass->reference_type())) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   364
      // reference already enqueued, referent and next will be traversed later
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   365
      klass->InstanceKlass::oop_ps_push_contents(obj, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   366
      return;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   367
    } else {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   368
      // treat referent as normal oop
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   369
      pm->claim_or_forward_depth(referent_addr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   370
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   371
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   372
  // Treat discovered as normal oop, if ref is not "active",
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   373
  // i.e. if next is non-NULL.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   374
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
30558
baec90a2699f 8031401: Remove unused code in the reference processor
kbarrett
parents: 30173
diff changeset
   375
  T  next_oop = oopDesc::load_heap_oop(next_addr);
baec90a2699f 8031401: Remove unused code in the reference processor
kbarrett
parents: 30173
diff changeset
   376
  if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
baec90a2699f 8031401: Remove unused code in the reference processor
kbarrett
parents: 30173
diff changeset
   377
    T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   378
    log_develop_trace(gc, ref)("   Process discovered as normal " PTR_FORMAT, p2i(discovered_addr));
30558
baec90a2699f 8031401: Remove unused code in the reference processor
kbarrett
parents: 30173
diff changeset
   379
    if (PSScavenge::should_scavenge(discovered_addr)) {
baec90a2699f 8031401: Remove unused code in the reference processor
kbarrett
parents: 30173
diff changeset
   380
      pm->claim_or_forward_depth(discovered_addr);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   381
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   382
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   383
  // Treat next as normal oop;  next is a link in the reference queue.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   384
  if (PSScavenge::should_scavenge(next_addr)) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   385
    pm->claim_or_forward_depth(next_addr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   386
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   387
  klass->InstanceKlass::oop_ps_push_contents(obj, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   388
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   389
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   390
void InstanceRefKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   391
  if (UseCompressedOops) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   392
    oop_ps_push_contents_specialized<narrowOop>(obj, this, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   393
  } else {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   394
    oop_ps_push_contents_specialized<oop>(obj, this, pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   395
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   396
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   397
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   398
void ObjArrayKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   399
  assert(obj->is_objArray(), "obj must be obj array");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   400
  PushContentsClosure cl(pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   401
  oop_oop_iterate_elements<true>(objArrayOop(obj), &cl);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   402
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   403
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   404
void TypeArrayKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   405
  assert(obj->is_typeArray(),"must be a type array");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   406
  ShouldNotReachHere();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   407
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
   408
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // Attempt to CAS in the header.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // This tests if the header is still the same as when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // this started.  If it is the same (i.e., no forwarding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // pointer has been installed), then this thread owns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  if (obj->cas_forward_to(obj, obj_mark)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    // We won any races, we "own" this object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    assert(obj == obj->forwardee(), "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   421
    _promotion_failed_info.register_copy_failure(obj->size());
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13728
diff changeset
   422
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29702
diff changeset
   423
    push_contents(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    // Save the mark if needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    PSScavenge::oop_promotion_failed(obj, obj_mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  }  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    // We lost, someone else "owns" this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    // No unallocation to worry about.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    obj = obj->forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
   435
  log_develop_trace(gc, scavenge)("{promotion-failure %s " PTR_FORMAT " (%d)}", obj->klass()->internal_name(), p2i(obj), obj->size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
}