daniellansun commented on code in PR #2736:
URL: https://github.com/apache/groovy/pull/2736#discussion_r3657349536
##########
src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java:
##########
@@ -472,9 +537,14 @@ private static Object
invokeColdReflective(ColdReflectiveMethodHandleWrapper col
throw ScriptBytecodeAdapter.unwrap(gre);
}
}
- MethodHandle mh = selectMethodHandle(cold.callSite, cold.sender,
cold.methodName, cold.callID,
- cold.safeNavigation, cold.thisCall, cold.spreadCall, 1,
arguments);
- return mh.invokeExact(arguments);
+ // Re-select without the cold tier so an always-invalid SwitchPoint
(or any
+ // permanent cold miss after class-domain failover) cannot recurse
through
+ // tryBuild → invokeColdReflective (GROOVY-12191).
+ MethodHandleWrapper full = fallback(cold.callSite, cold.sender,
cold.methodName, cold.callID,
+ cold.safeNavigation, cold.thisCall, cold.spreadCall, 1,
arguments, false);
+ cold.callSite.put(receiverCacheKey(arguments[0]),
+ full.isCanSetTarget() ? full : NULL_METHOD_HANDLE_WRAPPER);
Review Comment:
Agreed that this needed an explicit comment — the policy is shared with
`fromCacheHandle` / `selectMethodHandle`, not cold-tier-specific invention.
**Why the sentinel is the only safe PIC value when `!canSetTarget`**
1. `canSetTarget == false` means the selection is **not
class-keyed-cacheable** (typical causes: per-instance MetaClass, spread-call →
`selector.cache == false`).
2. Storing that real wrapper under the receiver-class PIC key would pin a
selection that is only valid for one instance or one spread shape, and the next
hit would skip re-selection.
3. `NULL_METHOD_HANDLE_WRAPPER` is the existing PIC sentinel meaning *“do
not cache this receiver shape; re-run fallback on the next hit”* (see
`fromCacheHandle`).
4. The **current** invocation still uses `full.getCachedMethodHandle()` —
the sentinel only shapes the PIC, not the return of this call.
**Action taken**
- Expanded the inline comment at the cold-path PIC write to state the above.
- Added a unit test that asserts the uncacheable → sentinel PIC write policy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]