src/hotspot/share/prims/jni.cpp
changeset 49466 6ce398fe53fd
parent 49449 ef5d5d343e2a
child 49594 898ef81cbc0e
equal deleted inserted replaced
49465:4881673579b7 49466:6ce398fe53fd
    34 #include "classfile/javaClasses.inline.hpp"
    34 #include "classfile/javaClasses.inline.hpp"
    35 #include "classfile/modules.hpp"
    35 #include "classfile/modules.hpp"
    36 #include "classfile/symbolTable.hpp"
    36 #include "classfile/symbolTable.hpp"
    37 #include "classfile/systemDictionary.hpp"
    37 #include "classfile/systemDictionary.hpp"
    38 #include "classfile/vmSymbols.hpp"
    38 #include "classfile/vmSymbols.hpp"
    39 #include "gc/shared/gcLocker.inline.hpp"
       
    40 #include "interpreter/linkResolver.hpp"
    39 #include "interpreter/linkResolver.hpp"
    41 #include "memory/allocation.hpp"
    40 #include "memory/allocation.hpp"
    42 #include "memory/allocation.inline.hpp"
    41 #include "memory/allocation.inline.hpp"
    43 #include "memory/oopFactory.hpp"
    42 #include "memory/oopFactory.hpp"
    44 #include "memory/resourceArea.hpp"
    43 #include "memory/resourceArea.hpp"
  3147 
  3146 
  3148 
  3147 
  3149 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy))
  3148 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy))
  3150   JNIWrapper("GetPrimitiveArrayCritical");
  3149   JNIWrapper("GetPrimitiveArrayCritical");
  3151  HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY(env, array, (uintptr_t *) isCopy);
  3150  HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY(env, array, (uintptr_t *) isCopy);
  3152   GCLocker::lock_critical(thread);
       
  3153   if (isCopy != NULL) {
  3151   if (isCopy != NULL) {
  3154     *isCopy = JNI_FALSE;
  3152     *isCopy = JNI_FALSE;
  3155   }
  3153   }
  3156   oop a = JNIHandles::resolve_non_null(array);
  3154   oop a = JNIHandles::resolve_non_null(array);
       
  3155   a = Universe::heap()->pin_object(thread, a);
  3157   assert(a->is_array(), "just checking");
  3156   assert(a->is_array(), "just checking");
  3158   BasicType type;
  3157   BasicType type;
  3159   if (a->is_objArray()) {
  3158   if (a->is_objArray()) {
  3160     type = T_OBJECT;
  3159     type = T_OBJECT;
  3161   } else {
  3160   } else {
  3168 
  3167 
  3169 
  3168 
  3170 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode))
  3169 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode))
  3171   JNIWrapper("ReleasePrimitiveArrayCritical");
  3170   JNIWrapper("ReleasePrimitiveArrayCritical");
  3172   HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(env, array, carray, mode);
  3171   HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(env, array, carray, mode);
  3173   // The array, carray and mode arguments are ignored
  3172   oop a = JNIHandles::resolve_non_null(array);
  3174   GCLocker::unlock_critical(thread);
  3173   Universe::heap()->unpin_object(thread, a);
  3175 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN();
  3174 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN();
  3176 JNI_END
  3175 JNI_END
  3177 
  3176 
  3178 
  3177 
  3179 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
  3178 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
  3180   JNIWrapper("GetStringCritical");
  3179   JNIWrapper("GetStringCritical");
  3181   HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy);
  3180   HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy);
  3182   GCLocker::lock_critical(thread);
       
  3183   oop s = JNIHandles::resolve_non_null(string);
  3181   oop s = JNIHandles::resolve_non_null(string);
       
  3182   s = Universe::heap()->pin_object(thread, s);
  3184   typeArrayOop s_value = java_lang_String::value(s);
  3183   typeArrayOop s_value = java_lang_String::value(s);
  3185   bool is_latin1 = java_lang_String::is_latin1(s);
  3184   bool is_latin1 = java_lang_String::is_latin1(s);
  3186   if (isCopy != NULL) {
  3185   if (isCopy != NULL) {
  3187     *isCopy = is_latin1 ? JNI_TRUE : JNI_FALSE;
  3186     *isCopy = is_latin1 ? JNI_TRUE : JNI_FALSE;
  3188   }
  3187   }
  3215   if (is_latin1) {
  3214   if (is_latin1) {
  3216     // For latin1 string, free jchar array allocated by earlier call to GetStringCritical.
  3215     // For latin1 string, free jchar array allocated by earlier call to GetStringCritical.
  3217     // This assumes that ReleaseStringCritical bookends GetStringCritical.
  3216     // This assumes that ReleaseStringCritical bookends GetStringCritical.
  3218     FREE_C_HEAP_ARRAY(jchar, chars);
  3217     FREE_C_HEAP_ARRAY(jchar, chars);
  3219   }
  3218   }
  3220   GCLocker::unlock_critical(thread);
  3219   Universe::heap()->unpin_object(thread, s);
  3221 HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN();
  3220 HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN();
  3222 JNI_END
  3221 JNI_END
  3223 
  3222 
  3224 
  3223 
  3225 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref))
  3224 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref))