hotspot/src/share/vm/memory/iterator.hpp
author sjohanss
Tue, 09 May 2017 11:03:45 +0200
changeset 46445 825b002e05ae
parent 46415 7d5a286cdf89
permissions -rw-r--r--
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field Reviewed-by: kbarrett, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
     2
 * Copyright (c) 1997, 2017, 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: 4738
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4738
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: 4738
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_MEMORY_ITERATOR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_MEMORY_ITERATOR_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/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/memRegion.hpp"
37466
287c4ebd11b0 8153967: Remove top.hpp
stefank
parents: 37106
diff changeset
    30
#include "oops/oopsHierarchy.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
    32
class CodeBlob;
3913
e049e6b81e11 6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents: 3912
diff changeset
    33
class nmethod;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class ReferenceProcessor;
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
    35
class DataLayout;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    36
class KlassClosure;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    37
class ClassLoaderData;
37466
287c4ebd11b0 8153967: Remove top.hpp
stefank
parents: 37106
diff changeset
    38
class Symbol;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
23538
2518569e1e01 8038628: Remove unused Closure::abort()
stefank
parents: 23535
diff changeset
    40
// The following classes are C++ `closures` for iterating over objects, roots and spaces
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
    41
23538
2518569e1e01 8038628: Remove unused Closure::abort()
stefank
parents: 23535
diff changeset
    42
class Closure : public StackObj { };
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
    43
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    44
// OopClosure is used for iterating through references to Java objects.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
    45
