Skip to content

Commit

Permalink
Merge pull request #18383 from IBMJimmyk/UnsafeFastPathJDK17
Browse files Browse the repository at this point in the history
Updated recognized methods for newer JDKs
  • Loading branch information
zl-wang committed Nov 6, 2023
2 parents b614f6c + 0d0bd0f commit 0d0f5ed
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions runtime/compiler/codegen/J9RecognizedMethodsEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
java_util_HashMap_findNullKeyEntry,
java_util_HashMap_get,
java_util_HashMap_getNode,
java_util_HashMap_getNode_Object,
java_util_HashMap_findNonNullKeyEntry,
java_util_HashMap_putImpl,
java_util_HashMap_resize,
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,7 @@ void TR_ResolvedJ9Method::construct()
{x(TR::java_util_HashMap_findNullKeyEntry, "findNullKeyEntry", "()Ljava/util/HashMap$Entry;")},
{x(TR::java_util_HashMap_get, "get", "(Ljava/lang/Object;)Ljava/lang/Object;")},
{x(TR::java_util_HashMap_getNode, "getNode", "(ILjava/lang/Object;)Ljava/util/HashMap$Node;")},
{x(TR::java_util_HashMap_getNode_Object, "getNode", "(Ljava/lang/Object;)Ljava/util/HashMap$Node;")},
{x(TR::java_util_HashMap_putImpl, "putImpl", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")},
{x(TR::java_util_HashMap_findNonNullKeyEntry, "findNonNullKeyEntry", "(Ljava/lang/Object;II)Ljava/util/HashMap$Entry;")},
{x(TR::java_util_HashMap_resize, "resize", "()[Ljava/util/HashMap$Node;")},
Expand Down Expand Up @@ -2887,6 +2888,7 @@ void TR_ResolvedJ9Method::construct()
{x(TR::sun_misc_Unsafe_putFloatVolatile_jlObjectJF_V, "putFloatRelease", "(Ljava/lang/Object;JF)V")},
{x(TR::sun_misc_Unsafe_putDoubleVolatile_jlObjectJD_V, "putDoubleRelease", "(Ljava/lang/Object;JD)V")},
{x(TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V, "putObjectRelease", "(Ljava/lang/Object;JLjava/lang/Object;)V")},
{x(TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V, "putReferenceRelease", "(Ljava/lang/Object;JLjava/lang/Object;)V")},

{x(TR::sun_misc_Unsafe_putInt_jlObjectII_V, "putInt", "(Ljava/lang/Object;II)V")},

Expand Down Expand Up @@ -2921,6 +2923,7 @@ void TR_ResolvedJ9Method::construct()
{x(TR::sun_misc_Unsafe_getFloatVolatile_jlObjectJ_F, "getFloatAcquire", "(Ljava/lang/Object;J)F")},
{x(TR::sun_misc_Unsafe_getDoubleVolatile_jlObjectJ_D, "getDoubleAcquire", "(Ljava/lang/Object;J)D")},
{x(TR::sun_misc_Unsafe_getObjectVolatile_jlObjectJ_jlObject, "getObjectAcquire", "(Ljava/lang/Object;J)Ljava/lang/Object;")},
{x(TR::sun_misc_Unsafe_getObjectVolatile_jlObjectJ_jlObject, "getReferenceAcquire", "(Ljava/lang/Object;J)Ljava/lang/Object;")},

{x(TR::sun_misc_Unsafe_putByte_JB_V, "putByte", "(JB)V")},
{x(TR::sun_misc_Unsafe_putShort_JS_V, "putShort", "(JS)V")},
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/il/J9MethodSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static TR::RecognizedMethod canSkipBoundChecks[] =
TR::java_util_HashtableHashEnumerator_hasMoreElements,
TR::java_util_HashtableHashEnumerator_nextElement,
TR::java_util_HashMap_getNode,
TR::java_util_HashMap_getNode_Object,
TR::java_util_HashMap_resize,
//TR::java_util_HashMapHashIterator_nextNode, /* Unsafe if the Iterator is being incorrectly used (concurrent execution) */
TR::java_util_HashMapHashIterator_init, /* Safe because the object is only visible by one thread when init() is executing */
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ TR_J9InlinerPolicy::alwaysWorthInlining(TR_ResolvedMethod * calleeMethod, TR::No
case TR::java_lang_StringUTF16_newBytesFor:
case TR::java_util_HashMap_get:
case TR::java_util_HashMap_getNode:
case TR::java_util_HashMap_getNode_Object:
case TR::java_lang_String_getChars_charArray:
case TR::java_lang_String_getChars_byteArray:
case TR::java_lang_Integer_toUnsignedLong:
Expand Down
41 changes: 21 additions & 20 deletions runtime/compiler/optimizer/UnsafeFastPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,12 @@ int32_t TR_UnsafeFastPath::perform()
case TR::sun_misc_Unsafe_getObject_jlObjectJ_jlObject:
switch (methodSymbol->getRecognizedMethod())
{
case TR::java_util_concurrent_ConcurrentHashMap_tabAt:
case TR::java_util_concurrent_ConcurrentHashMap_setTabAt:
isArrayOperation = true;
default:
break;
case TR::java_util_concurrent_ConcurrentHashMap_tabAt:
case TR::java_util_concurrent_ConcurrentHashMap_setTabAt:
isArrayOperation = true;
break;
default:
break;
}
break;
case TR::com_ibm_jit_JITHelpers_getByteFromArrayVolatile:
Expand Down Expand Up @@ -554,14 +555,14 @@ int32_t TR_UnsafeFastPath::perform()
case TR::sun_misc_Unsafe_putObject_jlObjectJjlObject_V:
switch (comp()->getMethodSymbol()->getRecognizedMethod())
{
case TR::java_util_concurrent_ConcurrentHashMap_setTabAt:
type = TR::Address;
value = node->getChild(3);
break;
default:
break;
// by not setting type the call will not be recognized here and will
// be left to the inliner since we need to generate control flow
case TR::java_util_concurrent_ConcurrentHashMap_setTabAt:
type = TR::Address;
value = node->getChild(3);
break;
default:
break;
// by not setting type the call will not be recognized here and will
// be left to the inliner since we need to generate control flow
}
break;
case TR::com_ibm_jit_JITHelpers_getByteFromArrayByIndex:
Expand All @@ -588,13 +589,13 @@ int32_t TR_UnsafeFastPath::perform()
case TR::sun_misc_Unsafe_getObject_jlObjectJ_jlObject:
switch (methodSymbol->getRecognizedMethod())
{
case TR::java_util_concurrent_ConcurrentHashMap_tabAt:
type = TR::Address;
break;
default:
break;
// by not setting type the call will not be recognized here and will
// be left to the inliner since we need to generate control flow
case TR::java_util_concurrent_ConcurrentHashMap_tabAt:
type = TR::Address;
break;
default:
break;
// by not setting type the call will not be recognized here and will
// be left to the inliner since we need to generate control flow
}
break;
case TR::sun_misc_Unsafe_putInt_jlObjectJI_V:
Expand Down

0 comments on commit 0d0f5ed

Please sign in to comment.