Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#18222 from nbhuiyan/cct-ann-vm
Browse files Browse the repository at this point in the history
Add CT helper to check for ChangesCurrentThread annotation
  • Loading branch information
tajila authored Oct 4, 2023
2 parents 6b03df7 + 76e395a commit 8abe35a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions runtime/jit_vm/cthelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

extern "C" {

#if JAVA_SPEC_VERSION >= 21
J9_DECLARE_CONSTANT_UTF8(ojdk_changesCurrentThread, "Ljdk/internal/vm/annotation/ChangesCurrentThread");
#endif /* JAVA_SPEC_VERSION >= 21 */

#if JAVA_SPEC_VERSION >= 16
J9_DECLARE_CONSTANT_UTF8(ojdk_intrinsicCandidate, "Ljdk/internal/vm/annotation/IntrinsicCandidate;");
#endif /* JAVA_SPEC_VERSION >= 16 */
Expand Down Expand Up @@ -252,4 +256,21 @@ jitIsMethodTaggedWithIntrinsicCandidate(J9VMThread *currentThread, J9Method *met
#endif /* JAVA_SPEC_VERSION >= 16 */
}

/**
* Queries if the method is annotated with @ChangesCurrentThread
*
* @param currentThread the currentThread
* @param method the method to check for the annotation
* @return true if method is annotated with @ChangesCurrentThread, false otherwise
*/
BOOLEAN
jitIsMethodTaggedWithChangesCurrentThread(J9VMThread *currentThread, J9Method *method)
{
#if JAVA_SPEC_VERSION >= 21
return FALSE != methodContainsRuntimeAnnotation(currentThread, method, (J9UTF8 *)&ojdk_changesCurrentThread);
#else /* JAVA_SPEC_VERSION >= 21 */
return FALSE;
#endif /* JAVA_SPEC_VERSION >= 21 */
}

}
2 changes: 1 addition & 1 deletion runtime/oti/j9protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ extern J9_CFUNC BOOLEAN jitIsFieldStable(J9VMThread *currentThread, J9Class *cla
extern J9_CFUNC BOOLEAN jitIsMethodTaggedWithForceInline(J9VMThread *currentThread, J9Method *method);
extern J9_CFUNC BOOLEAN jitIsMethodTaggedWithDontInline(J9VMThread *currentThread, J9Method *method);
extern J9_CFUNC BOOLEAN jitIsMethodTaggedWithIntrinsicCandidate(J9VMThread *currentThread, J9Method *method);
extern J9_CFUNC BOOLEAN jitIsMethodTaggedWithChangesCurrentThread(J9VMThread *currentThread, J9Method *method);

typedef struct J9MethodFromSignatureWalkState {
const char *className;
Expand Down Expand Up @@ -1399,4 +1400,3 @@ extern J9_CFUNC void jitAddPicToPatchOnClassUnload (void *classPointer, void *a
#endif

#endif /* J9PROTOS_H */

0 comments on commit 8abe35a

Please sign in to comment.