mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8200429: Adjust object pinning interface on CollectedHeap
Reviewed-by: dholmes, rkennke
This commit is contained in:
parent
29bb7c8a05
commit
15263a27f8
3 changed files with 38 additions and 21 deletions
|
@ -621,12 +621,15 @@ void CollectedHeap::reset_promotion_should_fail() {
|
||||||
|
|
||||||
#endif // #ifndef PRODUCT
|
#endif // #ifndef PRODUCT
|
||||||
|
|
||||||
oop CollectedHeap::pin_object(JavaThread* thread, oop o) {
|
bool CollectedHeap::supports_object_pinning() const {
|
||||||
Handle handle(thread, o);
|
return false;
|
||||||
GCLocker::lock_critical(thread);
|
|
||||||
return handle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectedHeap::unpin_object(JavaThread* thread, oop o) {
|
oop CollectedHeap::pin_object(JavaThread* thread, oop obj) {
|
||||||
GCLocker::unlock_critical(thread);
|
ShouldNotReachHere();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CollectedHeap::unpin_object(JavaThread* thread, oop obj) {
|
||||||
|
ShouldNotReachHere();
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,14 +589,12 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||||
// perform cleanup tasks serially in the VMThread.
|
// perform cleanup tasks serially in the VMThread.
|
||||||
virtual WorkGang* get_safepoint_workers() { return NULL; }
|
virtual WorkGang* get_safepoint_workers() { return NULL; }
|
||||||
|
|
||||||
// Support for object pinning. This is used by JNI's Get*Critical() and
|
// Support for object pinning. This is used by JNI Get*Critical()
|
||||||
// Release*Critical() family of functions. A GC may either use the GCLocker
|
// and Release*Critical() family of functions. If supported, the GC
|
||||||
// protocol to ensure no critical arrays are in-use when entering
|
// must guarantee that pinned objects never move.
|
||||||
// a GC pause, or it can implement pinning, which must guarantee that
|
virtual bool supports_object_pinning() const;
|
||||||
// the object does not move while pinned.
|
virtual oop pin_object(JavaThread* thread, oop obj);
|
||||||
virtual oop pin_object(JavaThread* thread, oop o);
|
virtual void unpin_object(JavaThread* thread, oop obj);
|
||||||
|
|
||||||
virtual void unpin_object(JavaThread* thread, oop o);
|
|
||||||
|
|
||||||
// Non product verification and debugging.
|
// Non product verification and debugging.
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "classfile/symbolTable.hpp"
|
#include "classfile/symbolTable.hpp"
|
||||||
#include "classfile/systemDictionary.hpp"
|
#include "classfile/systemDictionary.hpp"
|
||||||
#include "classfile/vmSymbols.hpp"
|
#include "classfile/vmSymbols.hpp"
|
||||||
|
#include "gc/shared/gcLocker.inline.hpp"
|
||||||
#include "interpreter/linkResolver.hpp"
|
#include "interpreter/linkResolver.hpp"
|
||||||
#include "memory/allocation.hpp"
|
#include "memory/allocation.hpp"
|
||||||
#include "memory/allocation.inline.hpp"
|
#include "memory/allocation.inline.hpp"
|
||||||
|
@ -3145,6 +3146,24 @@ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start,
|
||||||
}
|
}
|
||||||
JNI_END
|
JNI_END
|
||||||
|
|
||||||
|
static oop lock_gc_or_pin_object(JavaThread* thread, jobject obj) {
|
||||||
|
if (Universe::heap()->supports_object_pinning()) {
|
||||||
|
const oop o = JNIHandles::resolve_non_null(obj);
|
||||||
|
return Universe::heap()->pin_object(thread, o);
|
||||||
|
} else {
|
||||||
|
GCLocker::lock_critical(thread);
|
||||||
|
return JNIHandles::resolve_non_null(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unlock_gc_or_unpin_object(JavaThread* thread, jobject obj) {
|
||||||
|
if (Universe::heap()->supports_object_pinning()) {
|
||||||
|
const oop o = JNIHandles::resolve_non_null(obj);
|
||||||
|
return Universe::heap()->unpin_object(thread, o);
|
||||||
|
} else {
|
||||||
|
GCLocker::unlock_critical(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy))
|
JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy))
|
||||||
JNIWrapper("GetPrimitiveArrayCritical");
|
JNIWrapper("GetPrimitiveArrayCritical");
|
||||||
|
@ -3152,8 +3171,7 @@ JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboole
|
||||||
if (isCopy != NULL) {
|
if (isCopy != NULL) {
|
||||||
*isCopy = JNI_FALSE;
|
*isCopy = JNI_FALSE;
|
||||||
}
|
}
|
||||||
oop a = JNIHandles::resolve_non_null(array);
|
oop a = lock_gc_or_pin_object(thread, array);
|
||||||
a = Universe::heap()->pin_object(thread, a);
|
|
||||||
assert(a->is_array(), "just checking");
|
assert(a->is_array(), "just checking");
|
||||||
BasicType type;
|
BasicType type;
|
||||||
if (a->is_objArray()) {
|
if (a->is_objArray()) {
|
||||||
|
@ -3170,8 +3188,7 @@ JNI_END
|
||||||
JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode))
|
JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode))
|
||||||
JNIWrapper("ReleasePrimitiveArrayCritical");
|
JNIWrapper("ReleasePrimitiveArrayCritical");
|
||||||
HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(env, array, carray, mode);
|
HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(env, array, carray, mode);
|
||||||
oop a = JNIHandles::resolve_non_null(array);
|
unlock_gc_or_unpin_object(thread, array);
|
||||||
Universe::heap()->unpin_object(thread, a);
|
|
||||||
HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN();
|
HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN();
|
||||||
JNI_END
|
JNI_END
|
||||||
|
|
||||||
|
@ -3179,8 +3196,7 @@ JNI_END
|
||||||
JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
|
JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
|
||||||
JNIWrapper("GetStringCritical");
|
JNIWrapper("GetStringCritical");
|
||||||
HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy);
|
HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy);
|
||||||
oop s = JNIHandles::resolve_non_null(string);
|
oop s = lock_gc_or_pin_object(thread, string);
|
||||||
s = Universe::heap()->pin_object(thread, s);
|
|
||||||
typeArrayOop s_value = java_lang_String::value(s);
|
typeArrayOop s_value = java_lang_String::value(s);
|
||||||
bool is_latin1 = java_lang_String::is_latin1(s);
|
bool is_latin1 = java_lang_String::is_latin1(s);
|
||||||
if (isCopy != NULL) {
|
if (isCopy != NULL) {
|
||||||
|
@ -3217,7 +3233,7 @@ JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar
|
||||||
// This assumes that ReleaseStringCritical bookends GetStringCritical.
|
// This assumes that ReleaseStringCritical bookends GetStringCritical.
|
||||||
FREE_C_HEAP_ARRAY(jchar, chars);
|
FREE_C_HEAP_ARRAY(jchar, chars);
|
||||||
}
|
}
|
||||||
Universe::heap()->unpin_object(thread, s);
|
unlock_gc_or_unpin_object(thread, str);
|
||||||
HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN();
|
HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN();
|
||||||
JNI_END
|
JNI_END
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue