< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page
rev 55759 : 8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
Summary: Check JvmtiExport::_field_access_count != 0 at runtime
Reviewed-by:


3759 };
3760 
3761 
3762 // For jvmti use to modify jni function table.
3763 // Java threads in native contiues to run until it is transitioned
3764 // to VM at safepoint. Before the transition or before it is blocked
3765 // for safepoint it may access jni function table. VM could crash if
3766 // any java thread access the jni function table in the middle of memcpy.
3767 // To avoid this each function pointers are copied automically.
3768 void copy_jni_function_table(const struct JNINativeInterface_ *new_jni_NativeInterface) {
3769   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
3770   intptr_t *a = (intptr_t *) jni_functions();
3771   intptr_t *b = (intptr_t *) new_jni_NativeInterface;
3772   for (uint i=0; i <  sizeof(struct JNINativeInterface_)/sizeof(void *); i++) {
3773     Atomic::store(*b++, a++);
3774   }
3775 }
3776 
3777 void quicken_jni_functions() {
3778   // Replace Get<Primitive>Field with fast versions
3779   if (UseFastJNIAccessors && !JvmtiExport::can_post_field_access()
3780       && !VerifyJNIFields && !CountJNICalls && !CheckJNICalls) {
3781     address func;
3782     func = JNI_FastGetField::generate_fast_get_boolean_field();
3783     if (func != (address)-1) {
3784       jni_NativeInterface.GetBooleanField = (GetBooleanField_t)func;
3785     }
3786     func = JNI_FastGetField::generate_fast_get_byte_field();
3787     if (func != (address)-1) {
3788       jni_NativeInterface.GetByteField = (GetByteField_t)func;
3789     }
3790     func = JNI_FastGetField::generate_fast_get_char_field();
3791     if (func != (address)-1) {
3792       jni_NativeInterface.GetCharField = (GetCharField_t)func;
3793     }
3794     func = JNI_FastGetField::generate_fast_get_short_field();
3795     if (func != (address)-1) {
3796       jni_NativeInterface.GetShortField = (GetShortField_t)func;
3797     }
3798     func = JNI_FastGetField::generate_fast_get_int_field();
3799     if (func != (address)-1) {
3800       jni_NativeInterface.GetIntField = (GetIntField_t)func;




3759 };
3760 
3761 
3762 // For jvmti use to modify jni function table.
3763 // Java threads in native contiues to run until it is transitioned
3764 // to VM at safepoint. Before the transition or before it is blocked
3765 // for safepoint it may access jni function table. VM could crash if
3766 // any java thread access the jni function table in the middle of memcpy.
3767 // To avoid this each function pointers are copied automically.
3768 void copy_jni_function_table(const struct JNINativeInterface_ *new_jni_NativeInterface) {
3769   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
3770   intptr_t *a = (intptr_t *) jni_functions();
3771   intptr_t *b = (intptr_t *) new_jni_NativeInterface;
3772   for (uint i=0; i <  sizeof(struct JNINativeInterface_)/sizeof(void *); i++) {
3773     Atomic::store(*b++, a++);
3774   }
3775 }
3776 
3777 void quicken_jni_functions() {
3778   // Replace Get<Primitive>Field with fast versions
3779   if (UseFastJNIAccessors && !VerifyJNIFields && !CountJNICalls && !CheckJNICalls) {

3780     address func;
3781     func = JNI_FastGetField::generate_fast_get_boolean_field();
3782     if (func != (address)-1) {
3783       jni_NativeInterface.GetBooleanField = (GetBooleanField_t)func;
3784     }
3785     func = JNI_FastGetField::generate_fast_get_byte_field();
3786     if (func != (address)-1) {
3787       jni_NativeInterface.GetByteField = (GetByteField_t)func;
3788     }
3789     func = JNI_FastGetField::generate_fast_get_char_field();
3790     if (func != (address)-1) {
3791       jni_NativeInterface.GetCharField = (GetCharField_t)func;
3792     }
3793     func = JNI_FastGetField::generate_fast_get_short_field();
3794     if (func != (address)-1) {
3795       jni_NativeInterface.GetShortField = (GetShortField_t)func;
3796     }
3797     func = JNI_FastGetField::generate_fast_get_int_field();
3798     if (func != (address)-1) {
3799       jni_NativeInterface.GetIntField = (GetIntField_t)func;


< prev index next >