hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 670 ddf3e9583f2f
child 6762 f8d1b560700e
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
     2
 * Copyright (c) 2002, 2008, 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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
class GCTaskManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class GCTaskQueue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class OopStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class ReferenceProcessor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class ParallelScavengeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class PSIsAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class PSRefProcTaskExecutor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class PSScavenge: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  friend class PSIsAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  friend class PSKeepAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  friend class PSPromotionManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 enum ScavengeSkippedCause {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
   not_skipped = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
   to_space_not_empty,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
   promoted_too_large,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
   full_follows_scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Saved value of to_space->top(), used to prevent objects in to_space from
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // being rescanned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  static HeapWord* _to_space_top_before_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // Number of consecutive attempts to scavenge that were skipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  static int                _consecutive_skipped_scavenges;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Flags/counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  static ReferenceProcessor* _ref_processor;        // Reference processor for scavenging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  static PSIsAliveClosure    _is_alive_closure;     // Closure used for reference processing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  static CardTableExtension* _card_table;           // We cache the card table for fast access.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  static bool                _survivor_overflow;    // Overflow this collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static int                 _tenuring_threshold;   // tenuring threshold for next scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static elapsedTimer        _accumulated_time;     // total time spent on scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static HeapWord*           _young_generation_boundary; // The lowest address possible for the young_gen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
                                                         // This is used to decide if an oop should be scavenged,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
                                                         // cards should be marked, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  static GrowableArray<markOop>* _preserved_mark_stack; // List of marks to be restored after failed promotion
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  static GrowableArray<oop>*     _preserved_oop_stack;  // List of oops that need their mark restored.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static CollectorCounters*      _counters;         // collector performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  static void clean_up_failed_promotion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  static bool should_attempt_scavenge();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  static inline void save_to_space_top_before_gc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Private accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  static int              tenuring_threshold()  { return _tenuring_threshold; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static bool             promotion_failed()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    { return _preserved_mark_stack != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static int              consecutive_skipped_scavenges()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    { return _consecutive_skipped_scavenges; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Performance Counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  static CollectorCounters* counters()           { return _counters; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // Used by scavenge_contents && psMarkSweep
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  static ReferenceProcessor* const reference_processor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    assert(_ref_processor != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    return _ref_processor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Used to add tasks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  static GCTaskManager* const gc_task_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // The promotion managers tell us if they encountered overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  static void set_survivor_overflow(bool state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    _survivor_overflow = state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Adaptive size policy support.  When the young generation/old generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // boundary moves, _young_generation_boundary must be reset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  static void set_young_generation_boundary(HeapWord* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    _young_generation_boundary = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Called by parallelScavengeHeap to init the tenuring threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Scavenge entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  static void invoke();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Return true is a collection was done.  Return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // false if the collection was skipped.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  static bool invoke_no_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // If an attempt to promote fails, this method is invoked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  static void oop_promotion_failed(oop obj, markOop obj_mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   119
  template <class T> static inline bool should_scavenge(T* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // These call should_scavenge() above and, if it returns true, also check that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // the object was not newly copied into to_space.  The version with the bool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // argument is a convenience wrapper that fetches the to_space pointer from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // 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
   125
  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
   126
  template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   128
  template <class T> inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Is an object in the young generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // This assumes that the HeapWord argument is in the heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // so it only checks one side of the complete predicate.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  inline static bool is_obj_in_young(HeapWord* o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    const bool result = (o >= _young_generation_boundary);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
};