< prev index next >

src/hotspot/share/runtime/jniHandles.inline.hpp

Print this page
rev 50745 : imported patch remove_in_concurrent_root


  40 inline oop* JNIHandles::jobject_ptr(jobject handle) {
  41   assert(!is_jweak(handle), "precondition");
  42   return reinterpret_cast<oop*>(handle);
  43 }
  44 
  45 inline oop* JNIHandles::jweak_ptr(jobject handle) {
  46   assert(is_jweak(handle), "precondition");
  47   char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
  48   return reinterpret_cast<oop*>(ptr);
  49 }
  50 
  51 // external_guard is true if called from resolve_external_guard.
  52 template<bool external_guard>
  53 inline oop JNIHandles::resolve_impl(jobject handle) {
  54   assert(handle != NULL, "precondition");
  55   assert(!current_thread_in_native(), "must not be in native");
  56   oop result;
  57   if (is_jweak(handle)) {       // Unlikely
  58     result = resolve_jweak(handle);
  59   } else {
  60     result = NativeAccess<IN_CONCURRENT_ROOT>::oop_load(jobject_ptr(handle));
  61     // Construction of jobjects canonicalize a null value into a null
  62     // jobject, so for non-jweak the pointee should never be null.
  63     assert(external_guard || result != NULL, "Invalid JNI handle");
  64   }
  65   return result;
  66 }
  67 
  68 inline oop JNIHandles::resolve(jobject handle) {
  69   oop result = NULL;
  70   if (handle != NULL) {
  71     result = resolve_impl<false /* external_guard */ >(handle);
  72   }
  73   return result;
  74 }
  75 
  76 inline oop JNIHandles::resolve_non_null(jobject handle) {
  77   assert(handle != NULL, "JNI handle should not be null");
  78   oop result = resolve_impl<false /* external_guard */ >(handle);
  79   assert(result != NULL, "NULL read from jni handle");
  80   return result;


  40 inline oop* JNIHandles::jobject_ptr(jobject handle) {
  41   assert(!is_jweak(handle), "precondition");
  42   return reinterpret_cast<oop*>(handle);
  43 }
  44 
  45 inline oop* JNIHandles::jweak_ptr(jobject handle) {
  46   assert(is_jweak(handle), "precondition");
  47   char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
  48   return reinterpret_cast<oop*>(ptr);
  49 }
  50 
  51 // external_guard is true if called from resolve_external_guard.
  52 template<bool external_guard>
  53 inline oop JNIHandles::resolve_impl(jobject handle) {
  54   assert(handle != NULL, "precondition");
  55   assert(!current_thread_in_native(), "must not be in native");
  56   oop result;
  57   if (is_jweak(handle)) {       // Unlikely
  58     result = resolve_jweak(handle);
  59   } else {
  60     result = NativeAccess<>::oop_load(jobject_ptr(handle));
  61     // Construction of jobjects canonicalize a null value into a null
  62     // jobject, so for non-jweak the pointee should never be null.
  63     assert(external_guard || result != NULL, "Invalid JNI handle");
  64   }
  65   return result;
  66 }
  67 
  68 inline oop JNIHandles::resolve(jobject handle) {
  69   oop result = NULL;
  70   if (handle != NULL) {
  71     result = resolve_impl<false /* external_guard */ >(handle);
  72   }
  73   return result;
  74 }
  75 
  76 inline oop JNIHandles::resolve_non_null(jobject handle) {
  77   assert(handle != NULL, "JNI handle should not be null");
  78   oop result = resolve_impl<false /* external_guard */ >(handle);
  79   assert(result != NULL, "NULL read from jni handle");
  80   return result;
< prev index next >