Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp
38920 views
/*1* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP25#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP2627#include "gc_implementation/parallelScavenge/cardTableExtension.hpp"28#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"29#include "gc_implementation/shared/collectorCounters.hpp"30#include "gc_implementation/shared/gcTrace.hpp"31#include "memory/allocation.hpp"32#include "oops/oop.hpp"33#include "utilities/stack.hpp"3435class GCTaskManager;36class GCTaskQueue;37class OopStack;38class ReferenceProcessor;39class ParallelScavengeHeap;40class ParallelScavengeTracer;41class PSIsAliveClosure;42class PSRefProcTaskExecutor;43class STWGCTimer;4445class PSScavenge: AllStatic {46friend class PSIsAliveClosure;47friend class PSKeepAliveClosure;48friend class PSPromotionManager;4950enum ScavengeSkippedCause {51not_skipped = 0,52to_space_not_empty,53promoted_too_large,54full_follows_scavenge55};5657// Saved value of to_space->top(), used to prevent objects in to_space from58// being rescanned.59static HeapWord* _to_space_top_before_gc;6061// Number of consecutive attempts to scavenge that were skipped62static int _consecutive_skipped_scavenges;636465protected:66// Flags/counters67static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.68static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing69static CardTableExtension* _card_table; // We cache the card table for fast access.70static bool _survivor_overflow; // Overflow this collection71static uint _tenuring_threshold; // tenuring threshold for next scavenge72static elapsedTimer _accumulated_time; // total time spent on scavenge73static STWGCTimer _gc_timer; // GC time book keeper74static ParallelScavengeTracer _gc_tracer; // GC tracing75// The lowest address possible for the young_gen.76// This is used to decide if an oop should be scavenged,77// cards should be marked, etc.78static HeapWord* _young_generation_boundary;79// Used to optimize compressed oops young gen boundary checking.80static uintptr_t _young_generation_boundary_compressed;81static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion82static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.83static CollectorCounters* _counters; // collector performance counters8485static void clean_up_failed_promotion();8687static bool should_attempt_scavenge();8889static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }90static inline void save_to_space_top_before_gc();9192// Private accessors93static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }94static const ParallelScavengeTracer* gc_tracer() { return &_gc_tracer; }9596public:97// Accessors98static uint tenuring_threshold() { return _tenuring_threshold; }99static elapsedTimer* accumulated_time() { return &_accumulated_time; }100static int consecutive_skipped_scavenges()101{ return _consecutive_skipped_scavenges; }102103// Performance Counters104static CollectorCounters* counters() { return _counters; }105106// Used by scavenge_contents && psMarkSweep107static ReferenceProcessor* const reference_processor() {108assert(_ref_processor != NULL, "Sanity");109return _ref_processor;110}111// Used to add tasks112static GCTaskManager* const gc_task_manager();113// The promotion managers tell us if they encountered overflow114static void set_survivor_overflow(bool state) {115_survivor_overflow = state;116}117// Adaptive size policy support. When the young generation/old generation118// boundary moves, _young_generation_boundary must be reset119static void set_young_generation_boundary(HeapWord* v) {120_young_generation_boundary = v;121if (UseCompressedOops) {122_young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);123}124}125126// Called by parallelScavengeHeap to init the tenuring threshold127static void initialize();128129// Scavenge entry point. This may invoke a full gc; return true if so.130static bool invoke();131// Return true if a collection was done; false otherwise.132static bool invoke_no_policy();133134// If an attempt to promote fails, this method is invoked135static void oop_promotion_failed(oop obj, markOop obj_mark);136137template <class T> static inline bool should_scavenge(T* p);138139// These call should_scavenge() above and, if it returns true, also check that140// the object was not newly copied into to_space. The version with the bool141// argument is a convenience wrapper that fetches the to_space pointer from142// the heap and calls the other version (if the arg is true).143template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);144template <class T> static inline bool should_scavenge(T* p, bool check_to_space);145146template <class T, bool promote_immediately>147inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);148149static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);150151// Is an object in the young generation152// This assumes that the 'o' is in the heap,153// so it only checks one side of the complete predicate.154155inline static bool is_obj_in_young(oop o) {156return (HeapWord*)o >= _young_generation_boundary;157}158159inline static bool is_obj_in_young(narrowOop o) {160return (uintptr_t)o >= _young_generation_boundary_compressed;161}162163inline static bool is_obj_in_young(HeapWord* o) {164return o >= _young_generation_boundary;165}166};167168#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP169170171