< prev index next >

src/share/vm/prims/jni.cpp

Print this page




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


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




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


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


< prev index next >