/* * Copyright (c) 2012, 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. *
*/
/* * Support for virtual threads involves oops, access of which may trigger * events, i.e. load barriers. Hence, write_event() must be re-entrant * for recursion. Getting the thread id and capturing a stacktrace may * involve oop access, and are therefore hoisted before claiming a buffer * and binding it to a writer.
*/ void write_event() {
DEBUG_ONLY(assert_precondition();)
Thread* const thread = Thread::current();
JfrThreadLocal* const tl = thread->jfr_thread_local(); const traceid tid = thread_id(thread); const traceid sid = stack_trace_id(thread, tl); // Keep tid and sid above this line.
JfrBuffer* const buffer = tl->native_buffer(); if (buffer == nullptr) { // Most likely a pending OOM. return;
} bool large = is_large(); if (write_sized_event(buffer, thread, tid, sid, large)) { // Event written successfully return;
} if (!large) { // Try large size. if (write_sized_event(buffer, thread, tid, sid, true)) { // Event written successfully, use large size from now on.
set_large();
}
}
}
#ifdef ASSERT private: // Verification of fields.
JfrEventVerifier _verifier;
void assert_precondition() {
assert(T::eventId >= FIRST_EVENT_ID, "event id underflow invariant");
assert(T::eventId <= LAST_EVENT_ID, "event id overflow invariant");
DEBUG_ONLY(static_cast<T*>(this)->verify());
}
protected: void set_field_bit(size_t field_idx) {
_verifier.set_field_bit(field_idx); // It is ok to reuse an already committed event // granted you provide new informational content.
_verifier.clear_committed();
}
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 und die Messung sind noch experimentell.