class OopClosure : public Closure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  virtual void do_oop(oop* o) = 0;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
  virtual void do_oop(narrowOop* o) = 0;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    49
};
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1388
diff changeset
    50
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    51
// ExtendedOopClosure adds extra code to be run during oop iterations.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    52
// This is needed by the GC and is extracted to a separate type to not
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    53
// pollute the OopClosure interface.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    54
class ExtendedOopClosure : public OopClosure {
33226
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    55
 private:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    56
  ReferenceProcessor* _ref_processor;
33226
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    57
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    58
 protected:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    59
  ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
33226
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    60
  ExtendedOopClosure() : _ref_processor(NULL) { }
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    61
  ~ExtendedOopClosure() { }
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    62
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    63
  void set_ref_processor_internal(ReferenceProcessor* rp) { _ref_processor = rp; }
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    64
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    65
 public:
19cb9b844190 8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents: 32606
diff changeset
    66
  ReferenceProcessor* ref_processor() const { return _ref_processor; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    68
  // Iteration of InstanceRefKlasses differ depending on the closure,
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    69
  // the below enum describes the different alternatives.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    70
  enum ReferenceIterationMode {
46445
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
    71
    DO_DISCOVERY,                // Apply closure and discover references
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
    72
    DO_DISCOVERED_AND_DISCOVERY, // Apply closure to discovered field and do discovery
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
    73
    DO_FIELDS                    // Apply closure to all fields
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    74
  };
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    75
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    76
  // The default iteration mode is to do discovery.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    77
  virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERY; }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 37995
diff changeset
    78
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    79
  // If the do_metadata functions return "true",
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    80
  // we invoke the following when running oop_iterate():
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    81
  //
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    82
  // 1) do_klass on the header klass pointer.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    83
  // 2) do_klass on the klass pointer in the mirrors.
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    84
  // 3) do_cld   on the class loader data in class loaders.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    85
  //
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    86
  // The virtual (without suffix) and the non-virtual (with _nv suffix) need
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    87
  // to be updated together, or else the devirtualization will break.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    88
  //
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    89
  // Providing default implementations of the _nv functions unfortunately
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    90
  // removes the compile-time safeness, but reduces the clutter for the
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    91
  // ExtendedOopClosures that don't need to walk the metadata.
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    92
  // Currently, only CMS and G1 need these.
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 3690
diff changeset
    93
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    94
  bool do_metadata_nv()      { return false; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    95
  virtual bool do_metadata() { return do_metadata_nv(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    97
  void do_klass_nv(Klass* k)      { ShouldNotReachHere(); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    98
  virtual void do_klass(Klass* k) { do_klass_nv(k); }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    99
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   100
  void do_cld_nv(ClassLoaderData* cld)      { ShouldNotReachHere(); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   101
  virtual void do_cld(ClassLoaderData* cld) { do_cld_nv(cld); }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   102
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   103
  // True iff this closure may be safely applied more than once to an oop
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   104
  // location without an intervening "major reset" (like the end of a GC).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   105
  virtual bool idempotent() { return false; }
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   106
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   107
#ifdef ASSERT
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   108
  // Default verification of each visited oop field.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   109
  template <typename T> void verify(T* p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   110
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   111
  // Can be used by subclasses to turn off the default verification of oop fields.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   112
  virtual bool should_verify_oops() { return true; }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   113
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   114
};
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1388
diff changeset
   115
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   116
// Wrapper closure only used to implement oop_iterate_no_header().
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   117
class NoHeaderExtendedOopClosure : public ExtendedOopClosure {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   118
  OopClosure* _wrapped_closure;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   119
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   120
  NoHeaderExtendedOopClosure(OopClosure* cl) : _wrapped_closure(cl) {}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   121
  // Warning: this calls the virtual version do_oop in the the wrapped closure.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   122
  void do_oop_nv(oop* p)       { _wrapped_closure->do_oop(p); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   123
  void do_oop_nv(narrowOop* p) { _wrapped_closure->do_oop(p); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   124
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   125
  void do_oop(oop* p)          { assert(false, "Only the _nv versions should be used");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   126
                                 _wrapped_closure->do_oop(p); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   127
  void do_oop(narrowOop* p)    { assert(false, "Only the _nv versions should be used");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   128
                                 _wrapped_closure->do_oop(p);}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   129
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   130
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   131
class KlassClosure : public Closure {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   132
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   133
  virtual void do_klass(Klass* k) = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
22899
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   136
class CLDClosure : public Closure {
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   137
 public:
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   138
  virtual void do_cld(ClassLoaderData* cld) = 0;
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   139
};
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   140
13741
e4395deb8597 7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents: 13728
diff changeset
   141
class KlassToOopClosure : public KlassClosure {
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   142
  friend class MetadataAwareOopClosure;
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   143
  friend class MetadataAwareOopsInGenClosure;
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   144
13741
e4395deb8597 7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents: 13728
diff changeset
   145
  OopClosure* _oop_closure;
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   146
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   147
  // Used when _oop_closure couldn't be set in an initialization list.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   148
  void initialize(OopClosure* oop_closure) {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   149
    assert(_oop_closure == NULL, "Should only be called once");
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   150
    _oop_closure = oop_closure;
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   151
  }
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   152
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   153
 public:
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   154
  KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   155
13741
e4395deb8597 7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents: 13728
diff changeset
   156
  virtual void do_klass(Klass* k);
e4395deb8597 7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents: 13728
diff changeset
   157
};
e4395deb8597 7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents: 13728
diff changeset
   158
22899
e2a6bf7f343a 8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents: 22234
diff changeset
   159
class CLDToOopClosure : public CLDClosure {
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   160
  OopClosure*       _oop_closure;
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   161
  KlassToOopClosure _klass_closure;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   162
  bool              _must_claim_cld;
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   163
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   164
 public:
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   165
  CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) :
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   166
      _oop_closure(oop_closure),
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   167
      _klass_closure(oop_closure),
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   168
      _must_claim_cld(must_claim_cld) {}
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   169
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   170
  void do_cld(ClassLoaderData* cld);
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   171
};
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13741
diff changeset
   172
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   173
class CLDToKlassAndOopClosure : public CLDClosure {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   174
  friend class G1CollectedHeap;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   175
 protected:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   176
  OopClosure*   _oop_closure;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   177
  KlassClosure* _klass_closure;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   178
  bool          _must_claim_cld;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   179
 public:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   180
  CLDToKlassAndOopClosure(KlassClosure* klass_closure,
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   181
                          OopClosure* oop_closure,
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   182
                          bool must_claim_cld) :
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   183
                              _oop_closure(oop_closure),
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   184
                              _klass_closure(klass_closure),
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   185
                              _must_claim_cld(must_claim_cld) {}
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   186
  void do_cld(ClassLoaderData* cld);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   187
};
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   188
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   189
// The base class for all concurrent marking closures,
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   190
// that participates in class unloading.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   191
// It's used to proxy through the metadata to the oops defined in them.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   192
class MetadataAwareOopClosure: public ExtendedOopClosure {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   193
  KlassToOopClosure _klass_closure;
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   194
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   195
 public:
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   196
  MetadataAwareOopClosure() : ExtendedOopClosure() {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   197
    _klass_closure.initialize(this);
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   198
  }
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   199
  MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   200
    _klass_closure.initialize(this);
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   201
  }
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   202
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   203
  bool do_metadata_nv()      { return true; }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   204
  virtual bool do_metadata() { return do_metadata_nv(); }
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   205
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   206
  void do_klass_nv(Klass* k);
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   207
  virtual void do_klass(Klass* k) { do_klass_nv(k); }
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   208
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   209
  void do_cld_nv(ClassLoaderData* cld);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   210
  virtual void do_cld(ClassLoaderData* cld) { do_cld_nv(cld); }
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   211
};
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   212
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// ObjectClosure is used for iterating through an object space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   215
class ObjectClosure : public Closure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // Called for each object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  virtual void do_object(oop obj) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
17625
3e91c67ddece 8014277: Remove ObjectClosure as base class for BoolObjectClosure
ehelin
parents: 14582
diff changeset
   222
class BoolObjectClosure : public Closure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  virtual bool do_object_b(oop obj) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
37106
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   227
class AlwaysTrueClosure: public BoolObjectClosure {
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   228
 public:
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   229
  bool do_object_b(oop p) { return true; }
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   230
};
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   231
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   232
class AlwaysFalseClosure : public BoolObjectClosure {
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   233
 public:
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   234
  bool do_object_b(oop p) { return false; }
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   235
};
0856b64af754 8151539: Remove duplicate AlwaysTrueClosures
stefank
parents: 36591
diff changeset
   236
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
// Applies an oop closure to all ref fields in objects iterated over in an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
// object iteration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
class ObjectToOopClosure: public ObjectClosure {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   240
  ExtendedOopClosure* _cl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  void do_object(oop obj);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   243
  ObjectToOopClosure(ExtendedOopClosure* cl) : _cl(cl) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
// A version of ObjectClosure that is expected to be robust
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
// in the face of possibly uninitialized objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
class ObjectClosureCareful : public ObjectClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  virtual size_t do_object_careful(oop p) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// The following are used in CompactibleFreeListSpace and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// ConcurrentMarkSweepGeneration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// Blk closure (abstract class)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
class BlkClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  virtual size_t do_blk(HeapWord* addr) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// A version of BlkClosure that is expected to be robust
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
// in the face of possibly uninitialized objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
class BlkClosureCareful : public BlkClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  size_t do_blk(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    guarantee(false, "call do_blk_careful instead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  virtual size_t do_blk_careful(HeapWord* addr) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
// SpaceClosure is used for iterating over spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
class Space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
class CompactibleSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
class SpaceClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // Called for each space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  virtual void do_space(Space* s) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
class CompactibleSpaceClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // Called for each compactible space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  virtual void do_space(CompactibleSpace* s) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   292
// CodeBlobClosure is used for iterating through code blobs
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   293
// in the code cache or on thread stacks
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   294
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   295
class CodeBlobClosure : public Closure {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   296
 public:
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   297
  // Called for each code blob.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   298
  virtual void do_code_blob(CodeBlob* cb) = 0;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   299
};
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   300
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   301
// Applies an oop closure to all ref fields in code blobs
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   302
// iterated over in an object iteration.
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   303
class CodeBlobToOopClosure : public CodeBlobClosure {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   304
  OopClosure* _cl;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   305
  bool _fix_relocations;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   306
 protected:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   307
  void do_nmethod(nmethod* nm);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   308
 public:
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 33226
diff changeset
   309
  // If fix_relocations(), then cl must copy objects to their new location immediately to avoid
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 33226
diff changeset
   310
  // patching nmethods with the old locations.
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   311
  CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   312
  virtual void do_code_blob(CodeBlob* cb);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   313
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 33226
diff changeset
   314
  bool fix_relocations() const { return _fix_relocations; }
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   315
  const static bool FixRelocations = true;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   316
};
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   317
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   318
class MarkingCodeBlobClosure : public CodeBlobToOopClosure {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   319
 public:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   320
  MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {}
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   321
  // Called for each code blob, but at most once per unique blob.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   322
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   323
  virtual void do_code_blob(CodeBlob* cb);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   324
};
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1388
diff changeset
   325
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// MonitorClosure is used for iterating over monitors in the monitors cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
class ObjectMonitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
class MonitorClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // called for each monitor in cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  virtual void do_monitor(ObjectMonitor* m) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
// A closure that is applied without any arguments.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
class VoidClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // I would have liked to declare this a pure virtual, but that breaks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // in mysterious ways, for unknown reasons.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  virtual void do_void();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
// YieldClosure is intended for use by iteration loops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
// to incrementalize their work, allowing interleaving
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
// of an interruptable task so as to allow other
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
// threads to run (which may not otherwise be able to access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
// exclusive resources, for instance). Additionally, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
// closure also allows for aborting an ongoing iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
// by means of checking the return value from the polling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
// call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
class YieldClosure : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
   virtual bool should_return() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
// Abstract closure for serializing data (read or write).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   360
class SerializeClosure : public Closure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  // Return bool indicating whether closure implements read or write.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  virtual bool reading() const = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  // Read/write the void pointer pointed to by p.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  virtual void do_ptr(void** p) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   368
  // Read/write the 32-bit unsigned integer pointed to by p.
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   369
  virtual void do_u4(u4* p) = 0;
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   370
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  // Read/write the region specified.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  virtual void do_region(u_char* start, size_t size) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  // Check/write the tag.  If reading, then compare the tag against
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // the passed in value and fail is they don't match.  This allows
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  // for verification that sections of the serialized data are of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // correct length.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  virtual void do_tag(int tag) = 0;
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   379
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   380
  bool writing() {
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   381
    return !reading();
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37466
diff changeset
   382
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
};
3690
dba50b88bd50 6798898: CMS: bugs related to class unloading
jmasa
parents: 1388
diff changeset
   384
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   385
class SymbolClosure : public StackObj {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   386
 public:
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   387
  virtual void do_symbol(Symbol**) = 0;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   388
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   389
  // Clear LSB in symbol address; it can be set by CPSlot.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   390
  static Symbol* load_symbol(Symbol** p) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   391
    return (Symbol*)(intptr_t(*p) & ~1);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   392
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   393
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   394
  // Store symbol, adjusting new pointer if the original pointer was adjusted
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   395
  // (symbol references in constant pool slots have their LSB set to 1).
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   396
  static void store_symbol(Symbol** p, Symbol* sym) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   397
    *p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1));
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   398
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   399
};
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   400
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   401
// The two class template specializations are used to dispatch calls
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   402
// to the ExtendedOopClosure functions. If use_non_virtual_call is true,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   403
// the non-virtual versions are called (E.g. do_oop_nv), otherwise the
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   404
// virtual versions are called (E.g. do_oop).
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   405
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   406
template <bool use_non_virtual_call>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   407
class Devirtualizer {};
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   408
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   409
// Dispatches to the non-virtual functions.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   410
template <> class Devirtualizer<true> {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   411
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   412
  template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   413
  template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   414
  template <class OopClosureType>             static void do_cld(OopClosureType* closure, ClassLoaderData* cld);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   415
  template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   416
};
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23539
diff changeset
   417
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   418
// Dispatches to the virtual functions.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   419
template <> class Devirtualizer<false> {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   420
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   421
  template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   422
  template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   423
  template <class OopClosureType>             static void do_cld(OopClosureType* closure, ClassLoaderData* cld);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   424
  template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   425
};
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25492
diff changeset
   426
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   427
#endif // SHARE_VM_MEMORY_ITERATOR_HPP