8014534: Better profiling support
Validation of parameters Reviewed-by: sspitsyn, skoivu, mchung
This commit is contained in:
parent
3d9f33759d
commit
2051164993
@ -53,7 +53,10 @@ public class Tracker {
|
|||||||
|
|
||||||
public static void ObjectInit(Object obj)
|
public static void ObjectInit(Object obj)
|
||||||
{
|
{
|
||||||
if ( engaged != 0 ) {
|
if ( engaged != 0) {
|
||||||
|
if (obj == null) {
|
||||||
|
throw new IllegalArgumentException("Null object.");
|
||||||
|
}
|
||||||
nativeObjectInit(Thread.currentThread(), obj);
|
nativeObjectInit(Thread.currentThread(), obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +69,10 @@ public class Tracker {
|
|||||||
|
|
||||||
public static void NewArray(Object obj)
|
public static void NewArray(Object obj)
|
||||||
{
|
{
|
||||||
if ( engaged != 0 ) {
|
if ( engaged != 0) {
|
||||||
|
if (obj == null) {
|
||||||
|
throw new IllegalArgumentException("Null object.");
|
||||||
|
}
|
||||||
nativeNewArray(Thread.currentThread(), obj);
|
nativeNewArray(Thread.currentThread(), obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,6 +88,14 @@ public class Tracker {
|
|||||||
public static void CallSite(int cnum, int mnum)
|
public static void CallSite(int cnum, int mnum)
|
||||||
{
|
{
|
||||||
if ( engaged != 0 ) {
|
if ( engaged != 0 ) {
|
||||||
|
if (cnum < 0) {
|
||||||
|
throw new IllegalArgumentException("Negative class index");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mnum < 0) {
|
||||||
|
throw new IllegalArgumentException("Negative method index");
|
||||||
|
}
|
||||||
|
|
||||||
nativeCallSite(Thread.currentThread(), cnum, mnum);
|
nativeCallSite(Thread.currentThread(), cnum, mnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,6 +109,14 @@ public class Tracker {
|
|||||||
public static void ReturnSite(int cnum, int mnum)
|
public static void ReturnSite(int cnum, int mnum)
|
||||||
{
|
{
|
||||||
if ( engaged != 0 ) {
|
if ( engaged != 0 ) {
|
||||||
|
if (cnum < 0) {
|
||||||
|
throw new IllegalArgumentException("Negative class index");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mnum < 0) {
|
||||||
|
throw new IllegalArgumentException("Negative method index");
|
||||||
|
}
|
||||||
|
|
||||||
nativeReturnSite(Thread.currentThread(), cnum, mnum);
|
nativeReturnSite(Thread.currentThread(), cnum, mnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,12 @@ class_get_methodID(JNIEnv *env, ClassIndex index, MethodIndex mnum)
|
|||||||
jmethodID method;
|
jmethodID method;
|
||||||
|
|
||||||
info = get_info(index);
|
info = get_info(index);
|
||||||
HPROF_ASSERT(mnum < info->method_count);
|
if (mnum >= info->method_count) {
|
||||||
|
jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
|
||||||
|
(*env)->ThrowNew(env, newExcCls, "Illegal mnum");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
method = info->method[mnum].method_id;
|
method = info->method[mnum].method_id;
|
||||||
if ( method == NULL ) {
|
if ( method == NULL ) {
|
||||||
char * name;
|
char * name;
|
||||||
@ -535,7 +540,12 @@ class_get_methodID(JNIEnv *env, ClassIndex index, MethodIndex mnum)
|
|||||||
jclass clazz;
|
jclass clazz;
|
||||||
|
|
||||||
name = (char *)string_get(info->method[mnum].name_index);
|
name = (char *)string_get(info->method[mnum].name_index);
|
||||||
HPROF_ASSERT(name!=NULL);
|
if (name==NULL) {
|
||||||
|
jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
|
||||||
|
(*env)->ThrowNew(env, newExcCls, "Name not found");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
sig = (char *)string_get(info->method[mnum].sig_index);
|
sig = (char *)string_get(info->method[mnum].sig_index);
|
||||||
HPROF_ASSERT(sig!=NULL);
|
HPROF_ASSERT(sig!=NULL);
|
||||||
clazz = class_get_class(env, index);
|
clazz = class_get_class(env, index);
|
||||||
|
@ -195,7 +195,12 @@ event_call(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
|
|||||||
|
|
||||||
HPROF_ASSERT(env!=NULL);
|
HPROF_ASSERT(env!=NULL);
|
||||||
HPROF_ASSERT(thread!=NULL);
|
HPROF_ASSERT(thread!=NULL);
|
||||||
HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
|
if (cnum == 0 || cnum == gdata->tracker_cnum) {
|
||||||
|
jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
|
||||||
|
(*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Prevent recursion into any BCI function for this thread (pstatus). */
|
/* Prevent recursion into any BCI function for this thread (pstatus). */
|
||||||
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
|
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
|
||||||
@ -204,8 +209,10 @@ event_call(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
|
|||||||
|
|
||||||
(*pstatus) = 1;
|
(*pstatus) = 1;
|
||||||
method = class_get_methodID(env, cnum, mnum);
|
method = class_get_methodID(env, cnum, mnum);
|
||||||
HPROF_ASSERT(method!=NULL);
|
if (method != NULL) {
|
||||||
tls_push_method(tls_index, method);
|
tls_push_method(tls_index, method);
|
||||||
|
}
|
||||||
|
|
||||||
(*pstatus) = 0;
|
(*pstatus) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,7 +255,13 @@ event_return(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
|
|||||||
|
|
||||||
HPROF_ASSERT(env!=NULL);
|
HPROF_ASSERT(env!=NULL);
|
||||||
HPROF_ASSERT(thread!=NULL);
|
HPROF_ASSERT(thread!=NULL);
|
||||||
HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
|
|
||||||
|
if (cnum == 0 || cnum == gdata->tracker_cnum) {
|
||||||
|
jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
|
||||||
|
(*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Prevent recursion into any BCI function for this thread (pstatus). */
|
/* Prevent recursion into any BCI function for this thread (pstatus). */
|
||||||
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
|
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
|
||||||
@ -257,8 +270,10 @@ event_return(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
|
|||||||
|
|
||||||
(*pstatus) = 1;
|
(*pstatus) = 1;
|
||||||
method = class_get_methodID(env, cnum, mnum);
|
method = class_get_methodID(env, cnum, mnum);
|
||||||
HPROF_ASSERT(method!=NULL);
|
if (method != NULL) {
|
||||||
tls_pop_method(tls_index, thread, method);
|
tls_pop_method(tls_index, thread, method);
|
||||||
|
}
|
||||||
|
|
||||||
(*pstatus) = 0;
|
(*pstatus) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user