/* * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. *
*/
// To prevent false sharing, we pad the PSPromotionManagers // and make sure that the first instance starts at a cache line.
assert(_manager_array == NULL, "Attempt to initialize twice");
_manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(promotion_manager_num);
_stack_array_depth = new PSScannerTasksQueueSet(ParallelGCThreads);
// Create and register the PSPromotionManager(s) for the worker threads. for(uint i=0; i<ParallelGCThreads; i++) {
stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth());
} // The VMThread gets its own PSPromotionManager, which is not available // for work stealing.
assert(_preserved_marks_set == NULL, "Attempt to initialize twice");
_preserved_marks_set = new PreservedMarksSet(true/* in_c_heap */);
_preserved_marks_set->init(promotion_manager_num); for (uint i = 0; i < promotion_manager_num; i += 1) {
_manager_array[i].register_preserved_marks(_preserved_marks_set->get(i));
}
}
// Helper functions to get around the circular dependency between // psScavenge.inline.hpp and psPromotionManager.inline.hpp. bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) { return PSScavenge::should_scavenge(p, check_to_space);
} bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) { return PSScavenge::should_scavenge(p, check_to_space);
}
PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) {
assert(index < ParallelGCThreads, "index out of range");
assert(_manager_array != NULL, "Sanity"); return &_manager_array[index];
}
TASKQUEUE_STATS_ONLY(print_taskqueue_stats()); for (uint i = 0; i < ParallelGCThreads; i++) {
PSPromotionManager* manager = manager_array(i);
assert(manager->claimed_stack_depth()->is_empty(), "should be empty"); if (manager->_promotion_failed_info.has_failed()) {
gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
promotion_failure_occurred = true;
}
manager->flush_labs();
manager->flush_string_dedup_requests();
} if (!promotion_failure_occurred) { // If there was no promotion failure, the preserved mark stacks // should be empty.
_preserved_marks_set->assert_empty();
} return promotion_failure_occurred;
}
if (ParallelGCThreads == 1) {
_target_stack_size = 0;
} else { // don't let the target stack size to be more than 1/4 of the entries
_target_stack_size = (uint) MIN2((uint) GCDrainStackTargetSize,
(uint) (queue_size / 4));
}
void PSPromotionManager::reset() {
assert(stacks_empty(), "reset of non-empty stack");
// We need to get an assert in here to make sure the labs are always flushed.
// Do not prefill the LAB's, save heap wastage!
HeapWord* lab_base = young_space()->top();
_young_lab.initialize(MemRegion(lab_base, (size_t)0));
_young_gen_is_full = false;
PSScannerTasksQueue* const tq = claimed_stack_depth(); do {
ScannerTask task;
// Drain overflow stack first, so other threads can steal from // claimed stack while we work. while (tq->pop_overflow(task)) {
process_popped_location_depth(task);
}
if (totally_drain) { while (tq->pop_local(task)) {
process_popped_location_depth(task);
}
} else { while (tq->size() > _target_stack_size && tq->pop_local(task)) {
process_popped_location_depth(task);
}
}
} while ((totally_drain && !tq->taskqueue_empty()) || !tq->overflow_empty());
void PSPromotionManager::flush_labs() {
assert(stacks_empty(), "Attempt to flush lab with live stack");
// If either promotion lab fills up, we can flush the // lab but not refill it, so check first.
assert(!_young_lab.is_flushed() || _young_gen_is_full, "Sanity"); if (!_young_lab.is_flushed())
_young_lab.flush();
assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity"); if (!_old_lab.is_flushed())
_old_lab.flush();
// Let PSScavenge know if we overflowed if (_young_gen_is_full) {
PSScavenge::set_survivor_overflow(true);
}
}
template <class T> void PSPromotionManager::process_array_chunk_work(
oop obj, int start, int end) {
assert(start <= end, "invariant");
T* const base = (T*)objArrayOop(obj)->base();
T* p = base + start;
T* const chunk_end = base + end; while (p < chunk_end) { if (PSScavenge::should_scavenge(p)) {
claim_or_forward_depth(p);
}
++p;
}
}
oop old = task.to_source_array();
assert(old->is_objArray(), "invariant");
assert(old->is_forwarded(), "invariant");
TASKQUEUE_STATS_ONLY(++_array_chunks_processed);
oop const obj = old->forwardee();
int start; intconst end = arrayOop(old)->length(); if (end > (int) _min_array_size_for_chunking) { // we'll chunk more
start = end - _array_chunk_size;
assert(start > 0, "invariant");
arrayOop(old)->set_length(start);
push_depth(ScannerTask(PartialArrayScanTask(old)));
TASKQUEUE_STATS_ONLY(++_array_chunk_pushes);
} else { // this is the final chunk for this array
start = 0; intconst actual_length = arrayOop(obj)->length();
arrayOop(old)->set_length(actual_length);
}
// Attempt to CAS in the header. // This tests if the header is still the same as when // this started. If it is the same (i.e., no forwarding // pointer has been installed), then this thread owns // it. if (obj->forward_to_atomic(obj, obj_mark) == NULL) { // We won any races, we "own" this object.
assert(obj == obj->forwardee(), "Sanity");
// Save the markWord of promotion-failed objs in _preserved_marks for later // restoration. This way we don't have to walk the young-gen to locate // these promotion-failed objs.
_preserved_marks->push_always(obj, obj_mark);
} else { // We lost, someone else "owns" this object
guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed.");
// No unallocation to worry about.
obj = obj->forwardee();
}
return obj;
}
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.