src/hotspot/share/gc/parallel/psScavenge.inline.hpp
author sangheki
Mon, 04 Jun 2018 21:20:16 -0700
changeset 50396 7f48bff40a9a
parent 49722 a47d1e21b3f1
child 50728 9375184cec98
permissions -rw-r--r--
8204094: assert(worker_i < _length) failed: Worker 15 is greater than max: 11 at ReferenceProcessorPhaseTimes Reviewed-by: kbarrett, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47580
diff changeset
     2
 * Copyright (c) 2002, 2018, 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: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
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: 670
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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    28
#include "gc/parallel/parallelScavengeHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    29
#include "gc/parallel/psPromotionManager.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    30
#include "gc/parallel/psScavenge.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34174
diff changeset
    31
#include "logging/log.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    32
#include "memory/iterator.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 35061
diff changeset
    33
#include "memory/resourceArea.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    34
#include "oops/access.inline.hpp"
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49592
diff changeset
    35
#include "oops/oop.inline.hpp"
24098
48f07e2c74de 8039957: Replace the last few %p usages with PTR_FORMAT in the GC code
stefank
parents: 20282
diff changeset
    36
#include "utilities/globalDefinitions.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    37
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
inline void PSScavenge::save_to_space_top_before_gc() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29208
diff changeset
    39
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  _to_space_top_before_gc = heap->young_gen()->to_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    43
template <class T> inline bool PSScavenge::should_scavenge(T* p) {
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    44
  T heap_oop = RawAccess<>::oop_load(p);
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13728
diff changeset
    45
  return PSScavenge::is_obj_in_young(heap_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  if (should_scavenge(p)) {
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    51
    oop obj = RawAccess<OOP_NOT_NULL>::oop_load(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    // Skip objects copied to to_space since the scavenge started.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    53
    HeapWord* const addr = (HeapWord*)obj;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    return addr < to_space_top_before_gc() || addr >= to_space->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    59
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  if (check_to_space) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29208
diff changeset
    62
    ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    return should_scavenge(p, heap->young_gen()->to_space());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  return should_scavenge(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    68
template<bool promote_immediately>
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    69
class PSRootsClosure: public OopClosure {
8728
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    70
 private:
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    71
  PSPromotionManager* _promotion_manager;
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    72
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    73
 protected:
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    74
  template <class T> void do_oop_work(T *p) {
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    75
    if (PSScavenge::should_scavenge(p)) {
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    76
      // We never card mark roots, maybe call a func without test?
29208
b570d043f295 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents: 24424
diff changeset
    77
      _promotion_manager->copy_and_push_safe_barrier<T, promote_immediately>(p);
8728
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    78
    }
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    79
  }
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    80
 public:
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    81
  PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    82
  void do_oop(oop* p)       { PSRootsClosure::do_oop_work(p); }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    83
  void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); }
8728
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    84
};
3f1bcd33068e 6962931: move interned strings out of the perm gen
jcoomes
parents: 7397
diff changeset
    85
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    86
typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    87
typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 8921
diff changeset
    88
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    89
// Scavenges a single oop in a ClassLoaderData.
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    90
class PSScavengeFromCLDClosure: public OopClosure {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    91
 private:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    92
  PSPromotionManager* _pm;
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    93
  // Used to redirty a scanned cld if it has oops
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    94
  // pointing to the young generation after being scanned.
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    95
  ClassLoaderData*    _scanned_cld;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    96
 public:
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    97
  PSScavengeFromCLDClosure(PSPromotionManager* pm) : _pm(pm), _scanned_cld(NULL) { }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    98
  void do_oop(narrowOop* p) { ShouldNotReachHere(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    99
  void do_oop(oop* p)       {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   100
    ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   101
    assert(!psh->is_in_reserved(p), "GC barrier needed");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   102
    if (PSScavenge::should_scavenge(p)) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   103
      assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   104
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   105
      oop o = *p;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   106
      oop new_obj;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   107
      if (o->is_forwarded()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   108
        new_obj = o->forwardee();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   109
      } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   110
        new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   111
      }
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
   112
      RawAccess<OOP_NOT_NULL>::oop_store(p, new_obj);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   113
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13728
diff changeset
   114
      if (PSScavenge::is_obj_in_young(new_obj)) {
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   115
        do_cld_barrier();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   116
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   117
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   118
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   119
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   120
  void set_scanned_cld(ClassLoaderData* cld) {
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   121
    assert(_scanned_cld == NULL || cld == NULL, "Should always only handling one cld at a time");
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   122
    _scanned_cld = cld;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   123
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   124
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   125
 private:
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   126
  void do_cld_barrier() {
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   127
    assert(_scanned_cld != NULL, "Should not be called without having a scanned cld");
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   128
    _scanned_cld->record_modified_oops();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   129
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   130
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   131
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   132
// Scavenges the oop in a ClassLoaderData.
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   133
class PSScavengeCLDClosure: public CLDClosure {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   134
 private:
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   135
  PSScavengeFromCLDClosure _oop_closure;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   136
 protected:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   137
 public:
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   138
  PSScavengeCLDClosure(PSPromotionManager* pm) : _oop_closure(pm) { }
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   139
  void do_cld(ClassLoaderData* cld) {
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   140
    // If the cld has not been dirtied we know that there's
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   141
    // no references into  the young gen and we can skip it.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   142
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   143
    if (cld->has_modified_oops()) {
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   144
      // Setup the promotion manager to redirty this cld
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   145
      // if references are left in the young gen.
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   146
      _oop_closure.set_scanned_cld(cld);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   147
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   148
      // Clean the cld since we're going to scavenge all the metadata.
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   149
      cld->oops_do(&_oop_closure, false, /*clear_modified_oops*/true);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   150
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   151
      _oop_closure.set_scanned_cld(NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   152
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   153
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   154
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
   155
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   156
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
   157
#endif // SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP