You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit contains the necessary changes to support
refining VM INL calls in VarHandle call chains, as well
as support for inlining the call targets down to the Unsafe
operations. This is necessary for improved OpenJDK VarHandle
performance.
VarHandles must be stored in static final fields for this to
work. VarHandle final fields will undergo folding during
ILGen by default in Java 17+ as we need this folding to
happen prior to inlining. It is not possible to modify
static final fields by conventional means in JDK17+.
In general, when VarHandle object is known, we can evaluate
the steps to obtain the target MethodHandle at compile time.
For that, we obtain the result of the following calls in
MethodHandleTransformer and InterpreterEmulator:
* Invokers.directVarHandleTarget
* VarHandle.asDirect
* Invokers.checkVarHandleGenericType
Signed-off-by: Nazim Bhuiyan <nubhuiyan@ibm.com>
case TR::java_lang_invoke_Invokers_directVarHandleTarget:
408
+
case TR::java_lang_invoke_VarHandle_asDirect:
409
+
{
410
+
auto vhIndex = getObjectInfoOfNode(node->getLastChild());
411
+
if (knot && isKnownObject(vhIndex) && !knot->isNull(vhIndex))
412
+
{
413
+
auto directVHIndex = comp()->fej9()->getDirectVarHandleTargetIndex(comp(), vhIndex);
414
+
if (directVHIndex == TR::KnownObjectTable::UNKNOWN)
415
+
break;
416
+
if (trace())
417
+
{
418
+
if (rm == TR::java_lang_invoke_Invokers_directVarHandleTarget)
419
+
traceMsg(comp(), "Invokers_directVarHandleTarget with known VarHandle object %d, updating node n%dn with known object info\n", directVHIndex, node->getGlobalIndex());
420
+
else traceMsg(comp(), "VarHandle_asDirect with known VarHandle object %d, updating node n%dn with known object info\n", directVHIndex, node->getGlobalIndex());
421
+
}
422
+
node->setKnownObjectIndex(directVHIndex);
423
+
return directVHIndex;
424
+
}
425
+
break;
426
+
}
427
+
case TR::java_lang_invoke_Invokers_checkVarHandleGenericType:
428
+
{
429
+
auto vhIndex = getObjectInfoOfNode(node->getFirstArgument());
430
+
auto adIndex = getObjectInfoOfNode(node->getLastChild());
431
+
if (knot
432
+
&& isKnownObject(adIndex)
433
+
&& isKnownObject(vhIndex)
434
+
&& !knot->isNull(vhIndex)
435
+
&& !knot->isNull(adIndex))
436
+
{
437
+
auto mhIndex = comp()->fej9()->getMethodHandleTableEntryIndex(comp(), vhIndex, adIndex);
438
+
if (trace())
439
+
traceMsg(comp(), "Invokers_checkVarHandleGenericType with known VarHandle object %d, updating node n%dn with known MH object %d from MH table\n", vhIndex, node->getGlobalIndex(), mhIndex);
0 commit comments