/* * Copyright (c) 2016, 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. *
*/
jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, JavaThread* jt) {
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(jt));
assert(writer != NULL, "invariant");
oop const w = JNIHandles::resolve_non_null(writer);
assert(w != NULL, "invariant");
JfrBuffer* const current = jt->jfr_thread_local()->java_buffer();
assert(current != NULL, "invariant");
JfrBuffer* const buffer = JfrStorage::flush(current, used, requested, false, jt);
assert(buffer != NULL, "invariant"); // "validity" is contextually defined here to mean // that some memory location was provided that is // large enough to accommodate the "requested size". constbool is_valid = buffer->free_size() >= (size_t)(used + requested);
u1* const new_current_position = is_valid ? buffer->pos() + used : buffer->pos();
assert(start_pos_offset != invalid_offset, "invariant");
w->long_field_put(start_pos_offset, (jlong)buffer->pos());
w->long_field_put(current_pos_offset, (jlong)new_current_position); // only update java writer if underlying memory changed if (buffer != current) {
w->long_field_put(start_pos_address_offset, (jlong)buffer->pos_address());
w->long_field_put(max_pos_offset, (jlong)buffer->end());
} if (!is_valid) { // mark writer as invalid for this write attempt
w->release_bool_field_put(valid_offset, JNI_FALSE); return JNI_FALSE;
} // An exclusive use of a leased buffer is treated equivalent to // holding a system resource. As such, it should be released as soon as possible. // Returning true here signals that the thread will need to call flush again // on EventWriter.endEvent() and that flush will return the lease. return buffer->lease() ? JNI_TRUE : JNI_FALSE;
}
class JfrJavaEventWriterNotificationClosure : public ThreadClosure { public: void do_thread(Thread* t) { if (t->is_Java_thread()) {
JfrJavaEventWriter::notify(JavaThread::cast(t));
}
}
};
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.