hotspot/src/share/vm/gc/parallel/psScavenge.hpp
author pliden
Wed, 13 May 2015 15:16:06 +0200
changeset 30764 fec48bf5a827
parent 29208 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp@b570d043f295
child 35862 411842d0c882
permissions -rw-r--r--
8079792: GC directory structure cleanup Reviewed-by: brutisso, stefank, david
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
     2
 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSSCAVENGE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSSCAVENGE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    28
#include "gc/parallel/cardTableExtension.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    29
#include "gc/parallel/psVirtualspace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    30
#include "gc/shared/collectorCounters.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
    31
#include "gc/shared/gcTrace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    32
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    33
#include "oops/oop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    34
#include "utilities/stack.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    35
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class GCTaskManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class GCTaskQueue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class OopStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class ReferenceProcessor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class ParallelScavengeHeap;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    41
class ParallelScavengeTracer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class PSIsAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class PSRefProcTaskExecutor;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    44
class STWGCTimer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class PSScavenge: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  friend class PSIsAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  friend class PSKeepAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  friend class PSPromotionManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 enum ScavengeSkippedCause {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
   not_skipped = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
   to_space_not_empty,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
   promoted_too_large,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
   full_follows_scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Saved value of to_space->top(), used to prevent objects in to_space from
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // being rescanned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static HeapWord* _to_space_top_before_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // Number of consecutive attempts to scavenge that were skipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  static int                _consecutive_skipped_scavenges;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Flags/counters
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    68
  static ReferenceProcessor*  _ref_processor;        // Reference processor for scavenging.
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    69
  static PSIsAliveClosure     _is_alive_closure;     // Closure used for reference processing
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    70
  static CardTableExtension*  _card_table;           // We cache the card table for fast access.
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    71
  static bool                 _survivor_overflow;    // Overflow this collection
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    72
  static uint                 _tenuring_threshold;   // tenuring threshold for next scavenge
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    73
  static elapsedTimer         _accumulated_time;     // total time spent on scavenge
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    74
  static STWGCTimer           _gc_timer;             // GC time book keeper
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
    75
  static ParallelScavengeTracer _gc_tracer;          // GC tracing
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    76
  // The lowest address possible for the young_gen.
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    77
  // This is used to decide if an oop should be scavenged,
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    78
  // cards should be marked, etc.
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    79
  static HeapWord*            _young_generation_boundary;
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    80
  // Used to optimize compressed oops young gen boundary checking.
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    81
  static uintptr_t            _young_generation_boundary_compressed;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11757
diff changeset
    82
  static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11757
diff changeset
    83
  static Stack<oop, mtGC>     _preserved_oop_stack;  // List of oops that need their mark restored.
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    84
  static CollectorCounters*   _counters;             // collector performance counters
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static void clean_up_failed_promotion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  static bool should_attempt_scavenge();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  static inline void save_to_space_top_before_gc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // Private accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
28177
318600b0d7db 8066442: Add PS and ParOld support for promotion event
sfriberg
parents: 18025
diff changeset
    95
  static const ParallelScavengeTracer* gc_tracer() { return &_gc_tracer; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // Accessors
13925
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13728
diff changeset
    99
  static uint             tenuring_threshold()  { return _tenuring_threshold; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static int              consecutive_skipped_scavenges()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    { return _consecutive_skipped_scavenges; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Performance Counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static CollectorCounters* counters()           { return _counters; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Used by scavenge_contents && psMarkSweep
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static ReferenceProcessor* const reference_processor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    assert(_ref_processor != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return _ref_processor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Used to add tasks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  static GCTaskManager* const gc_task_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // The promotion managers tell us if they encountered overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  static void set_survivor_overflow(bool state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    _survivor_overflow = state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Adaptive size policy support.  When the young generation/old generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // boundary moves, _young_generation_boundary must be reset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  static void set_young_generation_boundary(HeapWord* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    _young_generation_boundary = v;
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   122
    if (UseCompressedOops) {
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   123
      _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   124
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Called by parallelScavengeHeap to init the tenuring threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
11757
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   130
  // Scavenge entry point.  This may invoke a full gc; return true if so.
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   131
  static bool invoke();
cdf6204b114a 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 11753
diff changeset
   132
  // Return true if a collection was done; false otherwise.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  static bool invoke_no_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // If an attempt to promote fails, this method is invoked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  static void oop_promotion_failed(oop obj, markOop obj_mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   138
  template <class T> static inline bool should_scavenge(T* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // These call should_scavenge() above and, if it returns true, also check that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // the object was not newly copied into to_space.  The version with the bool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // argument is a convenience wrapper that fetches the to_space pointer from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // the heap and calls the other version (if the arg is true).
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   144
  template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   145
  template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   147
  static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   148
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Is an object in the young generation
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   150
  // This assumes that the 'o' is in the heap,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // so it only checks one side of the complete predicate.
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   152
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   153
  inline static bool is_obj_in_young(oop o) {
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   154
    return (HeapWord*)o >= _young_generation_boundary;
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   155
  }
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   156
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   157
  inline static bool is_obj_in_young(narrowOop o) {
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   158
    return (uintptr_t)o >= _young_generation_boundary_compressed;
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   159
  }
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   160
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  inline static bool is_obj_in_young(HeapWord* o) {
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
   162
    return o >= _young_generation_boundary;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
   165
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29208
diff changeset
   166
#endif // SHARE_VM_GC_PARALLEL_PSSCAVENGE_HPP