/* * Copyright (c) 2003, 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. *
*/
bool use_version_1_0_semantics(); // agent asked for version 1.0 bool use_version_1_1_semantics(); // agent asked for version 1.1 bool use_version_1_2_semantics(); // agent asked for version 1.2
// If (thread == NULL) then return current thread object. // Otherwise return JNIHandles::resolve_external_guard(thread). static oop current_thread_obj_or_resolve_external_guard(jthread thread);
// Return true if the thread identified with a pair <jt,thr_obj> is current. // A passive carrier thread is not treated as current. staticbool is_JavaThread_current(JavaThread* jt, oop thr_obj) {
JavaThread* current = JavaThread::current(); // jt can be NULL in case of a virtual thread if (jt == NULL || jt != current) { returnfalse;
}
oop cur_obj = current->jvmti_vthread();
// cur_obj == NULL is true for normal platform threads only // otherwise it can be virtual or carrier thread. return cur_obj == NULL || cur_obj == thr_obj;
}
// If there is a virtual thread mounted on the JavaThread* then // return virtual thread oop. Otherwise, return thread oop. static oop get_vthread_or_thread_oop(JavaThread* jt) {
oop result = jt->threadObj(); if (jt->jvmti_vthread() != NULL) {
result = jt->jvmti_vthread();
} return result;
}
// Return true if java thread is a carrier thread with a mounted virtual thread. staticbool is_cthread_with_mounted_vthread(JavaThread* jt); staticbool is_cthread_with_continuation(JavaThread* jt);
// This test will answer true when all environments have been disposed and some have // not yet been deallocated. As a result, this test should only be used as an // optimization for the no environment case. staticbool environments_might_exist() { return head_environment() != NULL;
}
// Memory functions unsignedchar* jvmtiMalloc(jlong size); // don't use this - call allocate
// method to create a local handle
jobject jni_reference(Handle hndl);
// method to create a local handle. // This function allows caller to specify which // threads local handle table to use.
jobject jni_reference(JavaThread *thread, Handle hndl);
// method to destroy a local handle void destroy_jni_reference(jobject jobj);
// method to destroy a local handle. // This function allows caller to specify which // threads local handle table to use. void destroy_jni_reference(JavaThread *thread, jobject jobj);
// return true if event is enabled globally or for any thread // True only if there is a callback for it. bool is_enabled(jvmtiEvent event_type) { return _env_event_enable.is_enabled(event_type);
}
// Random Utilities
protected: // helper methods for creating arrays of global JNI Handles from local Handles // allocated into environment specific storage
jthread * new_jthreadArray(int length, Handle *handles);
jthreadGroup * new_jthreadGroupArray(int length, objArrayHandle groups);
// convert to a jni jclass from a non-null Klass*
jclass get_jni_class_non_null(Klass* k);
// check if virtual thread is not terminated (alive) staticbool is_vthread_alive(oop vt);
// return JavaThread if virtual thread is mounted, NULL otherwise static JavaThread* get_JavaThread_or_null(oop vthread);
// get virtual thread last java vframe static javaVFrame* get_vthread_jvf(oop vthread);
// get carrier thread last java vframe static javaVFrame* get_cthread_last_java_vframe(JavaThread* jt, RegisterMap* reg_map);
// get ordinary thread thread state static jint get_thread_state(oop thread_oop, JavaThread* jt);
// get virtual thread thread state static jint get_vthread_state(oop thread_oop, JavaThread* jt);
// enumerates the live threads in the given thread group static jvmtiError get_live_threads(JavaThread* current_thread, Handle group_hdl, jint *count_ptr, Handle **thread_objs_p);
// enumerates the subgroups in the given thread group static jvmtiError get_subgroups(JavaThread* current_thread, Handle group_hdl, jint *count_ptr, objArrayHandle *group_objs_p);
// This class is the only safe means of iterating through environments. // Note that this iteratation includes invalid environments pending // deallocation -- in fact, some uses depend on this behavior.
class JvmtiEnvIterator : public StackObj { private: bool _entry_was_marked; public:
JvmtiEnvIterator() { if (Threads::number_of_threads() == 0) {
_entry_was_marked = false; // we are single-threaded, no need
} else {
Thread::current()->entering_jvmti_env_iteration();
_entry_was_marked = true;
}
}
~JvmtiEnvIterator() { if (_entry_was_marked) {
Thread::current()->leaving_jvmti_env_iteration();
}
}
JvmtiEnv* first() { return JvmtiEnvBase::head_environment(); }
JvmtiEnv* next(JvmtiEnvBase* env) { return env->next_environment(); }
};
// HandshakeClosure to set frame pop. class SetFramePopClosure : public JvmtiHandshakeClosure { private:
JvmtiEnv *_env;
JvmtiThreadState* _state;
jint _depth;
// HandshakeClosure to get monitor information with stack depth. class GetOwnedMonitorInfoClosure : public JvmtiHandshakeClosure { private:
JavaThread* _calling_thread;
JvmtiEnv *_env;
GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
// VM operation to get object monitor usage. class VM_GetObjectMonitorUsage : public VM_Operation { private:
JvmtiEnv *_env;
jobject _object;
JavaThread* _calling_thread;
jvmtiMonitorUsage* _info_ptr;
jvmtiError _result;
// HandshakeClosure to get current contended monitor. It is used for both platform and virtual threads. class GetCurrentContendedMonitorClosure : public JvmtiHandshakeClosure { private:
JavaThread *_calling_thread;
JvmtiEnv *_env;
jobject *_owned_monitor_ptr; bool _is_virtual;
#ifdef ASSERT // HandshakeClosure to print stack trace in JvmtiVTMSTransitionDisabler error handling. class PrintStackTraceClosure : public HandshakeClosure { public: staticvoid do_thread_impl(Thread *target);
// Get stack trace at safepoint or at direct handshake. class MultipleStackTracesCollector { private: friendclass VM_GetThreadListStackTraces;
JvmtiEnv *_env;
jint _max_frame_count;
jvmtiStackInfo *_stack_info;
jvmtiError _result; int _frame_count_total; struct StackInfoNode *_head;
// VM operation to get stack trace at safepoint. class VM_GetAllStackTraces : public VM_Operation { private:
JavaThread *_calling_thread;
jint _final_thread_count;
MultipleStackTracesCollector _collector;
// VM operation to get stack trace at safepoint. class VM_GetThreadListStackTraces : public VM_Operation { private:
jint _thread_count; const jthread* _thread_list;
MultipleStackTracesCollector _collector;
// HandshakeClosure to get single stack trace. class GetSingleStackTraceClosure : public HandshakeClosure { private:
JavaThread *_calling_thread;
jthread _jthread;
MultipleStackTracesCollector _collector;
// HandshakeClosure to get virtual thread monitor information with stack depth. class VirtualThreadGetOwnedMonitorInfoClosure : public HandshakeClosure { private:
JvmtiEnv *_env;
Handle _vthread_h;
GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
jvmtiError _result;
// HandshakeClosure to get virtual thread thread at safepoint. class VirtualThreadGetThreadClosure : public HandshakeClosure { private:
Handle _vthread_h;
jthread* _carrier_thread_ptr;
jvmtiError _result;
// HandshakeClosure to get virtual thread state at safepoint. class VirtualThreadGetThreadStateClosure : public HandshakeClosure { private:
Handle _vthread_h;
jint *_state_ptr;
jvmtiError _result;
// HandshakeClosure to set frame pop for a virtual thread. class VirtualThreadSetFramePopClosure : public JvmtiHandshakeClosure { private:
JvmtiEnv *_env;
Handle _vthread_h;
JvmtiThreadState* _state;
jint _depth;
// ResourceTracker // // ResourceTracker works a little like a ResourceMark. All allocates // using the resource tracker are recorded. If an allocate using the // resource tracker fails the destructor will free any resources // that were allocated using the tracker. // The motive for this class is to avoid messy error recovery code // in situations where multiple allocations are done in sequence. If // the second or subsequent allocation fails it avoids any code to // release memory allocated in the previous calls. // // Usage :- // ResourceTracker rt(env); // : // err = rt.allocate(1024, &ptr);
// Jvmti module closure to collect all modules loaded to the system. class JvmtiModuleClosure : public StackObj { private: static GrowableArray<OopHandle> *_tbl; // Protected with Module_lock
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.