/* * Copyright (c) 1998, 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. *
*/
// Must be included after jvmti.h. #include"jvmticmlr.h"
// Forward declarations
struct JvmtiCachedClassFileData; class JvmtiEventControllerPrivate; class JvmtiManageCapabilities; class JvmtiEnv; class JvmtiThreadState; class OopStorage; class ThreadsList;
// This class contains the JVMTI interface for the rest of hotspot. // class JvmtiExport : public AllStatic { friendclass VMStructs; friendclass CompileReplay;
JVMTI_SUPPORT_FLAG(early_vmstart_recorded)
JVMTI_SUPPORT_FLAG(can_get_owned_monitor_info) // includes can_get_owned_monitor_stack_depth_info
friendclass JvmtiEventControllerPrivate; // should only modify these flags
JVMTI_SUPPORT_FLAG(should_post_single_step)
JVMTI_SUPPORT_FLAG(should_post_field_access)
JVMTI_SUPPORT_FLAG(should_post_field_modification)
JVMTI_SUPPORT_FLAG(should_post_class_load)
JVMTI_SUPPORT_FLAG(should_post_class_prepare)
JVMTI_SUPPORT_FLAG(should_post_class_unload)
JVMTI_SUPPORT_FLAG(should_post_native_method_bind)
JVMTI_SUPPORT_FLAG(should_post_compiled_method_load)
JVMTI_SUPPORT_FLAG(should_post_compiled_method_unload)
JVMTI_SUPPORT_FLAG(should_post_dynamic_code_generated)
JVMTI_SUPPORT_FLAG(should_post_monitor_contended_enter)
JVMTI_SUPPORT_FLAG(should_post_monitor_contended_entered)
JVMTI_SUPPORT_FLAG(should_post_monitor_wait)
JVMTI_SUPPORT_FLAG(should_post_monitor_waited)
JVMTI_SUPPORT_FLAG(should_post_data_dump)
JVMTI_SUPPORT_FLAG(should_post_garbage_collection_start)
JVMTI_SUPPORT_FLAG(should_post_garbage_collection_finish)
JVMTI_SUPPORT_FLAG(should_post_on_exceptions)
// ------ the below maybe don't have to be (but are for now) // fixed conditions here ------------ // any events can be enabled
JVMTI_SUPPORT_FLAG(should_post_thread_life)
JVMTI_SUPPORT_FLAG(should_post_object_free)
JVMTI_SUPPORT_FLAG(should_post_resource_exhausted)
// we are holding objects on the heap - need to talk to GC - e.g. // breakpoint info
JVMTI_SUPPORT_FLAG(should_clean_up_heap_objects)
JVMTI_SUPPORT_FLAG(should_post_vm_object_alloc)
JVMTI_SUPPORT_FLAG(should_post_sampled_object_alloc)
// If flag cannot be implemented, give an error if on=true staticvoid report_unsupported(bool on);
// these should only be called by the friend class friendclass JvmtiManageCapabilities; inlinestaticvoid set_can_modify_any_class(bool on) {
JVMTI_ONLY(_can_modify_any_class = (on != 0);)
} inlinestaticvoid set_can_access_local_variables(bool on) {
JVMTI_ONLY(_can_access_local_variables = (on != 0);)
} inlinestaticvoid set_can_hotswap_or_post_breakpoint(bool on) {
JVMTI_ONLY(_can_hotswap_or_post_breakpoint = (on != 0);)
} inlinestaticvoid set_can_walk_any_space(bool on) {
JVMTI_ONLY(_can_walk_any_space = (on != 0);)
}
// posts a DynamicCodeGenerated event (internal/private implementation). // The public post_dynamic_code_generated* functions make use of the // internal implementation. Also called from JvmtiDeferredEvent::post() staticvoid post_dynamic_code_generated_internal(constchar *name, constvoid *code_begin, constvoid *code_end) NOT_JVMTI_RETURN;
// GenerateEvents support to allow posting of CompiledMethodLoad and // DynamicCodeGenerated events for a given environment. friendclass JvmtiCodeBlobEvents;
// This flag indicates whether RedefineClasses() has ever redefined // one or more classes during the lifetime of the VM. The flag should // only be set by the friend class and can be queried by other sub // systems as needed to relax invariant checks. static uint64_t _redefinition_count; friendclass VM_RedefineClasses; inlinestaticvoid increment_redefinition_count() {
JVMTI_ONLY(_redefinition_count++;)
} // Flag to indicate if the compiler has recorded all dependencies. When the // can_redefine_classes capability is enabled in the OnLoad phase then the compiler // records all dependencies from startup. However if the capability is first // enabled some time later then the dependencies recorded by the compiler // are incomplete. This flag is used by RedefineClasses to know if the // dependency information is complete or not. staticbool _all_dependencies_are_recorded;
// Only set in safepoint, so no memory ordering needed. inlinestatic uint64_t redefinition_count() {
JVMTI_ONLY(return _redefinition_count);
NOT_JVMTI(return 0);
}
inlinestaticvoid set_all_dependencies_are_recorded(bool on) {
_all_dependencies_are_recorded = (on != 0);
}
// Add read edges to the unnamed modules of the bootstrap and app class loaders staticvoid add_default_read_edges(Handle h_module, TRAPS) NOT_JVMTI_RETURN;
// Add a read edge to the module static jvmtiError add_module_reads(Handle module, Handle to_module, TRAPS);
// Updates a module to export a package static jvmtiError add_module_exports(Handle module, Handle pkg_name, Handle to_module, TRAPS);
// Updates a module to open a package static jvmtiError add_module_opens(Handle module, Handle pkg_name, Handle to_module, TRAPS);
// Add a used service to the module static jvmtiError add_module_uses(Handle module, Handle service, TRAPS);
// Add a service provider to the module static jvmtiError add_module_provides(Handle module, Handle service, Handle impl_class, TRAPS);
// let JVMTI know that the JVM_OnLoad code is running staticvoid enter_onload_phase() NOT_JVMTI_RETURN;
// let JVMTI know that the VM isn't up yet (and JVM_OnLoad code isn't running) staticvoid enter_primordial_phase() NOT_JVMTI_RETURN;
// let JVMTI know that the VM isn't up yet but JNI is live staticvoid enter_early_start_phase() NOT_JVMTI_RETURN; staticvoid enter_start_phase() NOT_JVMTI_RETURN;
// let JVMTI know that the VM is fully up and running now staticvoid enter_live_phase() NOT_JVMTI_RETURN;
// ------ can_* conditions (below) are set at OnLoad and never changed ------------ inlinestaticbool can_modify_any_class() {
JVMTI_ONLY(return _can_modify_any_class);
NOT_JVMTI(returnfalse);
} inlinestaticbool can_access_local_variables() {
JVMTI_ONLY(return _can_access_local_variables);
NOT_JVMTI(returnfalse);
} inlinestaticbool can_hotswap_or_post_breakpoint() {
JVMTI_ONLY(return _can_hotswap_or_post_breakpoint);
NOT_JVMTI(returnfalse);
} inlinestaticbool can_walk_any_space() {
JVMTI_ONLY(return _can_walk_any_space);
NOT_JVMTI(returnfalse);
}
// field access management static address get_field_access_count_addr() NOT_JVMTI_RETURN_(0);
// field modification management static address get_field_modification_count_addr() NOT_JVMTI_RETURN_(0);
// Methods that notify the debugger that something interesting has happened in the VM. staticvoid post_early_vm_start () NOT_JVMTI_RETURN; staticvoid post_vm_start () NOT_JVMTI_RETURN; staticvoid post_vm_initialized () NOT_JVMTI_RETURN; staticvoid post_vm_death () NOT_JVMTI_RETURN;
// Support for java.lang.instrument agent loading. staticbool _should_post_class_file_load_hook; inlinestaticvoid set_should_post_class_file_load_hook(bool on) { _should_post_class_file_load_hook = on; } inlinestaticbool should_post_class_file_load_hook() {
JVMTI_ONLY(return _should_post_class_file_load_hook);
NOT_JVMTI(returnfalse;)
} staticbool is_early_phase() NOT_JVMTI_RETURN_(false); staticbool has_early_class_hook_env() NOT_JVMTI_RETURN_(false); // Return true if the class was modified by the hook. staticbool post_class_file_load_hook(Symbol* h_name, Handle class_loader,
Handle h_protection_domain, unsignedchar **data_ptr, unsignedchar **end_ptr,
JvmtiCachedClassFileData **cache_ptr) NOT_JVMTI_RETURN_(false); staticvoid post_native_method_bind(Method* method, address* function_ptr) NOT_JVMTI_RETURN; staticvoid post_compiled_method_load(JvmtiEnv* env, nmethod *nm) NOT_JVMTI_RETURN; staticvoid post_compiled_method_load(nmethod *nm) NOT_JVMTI_RETURN; staticvoid post_dynamic_code_generated(constchar *name, constvoid *code_begin, constvoid *code_end) NOT_JVMTI_RETURN;
// used to post a CompiledMethodUnload event staticvoid post_compiled_method_unload(jmethodID mid, constvoid *code_begin) NOT_JVMTI_RETURN;
// similar to post_dynamic_code_generated except that it can be used to // post a DynamicCodeGenerated event while holding locks in the VM. Any event // posted using this function is recorded by the enclosing event collector // -- JvmtiDynamicCodeEventCollector. staticvoid post_dynamic_code_generated_while_holding_locks(constchar* name, address code_begin, address code_end) NOT_JVMTI_RETURN;
staticvoid record_sampled_internal_object_allocation(oop object) NOT_JVMTI_RETURN; // Post objects collected by sampled_object_alloc_event_collector. staticvoid post_sampled_object_alloc(JavaThread *thread, oop object) NOT_JVMTI_RETURN;
// Collects vm internal objects for later event posting. inlinestaticvoid sampled_object_alloc_event_collector(oop object) { if (should_post_sampled_object_alloc()) {
record_sampled_internal_object_allocation(object);
}
}
inlinestaticvoid post_array_size_exhausted() { if (should_post_resource_exhausted()) {
post_resource_exhausted(JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, "Requested array size exceeds VM limit");
}
}
// Support class used by JvmtiDynamicCodeEventCollector and others. It // describes a single code blob by name and address range. class JvmtiCodeBlobDesc : public CHeapObj<mtInternal> { private: char _name[64];
address _code_begin;
address _code_end;
// JvmtiEventCollector is a helper class to setup thread for // event collection. class JvmtiEventCollector : public StackObj { private:
JvmtiEventCollector* _prev; // Save previous one to support nested event collector. bool _unset_jvmti_thread_state;
void setup_jvmti_thread_state(); // Set this collector in current thread, returns if success. void unset_jvmti_thread_state(); // Reset previous collector in current thread. virtualbool is_dynamic_code_event() { returnfalse; } virtualbool is_vm_object_alloc_event(){ returnfalse; } virtualbool is_sampled_object_alloc_event(){ returnfalse; }
JvmtiEventCollector *get_prev() { return _prev; }
};
// A JvmtiDynamicCodeEventCollector is a helper class for the JvmtiExport // interface. It collects "dynamic code generated" events that are posted // while holding locks. When the event collector goes out of scope the // events will be posted. // // Usage :- // // { // JvmtiDynamicCodeEventCollector event_collector; // : // { MutexLocker ml(...) // : // JvmtiExport::post_dynamic_code_generated_while_holding_locks(...) // } // // event collector goes out of scope => post events to profiler. // }
class JvmtiDynamicCodeEventCollector : public JvmtiEventCollector { private:
GrowableArray<JvmtiCodeBlobDesc*>* _code_blobs; // collected code blob events
// Used as a base class for object allocation collection and then posting // the allocations to any event notification callbacks. // class JvmtiObjectAllocEventCollector : public JvmtiEventCollector { protected:
GrowableArray<OopHandle>* _allocated; // field to record collected allocated object oop. bool _enable; // This flag is enabled in constructor if set up in the thread state // and disabled in destructor before posting event. To avoid // collection of objects allocated while running java code inside // agent post_X_object_alloc() event handler. void (*_post_callback)(JavaThread*, oop); // what callback to use when destroying the collector.
friendclass JvmtiExport;
// Record allocated object oop. inlinevoid record_allocation(oop obj);
// Used to record vm internally allocated object oops and post // vm object alloc event for objects visible to java world. // Constructor enables JvmtiThreadState flag and all vm allocated // objects are recorded in a growable array. When destructor is // called the vm object alloc event is posted for each object // visible to java world. // See jvm.cpp file for its usage. // class JvmtiVMObjectAllocEventCollector : public JvmtiObjectAllocEventCollector { public:
JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN;
~JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN; virtualbool is_vm_object_alloc_event() { returntrue; }
};
// Used to record sampled allocated object oops and post // sampled object alloc event. // Constructor enables JvmtiThreadState flag and all sampled allocated // objects are recorded in a growable array. When destructor is // called the sampled object alloc event is posted for each sampled object. // See jvm.cpp file for its usage. // class JvmtiSampledObjectAllocEventCollector : public JvmtiObjectAllocEventCollector { public:
JvmtiSampledObjectAllocEventCollector(bool should_start = true) {
JVMTI_ONLY(if (should_start) start();)
}
~JvmtiSampledObjectAllocEventCollector() NOT_JVMTI_RETURN; bool is_sampled_object_alloc_event() { returntrue; } void start() NOT_JVMTI_RETURN; staticbool object_alloc_is_safe_to_sample() NOT_JVMTI_RETURN_(false);
};
// Marker class to disable the posting of VMObjectAlloc events // within its scope. // // Usage :- // // { // NoJvmtiVMObjectAllocMark njm; // : // // VMObjAlloc event will not be posted // JvmtiExport::vm_object_alloc_event_collector(obj); // : // }
class NoJvmtiVMObjectAllocMark : public StackObj { private: // enclosing collector if enabled, NULL otherwise
JvmtiVMObjectAllocEventCollector *_collector;
// Base class for reporting GC events to JVMTI. class JvmtiGCMarker : public StackObj { public:
JvmtiGCMarker() NOT_JVMTI_RETURN;
~JvmtiGCMarker() NOT_JVMTI_RETURN;
};
// JvmtiHideSingleStepping is a helper class for hiding // internal single step events. class JvmtiHideSingleStepping : public StackObj { private: bool _single_step_hidden;
JavaThread * _thread;
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.