hotspot/src/share/vm/memory/sharedHeap.hpp
author jmasa
Mon, 20 Sep 2010 14:38:38 -0700
changeset 6759 67b1a69ef5aa
parent 5547 f4b087cbb361
child 7397 5b173b4ca846
permissions -rw-r--r--
6984287: Regularize how GC parallel workers are specified. Summary: Associate number of GC workers with the workgang as opposed to the task. Reviewed-by: johnc, ysr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 5547
diff changeset
     2
 * Copyright (c) 2000, 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: 4458
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4458
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: 4458
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// A "SharedHeap" is an implementation of a java heap for HotSpot.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// is an abstract class: there may be many different kinds of heaps.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// class defines the functions that a heap must implement, and contains
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// infrastructure common to all heaps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class PermGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class Generation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class BarrierSet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class GenRemSet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class Space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class SpaceClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class OopClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class OopsInGenClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class ObjectClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class SubTasksDone;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class WorkGang;
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 5547
diff changeset
    41
class FlexibleWorkGang;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class CollectorPolicy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class KlassHandle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class SharedHeap : public CollectedHeap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    48
  friend class VM_GC_Operation;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    49
  friend class VM_CGC_Operation;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    50
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // For claiming strong_roots tasks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  SubTasksDone* _process_strong_tasks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // There should be only a single instance of "SharedHeap" in a program.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // This is enforced with the protected constructor below, which will also
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // set the static pointer "_sh" to that instance.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static SharedHeap* _sh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // All heaps contain a "permanent generation."  This is some ways
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // similar to a generation in a generational system, in other ways not.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // See the "PermGen" class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  PermGen* _perm_gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // and the Gen Remembered Set, at least one good enough to scan the perm
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // gen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  GenRemSet* _rem_set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // A gc policy, controls global gc resource issues
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  CollectorPolicy *_collector_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // See the discussion below, in the specification of the reader function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // for this variable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  int _strong_roots_parity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // If we're doing parallel GC, use this gang of threads.
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 5547
diff changeset
    78
  FlexibleWorkGang* _workers;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Number of parallel threads currently working on GC tasks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // O indicates use sequential code; 1 means use parallel code even with
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // only one thread, for performance testing purposes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  int _n_par_threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Full initialization is done in a concrete subtype's "initialize"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // function.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  SharedHeap(CollectorPolicy* policy_);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    89
  // Returns true if the calling thread holds the heap lock,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    90
  // or the calling thread is a par gc thread and the heap_lock is held
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    91
  // by the vm thread doing a gc operation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    92
  bool heap_lock_held_for_gc();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    93
  // True if the heap_lock is held by the a non-gc thread invoking a gc
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    94
  // operation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    95
  bool _thread_holds_heap_lock_for_gc;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    96
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  static SharedHeap* heap() { return _sh; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  CollectorPolicy *collector_policy() const { return _collector_policy; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void set_barrier_set(BarrierSet* bs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Does operations required after initialization has been done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  virtual void post_initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Initialization of ("weak") reference processing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  virtual void ref_processing_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void set_perm(PermGen* perm_gen) { _perm_gen = perm_gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // This function returns the "GenRemSet" object that allows us to scan
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // generations; at least the perm gen, possibly more in a fully
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // generational heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  GenRemSet* rem_set() { return _rem_set; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // These function return the "permanent" generation, in which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // reflective objects are allocated and stored.  Two versions, the second
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // of which returns the view of the perm gen as a generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  PermGen* perm() const { return _perm_gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  Generation* perm_gen() const { return _perm_gen->as_gen(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // Iteration functions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  void oop_iterate(OopClosure* cl) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // Same as above, restricted to a memory region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  virtual void oop_iterate(MemRegion mr, OopClosure* cl) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // Iterate over all objects allocated since the last collection, calling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // "cl->do_object" on each.  The heap must have been initialized properly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // to support this function, or else this call will fail.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  virtual void object_iterate_since_last_GC(ObjectClosure* cl) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Iterate over all spaces in use in the heap, in an undefined order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  virtual void space_iterate(SpaceClosure* cl) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // A SharedHeap will contain some number of spaces.  This finds the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // space whose reserved area contains the given address, or else returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  virtual Space* space_containing(const void* addr) const = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  bool no_gc_in_progress() { return !is_gc_active(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Some collectors will perform "process_strong_roots" in parallel.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // Such a call will involve claiming some fine-grained tasks, such as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // scanning of threads.  To make this process simpler, we provide the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // "strong_roots_parity()" method.  Collectors that start parallel tasks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // whose threads invoke "process_strong_roots" must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // call "change_strong_roots_parity" in sequential code starting such a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // task.  (This also means that a parallel thread may only call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // process_strong_roots once.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // For calls to process_strong_roots by sequential code, the parity is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // updated automatically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // The idea is that objects representing fine-grained tasks, such as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // threads, will contain a "parity" field.  A task will is claimed in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // current "process_strong_roots" call only if its parity field is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // same as the "strong_roots_parity"; task claiming is accomplished by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // updating the parity field to the strong_roots_parity with a CAS.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // If the client meats this spec, then strong_roots_parity() will have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // the following properties:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  //   a) to return a different value than was returned before the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  //      call to change_strong_roots_parity, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  //   c) to never return a distinguished value (zero) with which such
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  //      task-claiming variables may be initialized, to indicate "never
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  //      claimed".
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   169
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  void change_strong_roots_parity();
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   171
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  int strong_roots_parity() { return _strong_roots_parity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   174
  // Call these in sequential code around process_strong_roots.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   175
  // strong_roots_prologue calls change_strong_roots_parity, if
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   176
  // parallel tasks are enabled.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   177
  class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   178
  public:
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   179
    StrongRootsScope(SharedHeap* outer, bool activate = true);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   180
    ~StrongRootsScope();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   181
  };
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   182
  friend class StrongRootsScope;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   183
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  enum ScanningOption {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    SO_None                = 0x0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    SO_AllClasses          = 0x1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    SO_SystemClasses       = 0x2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    SO_Symbols             = 0x4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    SO_Strings             = 0x8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    SO_CodeCache           = 0x10
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 5547
diff changeset
   193
  FlexibleWorkGang* workers() const { return _workers; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // Sets the number of parallel threads that will be doing tasks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // (such as process strong roots) subsequently.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  virtual void set_par_threads(int t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Number of threads currently working on GC tasks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  int n_par_threads() { return _n_par_threads; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // Invoke the "do_oop" method the closure "roots" on all root locations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // If "collecting_perm_gen" is false, then roots that may only contain
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // references to permGen objects are not scanned.  If true, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // "perm_gen" closure is applied to all older-to-younger refs in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // permanent generation.  The "so" argument determines which of roots
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // the closure is applied to:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // "SO_None" does none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // "SO_AllClasses" applies the closure to all entries in the SystemDictionary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  // "SO_SystemClasses" to all the "system" classes and loaders;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // "SO_Symbols" applies the closure to all entries in SymbolsTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // "SO_Strings" applies the closure to all entries in StringTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // "SO_CodeCache" applies the closure to all elements of the CodeCache.
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   214
  void process_strong_roots(bool activate_scope,
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   215
                            bool collecting_perm_gen,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                            ScanningOption so,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                            OopClosure* roots,
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   218
                            CodeBlobClosure* code_roots,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
                            OopsInGenClosure* perm_blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Apply "blk" to all the weak roots of the system.  These include
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // JNI weak roots, the code cache, system dictionary, symbol table,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // string table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  void process_weak_roots(OopClosure* root_closure,
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 2105
diff changeset
   225
                          CodeBlobClosure* code_roots,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
                          OopClosure* non_root_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // The functions below are helper functions that a subclass of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // "SharedHeap" can use in the implementation of its virtual
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // functions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   232
public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // Do anything common to GC's.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  virtual void gc_prologue(bool full) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  virtual void gc_epilogue(bool full) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // New methods from CollectedHeap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  size_t permanent_capacity() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    return perm_gen()->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  size_t permanent_used() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    return perm_gen()->used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  bool is_in_permanent(const void *p) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    return perm_gen()->is_in_reserved(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // Different from is_in_permanent in that is_in_permanent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  // only checks if p is in the reserved area of the heap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // and this checks to see if it in the commited area.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // This is typically used by things like the forte stackwalker
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // during verification of suspicious frame values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  bool is_permanent(const void *p) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    return perm_gen()->is_in(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  HeapWord* permanent_mem_allocate(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    return _perm_gen->mem_allocate(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  void permanent_oop_iterate(OopClosure* cl) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    _perm_gen->oop_iterate(cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  void permanent_object_iterate(ObjectClosure* cl) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    assert(perm_gen(), "NULL perm gen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    _perm_gen->object_iterate(cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // Some utilities.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   283
  void print_size_transition(outputStream* out,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   284
                             size_t bytes_before,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
                             size_t bytes_after,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
                             size_t capacity);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
};