jvmtiEnvBase.hpp revision 3863
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#ifndef SHARE_VM_PRIMS_JVMTIENVBASE_HPP
#define SHARE_VM_PRIMS_JVMTIENVBASE_HPP
#include "classfile/classLoader.hpp"
#include "prims/jvmtiEnvThreadState.hpp"
#include "prims/jvmtiEventController.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "runtime/fieldDescriptor.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/thread.hpp"
#include "runtime/vm_operations.hpp"
#include "utilities/growableArray.hpp"
//
// Forward Declarations
//
class JvmtiEnv;
class JvmtiThreadState;
class JvmtiRawMonitor; // for jvmtiEnv.hpp
class JvmtiEventControllerPrivate;
class JvmtiTagMap;
// One JvmtiEnv object is created per jvmti attachment;
// done via JNI GetEnv() call. Multiple attachments are
// allowed in jvmti.
private:
static bool _globally_initialized;
static jvmtiPhase _phase;
static volatile int _dying_thread_env_iteration_count;
public:
enum {
};
static void entering_dying_thread_env_iteration() { ++_dying_thread_env_iteration_count; }
static void leaving_dying_thread_env_iteration() { --_dying_thread_env_iteration_count; }
static bool is_inside_dying_thread_env_iteration(){ return _dying_thread_env_iteration_count > 0; }
private:
enum {
JVMTI_MAGIC = 0x71EE,
DISPOSED_MAGIC = 0xDEFC,
BAD_MAGIC = 0xDEAD
};
bool _is_retransformable;
const void *_env_local_storage; // per env agent allocated data.
volatile bool _class_file_load_hook_ever_enabled;
static volatile bool _needs_clean_up;
char** _native_method_prefixes;
protected:
~JvmtiEnvBase();
void dispose();
void env_dispose();
const void* get_env_local_storage() { return _env_local_storage; }
char** get_native_method_prefixes() { return _native_method_prefixes; }
int get_native_method_prefix_count() { return _native_method_prefix_count; }
private:
friend class JvmtiEventControllerPrivate;
void initialize();
static void globally_initialize();
static void periodic_clean_up();
friend class JvmtiEnvIterator;
public:
bool is_valid();
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
bool is_retransformable() { return _is_retransformable; }
static ByteSize jvmti_external_offset() {
};
};
static char** get_all_native_method_prefixes(int* count_ptr);
// 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.
static bool environments_might_exist() {
return head_environment() != NULL;
}
static void check_for_periodic_clean_up();
return &_env_event_enable;
}
if (size < 0) {
return JVMTI_ERROR_ILLEGAL_ARGUMENT;
}
if (size == 0) {
} else {
return JVMTI_ERROR_OUT_OF_MEMORY;
}
}
return JVMTI_ERROR_NONE;
}
}
return JVMTI_ERROR_NONE;
}
// Memory functions
// method to create a local handle
}
// method to create a local handle.
// This function allows caller to specify which
// threads local handle table to use.
}
// method to destroy a local handle
}
// method to destroy a local handle.
// This function allows caller to specify which
// threads local handle table to use although currently it is
// not used.
}
// Event Dispatch
}
return &_event_callbacks;
}
return &_ext_event_callbacks;
}
}
JvmtiTagMap* tag_map() {
return _tag_map;
}
// return true if event is enabled globally or for any thread
// True only if there is a callback for it.
}
// Random Utilities
protected:
// helper methods for creating arrays of global JNI Handles from local Handles
// allocated into environment specific storage
// convert from JNIHandle to JavaThread *
// convert to a jni jclass from a non-null klassOop
public:
// get a field descriptor for the specified class and field
// test for suspend - most (all?) of these should go away
bool wait_for_suspend,
// JVMTI API helper functions which are called at safepoint or thread is suspended.
};
// 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 {
_entry_was_marked = true;
}
}
~JvmtiEnvIterator() {
if (_entry_was_marked) {
}
}
};
// VM operation to get monitor information with stack depth.
class VM_GetOwnedMonitorInfo : public VM_Operation {
private:
public:
}
void doit() {
}
};
// VM operation to get object monitor usage.
class VM_GetObjectMonitorUsage : public VM_Operation {
private:
public:
VM_GetObjectMonitorUsage(JvmtiEnv *env, JavaThread* calling_thread, jobject object, jvmtiMonitorUsage* info_ptr) {
}
void doit() {
}
};
// VM operation to get current contended monitor.
class VM_GetCurrentContendedMonitor : public VM_Operation {
private:
public:
VM_GetCurrentContendedMonitor(JvmtiEnv *env, JavaThread *calling_thread, JavaThread *java_thread, jobject *mon_ptr) {
}
void doit() {
_result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,_java_thread,_owned_monitor_ptr);
}
};
// VM operation to get stack trace at safepoint.
class VM_GetStackTrace : public VM_Operation {
private:
public:
}
void doit() {
}
};
// forward declaration
struct StackInfoNode;
// VM operation to get stack trace at safepoint.
class VM_GetMultipleStackTraces : public VM_Operation {
private:
int _frame_count_total;
struct StackInfoNode *_head;
protected:
public:
_frame_count_total = 0;
}
};
// VM operation to get stack trace at safepoint.
class VM_GetAllStackTraces : public VM_GetMultipleStackTraces {
private:
public:
}
void doit();
};
// VM operation to get stack trace at safepoint.
class VM_GetThreadListStackTraces : public VM_GetMultipleStackTraces {
private:
const jthread* _thread_list;
public:
VM_GetThreadListStackTraces(JvmtiEnv *env, jint thread_count, const jthread* thread_list, jint max_frame_count)
}
void doit();
};
// VM operation to count stack frames at safepoint.
class VM_GetFrameCount : public VM_Operation {
private:
public:
}
void doit() {
}
};
// VM operation to frame location at safepoint.
class VM_GetFrameLocation : public VM_Operation {
private:
public:
}
void doit() {
}
};
// 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);
class ResourceTracker : public StackObj {
private:
GrowableArray<unsigned char*> *_allocations;
bool _failed;
public:
~ResourceTracker();
};
// Jvmti monitor closure to collect off stack monitors.
class JvmtiMonitorClosure: public MonitorClosure {
private:
public:
JvmtiEnvBase *env) {
}
};
#endif // SHARE_VM_PRIMS_JVMTIENVBASE_HPP