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

Fri, 31 May 2013 14:32:44 +0200

author
stefank
date
Fri, 31 May 2013 14:32:44 +0200
changeset 5515
9766f73e770d
parent 5237
f2110083203d
child 6876
710a3c8b516e
child 9858
b985cbb00e68
permissions
-rw-r--r--

8022880: False sharing between PSPromotionManager instances
Summary: Pad the PSPromotionManager instances in the manager array.
Reviewed-by: brutisso, jmasa

     1 /*
     2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
    28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
    29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
    30 #include "gc_implementation/shared/collectorCounters.hpp"
    31 #include "gc_implementation/shared/gcTrace.hpp"
    32 #include "memory/allocation.hpp"
    33 #include "oops/oop.hpp"
    34 #include "utilities/stack.hpp"
    36 class GCTaskManager;
    37 class GCTaskQueue;
    38 class OopStack;
    39 class ReferenceProcessor;
    40 class ParallelScavengeHeap;
    41 class ParallelScavengeTracer;
    42 class PSIsAliveClosure;
    43 class PSRefProcTaskExecutor;
    44 class STWGCTimer;
    46 class PSScavenge: AllStatic {
    47   friend class PSIsAliveClosure;
    48   friend class PSKeepAliveClosure;
    49   friend class PSPromotionManager;
    51  enum ScavengeSkippedCause {
    52    not_skipped = 0,
    53    to_space_not_empty,
    54    promoted_too_large,
    55    full_follows_scavenge
    56  };
    58   // Saved value of to_space->top(), used to prevent objects in to_space from
    59   // being rescanned.
    60   static HeapWord* _to_space_top_before_gc;
    62   // Number of consecutive attempts to scavenge that were skipped
    63   static int                _consecutive_skipped_scavenges;
    66  protected:
    67   // Flags/counters
    68   static ReferenceProcessor*  _ref_processor;        // Reference processor for scavenging.
    69   static PSIsAliveClosure     _is_alive_closure;     // Closure used for reference processing
    70   static CardTableExtension*  _card_table;           // We cache the card table for fast access.
    71   static bool                 _survivor_overflow;    // Overflow this collection
    72   static uint                 _tenuring_threshold;   // tenuring threshold for next scavenge
    73   static elapsedTimer         _accumulated_time;     // total time spent on scavenge
    74   static STWGCTimer           _gc_timer;             // GC time book keeper
    75   static ParallelScavengeTracer _gc_tracer;          // GC tracing
    76   // The lowest address possible for the young_gen.
    77   // This is used to decide if an oop should be scavenged,
    78   // cards should be marked, etc.
    79   static HeapWord*            _young_generation_boundary;
    80   // Used to optimize compressed oops young gen boundary checking.
    81   static uintptr_t            _young_generation_boundary_compressed;
    82   static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
    83   static Stack<oop, mtGC>     _preserved_oop_stack;  // List of oops that need their mark restored.
    84   static CollectorCounters*   _counters;             // collector performance counters
    86   static void clean_up_failed_promotion();
    88   static bool should_attempt_scavenge();
    90   static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
    91   static inline void save_to_space_top_before_gc();
    93   // Private accessors
    94   static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
    96  public:
    97   // Accessors
    98   static uint             tenuring_threshold()  { return _tenuring_threshold; }
    99   static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }
   100   static int              consecutive_skipped_scavenges()
   101     { return _consecutive_skipped_scavenges; }
   103   // Performance Counters
   104   static CollectorCounters* counters()           { return _counters; }
   106   // Used by scavenge_contents && psMarkSweep
   107   static ReferenceProcessor* const reference_processor() {
   108     assert(_ref_processor != NULL, "Sanity");
   109     return _ref_processor;
   110   }
   111   // Used to add tasks
   112   static GCTaskManager* const gc_task_manager();
   113   // The promotion managers tell us if they encountered overflow
   114   static void set_survivor_overflow(bool state) {
   115     _survivor_overflow = state;
   116   }
   117   // Adaptive size policy support.  When the young generation/old generation
   118   // boundary moves, _young_generation_boundary must be reset
   119   static void set_young_generation_boundary(HeapWord* v) {
   120     _young_generation_boundary = v;
   121     if (UseCompressedOops) {
   122       _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
   123     }
   124   }
   126   // Called by parallelScavengeHeap to init the tenuring threshold
   127   static void initialize();
   129   // Scavenge entry point.  This may invoke a full gc; return true if so.
   130   static bool invoke();
   131   // Return true if a collection was done; false otherwise.
   132   static bool invoke_no_policy();
   134   // If an attempt to promote fails, this method is invoked
   135   static void oop_promotion_failed(oop obj, markOop obj_mark);
   137   template <class T> static inline bool should_scavenge(T* p);
   139   // These call should_scavenge() above and, if it returns true, also check that
   140   // the object was not newly copied into to_space.  The version with the bool
   141   // argument is a convenience wrapper that fetches the to_space pointer from
   142   // the heap and calls the other version (if the arg is true).
   143   template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
   144   template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
   146   template <class T, bool promote_immediately>
   147     inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
   149   static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
   151   // Is an object in the young generation
   152   // This assumes that the 'o' is in the heap,
   153   // so it only checks one side of the complete predicate.
   155   inline static bool is_obj_in_young(oop o) {
   156     return (HeapWord*)o >= _young_generation_boundary;
   157   }
   159   inline static bool is_obj_in_young(narrowOop o) {
   160     return (uintptr_t)o >= _young_generation_boundary_compressed;
   161   }
   163   inline static bool is_obj_in_young(HeapWord* o) {
   164     return o >= _young_generation_boundary;
   165   }
   166 };
   168 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP

mercurial