/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "gc_implementation/shared/gcTrace.hpp"
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
#include "gc_implementation/shared/copyFailedInfo.hpp"
#include "memory/defNewGeneration.hpp"
#include "utilities/taskqueue.hpp"
class ChunkArray;
class ParScanWithoutBarrierClosure;
class ParScanWithBarrierClosure;
class ParEvacuateFollowersClosure;
// It would be better if these types could be kept local to the .cpp file,
// but they must be here to allow ParScanClosure::do_oop_work to be defined
// in genOopClosures.inline.hpp.
private:
protected:
template <class T> void do_oop_work(T* p);
public:
};
// The state needed by thread performing parallel young-gen collection.
class ParScanThreadState {
friend class ParScanThreadStateSet;
private:
// One of these two will be passed to process_strong_roots, which will
// set its generation. The first is for two-gen configs where the
// old gen collects the perm gen; the second is for arbitrary configs.
// The second isn't used right now (it used to be used for the train, an
// incremental collector) but the declaration has been left as a reminder.
// This closure will always be bound to the old gen; it will be used
// in evacuate_followers.
int _hash_seed;
int _thread_num;
bool _to_space_full;
#if TASKQUEUE_STATS
#endif // TASKQUEUE_STATS
// Stats for promotion failure
// Timing numbers.
double _start;
double _start_strong_roots;
double _strong_roots_time;
double _start_term;
double _term_time;
// Helper for trim_queues. Scans subset of an array and makes
// remainder available for work stealing.
// In support of CMS' parallel rescan of survivor space.
public:
return &_to_space_alloc_buffer;
}
// Decrease queue size below "max_size".
void trim_queues(int max_size);
// Private overflow stack usage
bool take_from_overflow_stack();
void push_on_overflow_stack(oop p);
// Is new_obj a candidate for scan_partial_array_and_push_remainder method.
// Allocate a to-space block of size "sz", or else return NULL.
else return alloc_in_to_space_slow(word_sz);
}
}
// Undo the most recent allocation ("obj", of "word_sz").
// Promotion failure stats
}
return _promotion_failed_info;
}
bool promotion_failed() {
return _promotion_failed_info.has_failed();
}
void print_promotion_failure_size();
#if TASKQUEUE_STATS
}
void reset_stats();
#endif // TASKQUEUE_STATS
void start_strong_roots() {
}
void end_strong_roots() {
}
void start_term_time() {
}
void end_term_time() {
}
double elapsed_time() const {
}
};
private:
public:
// Reset the terminator in ParScanThreadStateSet for
// "active_workers" threads.
virtual void set_for_termination(int active_workers);
};
protected:
template <class T> void do_oop_work(T* p);
public:
};
private:
int _level;
public:
virtual void do_void();
};
// Closure for scanning ParNewGeneration.
// Same as ScanClosure, except does parallel GC barrier.
protected:
template <class T> void do_oop_work(T* p);
public:
};
// Implements AbstractRefProcTaskExecutor for ParNew.
private:
public:
{ }
// Executes a task using worker threads.
// Switch to single threaded mode.
virtual void set_single_threaded_mode();
};
// A Generation that does parallel young-gen collection.
friend class ParNewGenTask;
friend class ParNewRefProcTask;
friend class ParNewRefProcTaskExecutor;
friend class ParScanThreadStateSet;
friend class ParEvacuateFollowersClosure;
private:
// The per-worker-thread work queues
// Per-worker-thread local overflow stacks
// Desired size of survivor space plab's
// A list of from-space images of to-be-scanned objects, threaded through
// klass-pointers (klass information already copied to the forwarded
// image.) Manipulated with CAS.
// If true, older generation does not support promotion undo, so avoid.
static bool _avoid_promotion_undo;
// This closure is used by the reference processor to filter out
// references to live referent.
static void waste_some_time();
// Preserve the mark of "obj", if necessary, in preparation for its mark
// word being overwritten with a self-forwarding-pointer.
void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer);
protected:
bool _survivor_overflow;
// Adjust the tenuring threshold. See the implementation for
// the details of the policy.
virtual void adjust_desired_tenuring_threshold();
public:
~ParNewGeneration() {
for (uint i = 0; i < ParallelGCThreads; i++)
delete _task_queues->queue(i);
delete _task_queues;
}
static bool in_use();
virtual void ref_processor_init();
virtual const char* name() const;
// override
virtual bool refs_discovery_is_mt() const {
return ParallelGCThreads > 1;
}
// Make the collection virtual.
bool clear_all_soft_refs,
bool is_tlab);
// This needs to be visible to the closure function.
// "obj" is the object to be copied, "m" is a recent value of its mark
// that must not contain a forwarding pointer (though one might be
// inserted in "obj"s mark word by a parallel thread).
if (_avoid_promotion_undo) {
}
}
// in support of testing overflow code
NOT_PRODUCT(int _overflow_counter;)
NOT_PRODUCT(bool should_simulate_overflow();)
// Accessor for overflow list
// Push the given (from-space) object on the global overflow list.
// If the global overflow list is non-empty, move some tasks from it
// onto "work_q" (which need not be empty). No more than 1/4 of the
// available space on "work_q" is used.
// The task queues to be used by parallel GC threads.
return _task_queues;
}
return &_plab_stats;
}
return _plab_stats.desired_plab_sz();
}
};
#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP