src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp

changeset 435
a61af66fc99e
child 548
ba764ed4b6f2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 + * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +class GCTaskManager;
    1.29 +class GCTaskQueue;
    1.30 +class OopStack;
    1.31 +class ReferenceProcessor;
    1.32 +class ParallelScavengeHeap;
    1.33 +class PSIsAliveClosure;
    1.34 +class PSRefProcTaskExecutor;
    1.35 +
    1.36 +class PSScavenge: AllStatic {
    1.37 +  friend class PSIsAliveClosure;
    1.38 +  friend class PSKeepAliveClosure;
    1.39 +  friend class PSPromotionManager;
    1.40 +
    1.41 + enum ScavengeSkippedCause {
    1.42 +   not_skipped = 0,
    1.43 +   to_space_not_empty,
    1.44 +   promoted_too_large,
    1.45 +   full_follows_scavenge
    1.46 + };
    1.47 +
    1.48 +  // Saved value of to_space->top(), used to prevent objects in to_space from
    1.49 +  // being rescanned.
    1.50 +  static HeapWord* _to_space_top_before_gc;
    1.51 +
    1.52 +  // Number of consecutive attempts to scavenge that were skipped
    1.53 +  static int                _consecutive_skipped_scavenges;
    1.54 +
    1.55 +
    1.56 + protected:
    1.57 +  // Flags/counters
    1.58 +  static ReferenceProcessor* _ref_processor;        // Reference processor for scavenging.
    1.59 +  static PSIsAliveClosure    _is_alive_closure;     // Closure used for reference processing
    1.60 +  static CardTableExtension* _card_table;           // We cache the card table for fast access.
    1.61 +  static bool                _survivor_overflow;    // Overflow this collection
    1.62 +  static int                 _tenuring_threshold;   // tenuring threshold for next scavenge
    1.63 +  static elapsedTimer        _accumulated_time;     // total time spent on scavenge
    1.64 +  static HeapWord*           _young_generation_boundary; // The lowest address possible for the young_gen.
    1.65 +                                                         // This is used to decide if an oop should be scavenged,
    1.66 +                                                         // cards should be marked, etc.
    1.67 +  static GrowableArray<markOop>* _preserved_mark_stack; // List of marks to be restored after failed promotion
    1.68 +  static GrowableArray<oop>*     _preserved_oop_stack;  // List of oops that need their mark restored.
    1.69 +  static CollectorCounters*      _counters;         // collector performance counters
    1.70 +
    1.71 +  static void clean_up_failed_promotion();
    1.72 +
    1.73 +  static bool should_attempt_scavenge();
    1.74 +
    1.75 +  static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
    1.76 +  static inline void save_to_space_top_before_gc();
    1.77 +
    1.78 +  // Private accessors
    1.79 +  static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
    1.80 +
    1.81 + public:
    1.82 +  // Accessors
    1.83 +  static int              tenuring_threshold()  { return _tenuring_threshold; }
    1.84 +  static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }
    1.85 +  static bool             promotion_failed()
    1.86 +    { return _preserved_mark_stack != NULL; }
    1.87 +  static int              consecutive_skipped_scavenges()
    1.88 +    { return _consecutive_skipped_scavenges; }
    1.89 +
    1.90 +  // Performance Counters
    1.91 +  static CollectorCounters* counters()           { return _counters; }
    1.92 +
    1.93 +  // Used by scavenge_contents && psMarkSweep
    1.94 +  static ReferenceProcessor* const reference_processor() {
    1.95 +    assert(_ref_processor != NULL, "Sanity");
    1.96 +    return _ref_processor;
    1.97 +  }
    1.98 +  // Used to add tasks
    1.99 +  static GCTaskManager* const gc_task_manager();
   1.100 +  // The promotion managers tell us if they encountered overflow
   1.101 +  static void set_survivor_overflow(bool state) {
   1.102 +    _survivor_overflow = state;
   1.103 +  }
   1.104 +  // Adaptive size policy support.  When the young generation/old generation
   1.105 +  // boundary moves, _young_generation_boundary must be reset
   1.106 +  static void set_young_generation_boundary(HeapWord* v) {
   1.107 +    _young_generation_boundary = v;
   1.108 +  }
   1.109 +
   1.110 +  // Called by parallelScavengeHeap to init the tenuring threshold
   1.111 +  static void initialize();
   1.112 +
   1.113 +  // Scavenge entry point
   1.114 +  static void invoke();
   1.115 +  // Return true is a collection was done.  Return
   1.116 +  // false if the collection was skipped.
   1.117 +  static bool invoke_no_policy();
   1.118 +
   1.119 +  // If an attempt to promote fails, this method is invoked
   1.120 +  static void oop_promotion_failed(oop obj, markOop obj_mark);
   1.121 +
   1.122 +  static inline bool should_scavenge(oop p);
   1.123 +
   1.124 +  // These call should_scavenge() above and, if it returns true, also check that
   1.125 +  // the object was not newly copied into to_space.  The version with the bool
   1.126 +  // argument is a convenience wrapper that fetches the to_space pointer from
   1.127 +  // the heap and calls the other version (if the arg is true).
   1.128 +  static inline bool should_scavenge(oop p, MutableSpace* to_space);
   1.129 +  static inline bool should_scavenge(oop p, bool check_to_space);
   1.130 +
   1.131 +  inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, oop* p);
   1.132 +
   1.133 +  // Is an object in the young generation
   1.134 +  // This assumes that the HeapWord argument is in the heap,
   1.135 +  // so it only checks one side of the complete predicate.
   1.136 +  inline static bool is_obj_in_young(HeapWord* o) {
   1.137 +    const bool result = (o >= _young_generation_boundary);
   1.138 +    return result;
   1.139 +  }
   1.140 +};

mercurial