-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atomic-free JNI work #1762
Atomic-free JNI work #1762
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
|
||
/******************************************************************************* | ||
* Copyright (c) 1991, 2016 IBM Corp. and others | ||
* Copyright (c) 1991, 2018 IBM Corp. and others | ||
* | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which accompanies this | ||
|
@@ -404,10 +403,8 @@ MM_RealtimeAccessBarrier::jniGetPrimitiveArrayCritical(J9VMThread* vmThread, jar | |
// acquire access and return a direct pointer | ||
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI) | ||
VM_VMAccess::inlineEnterVMFromJNI(vmThread); | ||
vmThread->jniCriticalDirectCount += 1; | ||
#else /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::enterCriticalRegion(vmThread); | ||
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::enterCriticalRegion(vmThread); | ||
data = (void *)_extensions->indexableObjectModel.getDataPointerForContiguous(arrayObject); | ||
if(NULL != isCopy) { | ||
*isCopy = JNI_FALSE; | ||
|
@@ -472,11 +469,10 @@ MM_RealtimeAccessBarrier::jniReleasePrimitiveArrayCritical(J9VMThread* vmThread, | |
Trc_MM_JNIReleasePrimitiveArrayCritical_invalid(vmThread, arrayObject, elems, data); | ||
} | ||
|
||
MM_JNICriticalRegion::exitCriticalRegion(vmThread); | ||
|
||
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI) | ||
vmThread->jniCriticalDirectCount -= 1; | ||
VM_VMAccess::inlineExitVMToJNI(vmThread); | ||
#else /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::exitCriticalRegion(vmThread); | ||
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
} | ||
} | ||
|
@@ -549,12 +545,12 @@ MM_RealtimeAccessBarrier::jniGetStringCritical(J9VMThread* vmThread, jstring str | |
} else { | ||
// acquire access and return a direct pointer | ||
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI) | ||
VM_VMAccess::inlineEnterVMFromJNI(vmThread); | ||
vmThread->jniCriticalDirectCount += 1; | ||
hasVMAccess = true; | ||
#else /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::enterCriticalRegion(vmThread); | ||
if (!hasVMAccess) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also just making a note for myself to come look at the hasVMAccess. Not sure how one thread entering here could have it and another thread not have it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect this code can be refactored/optimized at some point. |
||
VM_VMAccess::inlineEnterVMFromJNI(vmThread); | ||
hasVMAccess = true; | ||
} | ||
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::enterCriticalRegion(vmThread); | ||
J9Object *stringObject = (J9Object*)J9_JNI_UNWRAP_REFERENCE(str); | ||
J9IndexableObject *valueObject = (J9IndexableObject*)J9VMJAVALANGSTRING_VALUE(vmThread, stringObject); | ||
|
||
|
@@ -606,12 +602,12 @@ MM_RealtimeAccessBarrier::jniReleaseStringCritical(J9VMThread* vmThread, jstring | |
} else { | ||
// direct pointer, just drop access | ||
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI) | ||
VM_VMAccess::inlineEnterVMFromJNI(vmThread); | ||
vmThread->jniCriticalDirectCount -= 1; | ||
hasVMAccess = true; | ||
#else /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::exitCriticalRegion(vmThread); | ||
if (!hasVMAccess) { | ||
VM_VMAccess::inlineEnterVMFromJNI(vmThread); | ||
hasVMAccess = true; | ||
} | ||
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */ | ||
MM_JNICriticalRegion::exitCriticalRegion(vmThread); | ||
} | ||
|
||
if (hasVMAccess) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if these asserts could be enabled all of the time? Not asking you to change them just thinking out loud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag has no meaning unless the ifdef is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry thought that was a VMAccess check lol. My bad!