/* * Copyright (c) 2020, 2021, 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. *
*/
// This class encapsulates various marks we need to deal with calling the // frame processing code from arbitrary points in the runtime. It is mostly // due to problems that we might want to eventually clean up inside of the // frame processing code, such as creating random handles even though there // is no safepoint to protect against, and fiddling around with exceptions. class StackWatermarkProcessingMark {
ResetNoHandleMark _rnhm;
HandleMark _hm;
PreserveExceptionMark _pem;
ResourceMark _rm;
#ifdef ASSERT void StackWatermark::assert_is_frame_safe(const frame& f) {
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
assert(is_frame_safe(f), "Frame must be safe");
} #endif
// A frame is "safe" if it *and* its caller have been processed. This is the invariant // that allows exposing a frame, and for that frame to directly access its caller frame // without going through any hooks. bool StackWatermark::is_frame_safe(const frame& f) {
assert(_lock.owned_by_self(), "Must be locked");
uint32_t state = Atomic::load(&_state); if (!processing_started(state)) { returnfalse;
} if (processing_completed(state)) { returntrue;
} returnreinterpret_cast<uintptr_t>(f.sp()) < _iterator->caller();
}
void StackWatermark::start_processing_impl(void* context) {
log_info(stackbarrier)("Starting stack processing for tid %d",
_jt->osthread()->thread_id()); delete _iterator; if (_jt->has_last_Java_frame()) {
_iterator = new StackWatermarkFramesIterator(*this); // Always process three frames when starting an iteration. // // The three frames corresponds to: // 1) The callee frame // 2) The caller frame // This allows a callee to always be able to read state from its caller // without needing any special barriers. // // 3) An extra frame to deal with unwinding safepointing on the way out. // Sometimes, we also call into the runtime to on_unwind(), but then // hit a safepoint poll on the way out from the runtime.
_iterator->process_one(context);
_iterator->process_one(context);
_iterator->process_one(context);
} else {
_iterator = NULL;
}
update_watermark();
}
uintptr_t StackWatermark::last_processed() {
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag); if (!processing_started()) { // Stale state; no last processed return 0;
} if (processing_completed()) { // Already processed all; no last processed return 0;
} return _iterator->caller();
}
// If the thread waking up from a safepoint expected certain other // stack watermarks (potentially from different threads) are processed, // then we have to perform processing of said linked watermarks here.
process_linked_watermarks();
}
void StackWatermark::start_processing() { if (!processing_started_acquire()) {
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag); if (!processing_started()) {
start_processing_impl(NULL /* context */);
}
}
}
void StackWatermark::finish_processing(void* context) {
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag); if (!processing_started()) {
start_processing_impl(context);
} if (!processing_completed()) {
_iterator->process_all(context);
update_watermark();
}
}
¤ Dauer der Verarbeitung: 0.12 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.