< prev index next >

src/share/vm/prims/jni.cpp

Print this page




  67 #include "runtime/java.hpp"
  68 #include "runtime/javaCalls.hpp"
  69 #include "runtime/jfieldIDWorkaround.hpp"
  70 #include "runtime/orderAccess.inline.hpp"
  71 #include "runtime/reflection.hpp"
  72 #include "runtime/sharedRuntime.hpp"
  73 #include "runtime/signature.hpp"
  74 #include "runtime/thread.inline.hpp"
  75 #include "runtime/vm_operations.hpp"
  76 #include "services/memTracker.hpp"
  77 #include "services/runtimeService.hpp"
  78 #include "trace/traceMacros.hpp"
  79 #include "trace/tracing.hpp"
  80 #include "utilities/defaultStream.hpp"
  81 #include "utilities/dtrace.hpp"
  82 #include "utilities/events.hpp"
  83 #include "utilities/histogram.hpp"
  84 #include "utilities/internalVMTests.hpp"
  85 #include "utilities/macros.hpp"
  86 #if INCLUDE_ALL_GCS
  87 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  88 #endif // INCLUDE_ALL_GCS
  89 #if INCLUDE_JVMCI
  90 #include "jvmci/jvmciCompiler.hpp"
  91 #include "jvmci/jvmciRuntime.hpp"
  92 #endif
  93 
  94 static jint CurrentVersion = JNI_VERSION_9;
  95 
  96 #ifdef _WIN32
  97 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  98 #endif
  99 
 100 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace
 101 // '-return' probe regardless of the return path is taken out of the function.
 102 // Methods that have multiple return paths use this to avoid having to
 103 // instrument each return path.  Methods that use CHECK or THROW must use this
 104 // since those macros can cause an immedate uninstrumented return.
 105 //
 106 // In order to get the return value, a reference to the variable containing
 107 // the return value must be passed to the contructor of the object, and


2045   if (JvmtiExport::should_post_field_access()) {
2046     o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false);
2047   }
2048   jobject ret = JNIHandles::make_local(env, o->obj_field(offset));
2049 #if INCLUDE_ALL_GCS
2050   // If G1 is enabled and we are accessing the value of the referent
2051   // field in a reference object then we need to register a non-null
2052   // referent with the SATB barrier.
2053   if (UseG1GC) {
2054     bool needs_barrier = false;
2055 
2056     if (ret != NULL &&
2057         offset == java_lang_ref_Reference::referent_offset &&
2058         InstanceKlass::cast(k)->reference_type() != REF_NONE) {
2059       assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity");
2060       needs_barrier = true;
2061     }
2062 
2063     if (needs_barrier) {
2064       oop referent = JNIHandles::resolve(ret);
2065       G1SATBCardTableModRefBS::enqueue(referent);
2066     }
2067   }
2068 #endif // INCLUDE_ALL_GCS
2069 HOTSPOT_JNI_GETOBJECTFIELD_RETURN(ret);
2070   return ret;
2071 JNI_END
2072 
2073 
2074 
2075 #define DEFINE_GETFIELD(Return,Fieldname,Result \
2076   , EntryProbe, ReturnProbe) \
2077 \
2078   DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \
2079   , ReturnProbe); \
2080 \
2081 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \
2082   JNIWrapper("Get" XSTR(Result) "Field"); \
2083 \
2084   EntryProbe; \
2085   Return ret = 0;\




  67 #include "runtime/java.hpp"
  68 #include "runtime/javaCalls.hpp"
  69 #include "runtime/jfieldIDWorkaround.hpp"
  70 #include "runtime/orderAccess.inline.hpp"
  71 #include "runtime/reflection.hpp"
  72 #include "runtime/sharedRuntime.hpp"
  73 #include "runtime/signature.hpp"
  74 #include "runtime/thread.inline.hpp"
  75 #include "runtime/vm_operations.hpp"
  76 #include "services/memTracker.hpp"
  77 #include "services/runtimeService.hpp"
  78 #include "trace/traceMacros.hpp"
  79 #include "trace/tracing.hpp"
  80 #include "utilities/defaultStream.hpp"
  81 #include "utilities/dtrace.hpp"
  82 #include "utilities/events.hpp"
  83 #include "utilities/histogram.hpp"
  84 #include "utilities/internalVMTests.hpp"
  85 #include "utilities/macros.hpp"
  86 #if INCLUDE_ALL_GCS
  87 #include "gc/shared/satbMarkQueue.hpp"
  88 #endif // INCLUDE_ALL_GCS
  89 #if INCLUDE_JVMCI
  90 #include "jvmci/jvmciCompiler.hpp"
  91 #include "jvmci/jvmciRuntime.hpp"
  92 #endif
  93 
  94 static jint CurrentVersion = JNI_VERSION_9;
  95 
  96 #ifdef _WIN32
  97 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  98 #endif
  99 
 100 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace
 101 // '-return' probe regardless of the return path is taken out of the function.
 102 // Methods that have multiple return paths use this to avoid having to
 103 // instrument each return path.  Methods that use CHECK or THROW must use this
 104 // since those macros can cause an immedate uninstrumented return.
 105 //
 106 // In order to get the return value, a reference to the variable containing
 107 // the return value must be passed to the contructor of the object, and


2045   if (JvmtiExport::should_post_field_access()) {
2046     o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false);
2047   }
2048   jobject ret = JNIHandles::make_local(env, o->obj_field(offset));
2049 #if INCLUDE_ALL_GCS
2050   // If G1 is enabled and we are accessing the value of the referent
2051   // field in a reference object then we need to register a non-null
2052   // referent with the SATB barrier.
2053   if (UseG1GC) {
2054     bool needs_barrier = false;
2055 
2056     if (ret != NULL &&
2057         offset == java_lang_ref_Reference::referent_offset &&
2058         InstanceKlass::cast(k)->reference_type() != REF_NONE) {
2059       assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity");
2060       needs_barrier = true;
2061     }
2062 
2063     if (needs_barrier) {
2064       oop referent = JNIHandles::resolve(ret);
2065       SATBMarkQueue::enqueue(referent);
2066     }
2067   }
2068 #endif // INCLUDE_ALL_GCS
2069 HOTSPOT_JNI_GETOBJECTFIELD_RETURN(ret);
2070   return ret;
2071 JNI_END
2072 
2073 
2074 
2075 #define DEFINE_GETFIELD(Return,Fieldname,Result \
2076   , EntryProbe, ReturnProbe) \
2077 \
2078   DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \
2079   , ReturnProbe); \
2080 \
2081 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \
2082   JNIWrapper("Get" XSTR(Result) "Field"); \
2083 \
2084   EntryProbe; \
2085   Return ret = 0;\


< prev index next >