0N/A/*
3198N/A * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
1879N/A
1879N/A#include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
1879N/A#include "gc_implementation/shared/collectorCounters.hpp"
4141N/A#include "gc_implementation/shared/gcTrace.hpp"
1879N/A#include "memory/allocation.hpp"
1879N/A#include "oops/oop.hpp"
1879N/A#include "utilities/stack.hpp"
1879N/A
0N/Aclass GCTaskManager;
0N/Aclass GCTaskQueue;
0N/Aclass OopStack;
0N/Aclass ReferenceProcessor;
0N/Aclass ParallelScavengeHeap;
4141N/Aclass ParallelScavengeTracer;
0N/Aclass PSIsAliveClosure;
0N/Aclass PSRefProcTaskExecutor;
4141N/Aclass STWGCTimer;
0N/A
0N/Aclass PSScavenge: AllStatic {
0N/A friend class PSIsAliveClosure;
0N/A friend class PSKeepAliveClosure;
0N/A friend class PSPromotionManager;
0N/A
0N/A enum ScavengeSkippedCause {
0N/A not_skipped = 0,
0N/A to_space_not_empty,
0N/A promoted_too_large,
0N/A full_follows_scavenge
0N/A };
0N/A
0N/A // Saved value of to_space->top(), used to prevent objects in to_space from
0N/A // being rescanned.
0N/A static HeapWord* _to_space_top_before_gc;
0N/A
0N/A // Number of consecutive attempts to scavenge that were skipped
0N/A static int _consecutive_skipped_scavenges;
0N/A
0N/A
0N/A protected:
0N/A // Flags/counters
0N/A static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
0N/A static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
0N/A static CardTableExtension* _card_table; // We cache the card table for fast access.
0N/A static bool _survivor_overflow; // Overflow this collection
0N/A static int _tenuring_threshold; // tenuring threshold for next scavenge
0N/A static elapsedTimer _accumulated_time; // total time spent on scavenge
4141N/A static STWGCTimer _gc_timer; // GC time book keeper
4141N/A static ParallelScavengeTracer _gc_tracer; // GC tracing
0N/A static HeapWord* _young_generation_boundary; // The lowest address possible for the young_gen.
0N/A // This is used to decide if an oop should be scavenged,
0N/A // cards should be marked, etc.
3863N/A static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
3863N/A static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.
0N/A static CollectorCounters* _counters; // collector performance counters
0N/A
0N/A static void clean_up_failed_promotion();
0N/A
0N/A static bool should_attempt_scavenge();
0N/A
0N/A static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
0N/A static inline void save_to_space_top_before_gc();
0N/A
0N/A // Private accessors
0N/A static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
0N/A
0N/A public:
0N/A // Accessors
0N/A static int tenuring_threshold() { return _tenuring_threshold; }
0N/A static elapsedTimer* accumulated_time() { return &_accumulated_time; }
0N/A static int consecutive_skipped_scavenges()
0N/A { return _consecutive_skipped_scavenges; }
0N/A
0N/A // Performance Counters
0N/A static CollectorCounters* counters() { return _counters; }
0N/A
0N/A // Used by scavenge_contents && psMarkSweep
0N/A static ReferenceProcessor* const reference_processor() {
0N/A assert(_ref_processor != NULL, "Sanity");
0N/A return _ref_processor;
0N/A }
0N/A // Used to add tasks
0N/A static GCTaskManager* const gc_task_manager();
0N/A // The promotion managers tell us if they encountered overflow
0N/A static void set_survivor_overflow(bool state) {
0N/A _survivor_overflow = state;
0N/A }
0N/A // Adaptive size policy support. When the young generation/old generation
0N/A // boundary moves, _young_generation_boundary must be reset
0N/A static void set_young_generation_boundary(HeapWord* v) {
0N/A _young_generation_boundary = v;
0N/A }
0N/A
0N/A // Called by parallelScavengeHeap to init the tenuring threshold
0N/A static void initialize();
0N/A
3202N/A // Scavenge entry point. This may invoke a full gc; return true if so.
3202N/A static bool invoke();
3202N/A // Return true if a collection was done; false otherwise.
0N/A static bool invoke_no_policy();
0N/A
0N/A // If an attempt to promote fails, this method is invoked
0N/A static void oop_promotion_failed(oop obj, markOop obj_mark);
0N/A
113N/A template <class T> static inline bool should_scavenge(T* p);
0N/A
0N/A // These call should_scavenge() above and, if it returns true, also check that
0N/A // the object was not newly copied into to_space. The version with the bool
0N/A // argument is a convenience wrapper that fetches the to_space pointer from
0N/A // the heap and calls the other version (if the arg is true).
113N/A template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
113N/A template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
0N/A
3198N/A template <class T, bool promote_immediately>
3198N/A inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
0N/A
0N/A // Is an object in the young generation
0N/A // This assumes that the HeapWord argument is in the heap,
0N/A // so it only checks one side of the complete predicate.
0N/A inline static bool is_obj_in_young(HeapWord* o) {
0N/A const bool result = (o >= _young_generation_boundary);
0N/A return result;
0N/A }
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP