hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 f4b087cbb361
child 13728 882756847a04
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2007, 2010, 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: 3913
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3913
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: 3913
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: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/genOopClosures.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
/////////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Closures used by ConcurrentMarkSweepGeneration's collector
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
/////////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class ConcurrentMarkSweepGeneration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class CMSBitMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class CMSMarkStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class CMSCollector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class MarkFromRootsClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class Par_MarkFromRootsClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    40
// Decode the oop and call do_oop on it.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    41
#define DO_OOP_WORK_DEFN \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    42
  void do_oop(oop obj);                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    43
  template <class T> inline 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
    44
    T heap_oop = oopDesc::load_heap_oop(p);               \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    45
    if (!oopDesc::is_null(heap_oop)) {                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    46
      oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);       \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    47
      do_oop(obj);                                        \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
    }                                                     \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    50
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class MarkRefsIntoClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    52
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    53
  const MemRegion _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    54
  CMSBitMap*      _bitMap;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    55
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    56
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
 public:
3913
e049e6b81e11 6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents: 3912
diff changeset
    58
  MarkRefsIntoClosure(MemRegion span, CMSBitMap* bitMap);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    59
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    61
  inline void do_oop_nv(oop* p)       { MarkRefsIntoClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    62
  inline void do_oop_nv(narrowOop* p) { MarkRefsIntoClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  bool do_header() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// A variant of the above used in certain kinds of CMS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// marking verification.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class MarkRefsIntoVerifyClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    72
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    73
  const MemRegion _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    74
  CMSBitMap*      _verification_bm;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    75
  CMSBitMap*      _cms_bm;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    76
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    77
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  MarkRefsIntoVerifyClosure(MemRegion span, CMSBitMap* verification_bm,
3913
e049e6b81e11 6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents: 3912
diff changeset
    80
                            CMSBitMap* cms_bm);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    81
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    82
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    83
  inline void do_oop_nv(oop* p)       { MarkRefsIntoVerifyClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    84
  inline void do_oop_nv(narrowOop* p) { MarkRefsIntoVerifyClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  bool do_header() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    91
// KlassRememberingOopClosure is used when marking of the permanent generation
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    92
// is being done.  It adds fields to support revisiting of klasses
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    93
// for class unloading.  _should_remember_klasses should be set to
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    94
// indicate if klasses should be remembered.  Currently that is whenever
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    95
// CMS class unloading is turned on.  The _revisit_stack is used
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    96
// to save the klasses for later processing.
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    97
class KlassRememberingOopClosure : public OopClosure {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    98
 protected:
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
    99
  CMSCollector* _collector;
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   100
  CMSMarkStack* _revisit_stack;
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   101
  bool const    _should_remember_klasses;
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   102
 public:
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   103
  void check_remember_klasses() const PRODUCT_RETURN;
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   104
  virtual const bool should_remember_klasses() const {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   105
    check_remember_klasses();
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   106
    return _should_remember_klasses;
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   107
  }
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   108
  virtual void remember_klass(Klass* k);
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   109
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   110
  KlassRememberingOopClosure(CMSCollector* collector,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   111
                             ReferenceProcessor* rp,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   112
                             CMSMarkStack* revisit_stack);
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   113
};
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   114
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   115
// Similar to KlassRememberingOopClosure for use when multiple
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   116
// GC threads will execute the closure.
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   117
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   118
class Par_KlassRememberingOopClosure : public KlassRememberingOopClosure {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   119
 public:
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   120
  Par_KlassRememberingOopClosure(CMSCollector* collector,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   121
                                 ReferenceProcessor* rp,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   122
                                 CMSMarkStack* revisit_stack):
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   123
    KlassRememberingOopClosure(collector, rp, revisit_stack) {}
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   124
  virtual void remember_klass(Klass* k);
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   125
};
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   126
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
// The non-parallel version (the parallel version appears further below).
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   128
class PushAndMarkClosure: public KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   129
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   130
  MemRegion     _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
  CMSBitMap*    _bit_map;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
  CMSBitMap*    _mod_union_table;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   133
  CMSMarkStack* _mark_stack;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
  bool          _concurrent_precleaning;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   135
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   136
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  PushAndMarkClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
                     MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
                     ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
                     CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
                     CMSBitMap* mod_union_table,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   143
                     CMSMarkStack* mark_stack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   144
                     CMSMarkStack* revisit_stack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   145
                     bool concurrent_precleaning);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   146
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   147
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   148
  inline void do_oop_nv(oop* p)       { PushAndMarkClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   149
  inline void do_oop_nv(narrowOop* p) { PushAndMarkClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  bool do_header() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   154
  // In support of class unloading
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   155
  virtual const bool should_remember_mdo() const {
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   156
    return false;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   157
    // return _should_remember_klasses;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   158
  }
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   159
  virtual void remember_mdo(DataLayout* v);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// In the parallel case, the revisit stack, the bit map and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
// reference processor are currently all shared. Access to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
// these shared mutable structures must use appropriate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
// synchronization (for instance, via CAS). The marking stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
// used in the non-parallel case above is here replaced with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// an OopTaskQueue structure to allow efficient work stealing.
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   168
class Par_PushAndMarkClosure: public Par_KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   169
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   170
  MemRegion     _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   171
  CMSBitMap*    _bit_map;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   172
  OopTaskQueue* _work_queue;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   173
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   174
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  Par_PushAndMarkClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
                         MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
                         ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
                         CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
                         OopTaskQueue* work_queue,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
                         CMSMarkStack* revisit_stack);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   182
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   183
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   184
  inline void do_oop_nv(oop* p)       { Par_PushAndMarkClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   185
  inline void do_oop_nv(narrowOop* p) { Par_PushAndMarkClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  bool do_header() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  }
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   190
  // In support of class unloading
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   191
  virtual const bool should_remember_mdo() const {
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   192
    return false;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   193
    // return _should_remember_klasses;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   194
  }
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   195
  virtual void remember_mdo(DataLayout* v);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
// The non-parallel version (the parallel version appears further below).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
class MarkRefsIntoAndScanClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   200
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   201
  MemRegion          _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   202
  CMSBitMap*         _bit_map;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   203
  CMSMarkStack*      _mark_stack;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   204
  PushAndMarkClosure _pushAndMarkClosure;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   205
  CMSCollector*      _collector;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   206
  Mutex*             _freelistLock;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   207
  bool               _yield;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // Whether closure is being used for concurrent precleaning
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   209
  bool               _concurrent_precleaning;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   210
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   211
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  MarkRefsIntoAndScanClosure(MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
                             ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                             CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                             CMSBitMap* mod_union_table,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   217
                             CMSMarkStack* mark_stack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   218
                             CMSMarkStack* revisit_stack,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
                             CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                             bool should_yield,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                             bool concurrent_precleaning);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   222
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   223
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   224
  inline void do_oop_nv(oop* p)       { MarkRefsIntoAndScanClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   225
  inline void do_oop_nv(narrowOop* p) { MarkRefsIntoAndScanClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  bool do_header() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  void set_freelistLock(Mutex* m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    _freelistLock = m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  }
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   233
  virtual const bool should_remember_klasses() const {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   234
    return _pushAndMarkClosure.should_remember_klasses();
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   235
  }
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   236
  virtual void remember_klass(Klass* k) {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   237
    _pushAndMarkClosure.remember_klass(k);
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   238
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  bool take_from_overflow_list();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
// Tn this, the parallel avatar of MarkRefsIntoAndScanClosure, the revisit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
// stack and the bitMap are shared, so access needs to be suitably
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
// sycnhronized. An OopTaskQueue structure, supporting efficient
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
// workstealing, replaces a CMSMarkStack for storing grey objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
class Par_MarkRefsIntoAndScanClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   251
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   252
  MemRegion              _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   253
  CMSBitMap*             _bit_map;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   254
  OopTaskQueue*          _work_queue;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   255
  const uint             _low_water_mark;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   256
  Par_PushAndMarkClosure _par_pushAndMarkClosure;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   257
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   258
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  Par_MarkRefsIntoAndScanClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
                                 MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
                                 ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                                 CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
                                 OopTaskQueue* work_queue,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
                                 CMSMarkStack*  revisit_stack);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   266
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   267
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   268
  inline void do_oop_nv(oop* p)       { Par_MarkRefsIntoAndScanClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   269
  inline void do_oop_nv(narrowOop* p) { Par_MarkRefsIntoAndScanClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  bool do_header() { return true; }
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   271
  // When ScanMarkedObjectsAgainClosure is used,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   272
  // it passes [Par_]MarkRefsIntoAndScanClosure to oop_oop_iterate(),
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   273
  // and this delegation is used.
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   274
  virtual const bool should_remember_klasses() const {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   275
    return _par_pushAndMarkClosure.should_remember_klasses();
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   276
  }
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   277
  // See comment on should_remember_klasses() above.
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   278
  virtual void remember_klass(Klass* k) {
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   279
    _par_pushAndMarkClosure.remember_klass(k);
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   280
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    return Prefetch::do_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  void trim_queue(uint size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// This closure is used during the concurrent marking phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// following the first checkpoint. Its use is buried in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// the closure MarkFromRootsClosure.
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   290
class PushOrMarkClosure: public KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   291
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   292
  MemRegion       _span;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   293
  CMSBitMap*      _bitMap;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   294
  CMSMarkStack*   _markStack;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   295
  HeapWord* const _finger;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   296
  MarkFromRootsClosure* const
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   297
                  _parent;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   298
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   299
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  PushOrMarkClosure(CMSCollector* cms_collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
                    MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
                    CMSBitMap* bitMap,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   304
                    CMSMarkStack* markStack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   305
                    CMSMarkStack* revisitStack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   306
                    HeapWord* finger,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
                    MarkFromRootsClosure* parent);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   308
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   309
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   310
  inline void do_oop_nv(oop* p)       { PushOrMarkClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   311
  inline void do_oop_nv(narrowOop* p) { PushOrMarkClosure::do_oop_work(p); }
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   312
  // In support of class unloading
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   313
  virtual const bool should_remember_mdo() const {
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   314
    return false;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   315
    // return _should_remember_klasses;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   316
  }
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   317
  virtual void remember_mdo(DataLayout* v);
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   318
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // Deal with a stack overflow condition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  void handle_stack_overflow(HeapWord* lost);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// A parallel (MT) version of the above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// This closure is used during the concurrent marking phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
// following the first checkpoint. Its use is buried in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
// the closure Par_MarkFromRootsClosure.
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   329
class Par_PushOrMarkClosure: public Par_KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   330
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  MemRegion        _whole_span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  MemRegion        _span;        // local chunk
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  CMSBitMap*       _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  OopTaskQueue*    _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  CMSMarkStack*    _overflow_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  HeapWord*  const _finger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  HeapWord** const _global_finger_addr;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   338
  Par_MarkFromRootsClosure* const
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   339
                   _parent;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   340
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   341
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  Par_PushOrMarkClosure(CMSCollector* cms_collector,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   344
                        MemRegion span,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   345
                        CMSBitMap* bit_map,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   346
                        OopTaskQueue* work_queue,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   347
                        CMSMarkStack* mark_stack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   348
                        CMSMarkStack* revisit_stack,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   349
                        HeapWord* finger,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   350
                        HeapWord** global_finger_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   351
                        Par_MarkFromRootsClosure* parent);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   352
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   353
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   354
  inline void do_oop_nv(oop* p)       { Par_PushOrMarkClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   355
  inline void do_oop_nv(narrowOop* p) { Par_PushOrMarkClosure::do_oop_work(p); }
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   356
  // In support of class unloading
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   357
  virtual const bool should_remember_mdo() const {
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   358
    return false;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   359
    // return _should_remember_klasses;
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   360
  }
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   361
  virtual void remember_mdo(DataLayout* v);
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
   362
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  // Deal with a stack overflow condition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  void handle_stack_overflow(HeapWord* lost);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
// For objects in CMS generation, this closure marks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
// given objects (transitively) as being reachable/live.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
// This is currently used during the (weak) reference object
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   372
// processing phase of the CMS final checkpoint step, as
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   373
// well as during the concurrent precleaning of the discovered
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   374
// reference lists.
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   375
class CMSKeepAliveClosure: public KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   376
 private:
390
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   377
  const MemRegion _span;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  CMSMarkStack* _mark_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  CMSBitMap*    _bit_map;
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   380
  bool          _concurrent_precleaning;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   381
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   382
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  CMSKeepAliveClosure(CMSCollector* collector, MemRegion span,
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   385
                      CMSBitMap* bit_map, CMSMarkStack* mark_stack,
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   386
                      CMSMarkStack* revisit_stack, bool cpc);
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 390
diff changeset
   387
  bool    concurrent_precleaning() const { return _concurrent_precleaning; }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   388
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   389
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   390
  inline void do_oop_nv(oop* p)       { CMSKeepAliveClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   391
  inline void do_oop_nv(narrowOop* p) { CMSKeepAliveClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   394
class CMSInnerParMarkAndPushClosure: public Par_KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   395
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  MemRegion     _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  OopTaskQueue* _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  CMSBitMap*    _bit_map;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   399
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   400
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  CMSInnerParMarkAndPushClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
                                MemRegion span, CMSBitMap* bit_map,
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   404
                                CMSMarkStack* revisit_stack,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   405
                                OopTaskQueue* work_queue);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   406
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   407
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   408
  inline void do_oop_nv(oop* p)       { CMSInnerParMarkAndPushClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   409
  inline void do_oop_nv(narrowOop* p) { CMSInnerParMarkAndPushClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
// A parallel (MT) version of the above, used when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
// reference processing is parallel; the only difference
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
// is in the do_oop method.
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   415
class CMSParKeepAliveClosure: public Par_KlassRememberingOopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   416
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  MemRegion     _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  OopTaskQueue* _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  CMSBitMap*    _bit_map;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   420
  CMSInnerParMarkAndPushClosure
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   421
                _mark_and_push;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  const uint    _low_water_mark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  void trim_queue(uint max);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   424
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   425
  DO_OOP_WORK_DEFN
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  CMSParKeepAliveClosure(CMSCollector* collector, MemRegion span,
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   428
                         CMSBitMap* bit_map, CMSMarkStack* revisit_stack,
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1605
diff changeset
   429
                         OopTaskQueue* work_queue);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   430
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   431
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   432
  inline void do_oop_nv(oop* p)       { CMSParKeepAliveClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   433
  inline void do_oop_nv(narrowOop* p) { CMSParKeepAliveClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   435
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   436
#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP