couple questions on method handle combinators

Paul Sandoz paul.sandoz at oracle.com
Wed Jun 14 18:02:45 UTC 2017


> On 14 Jun 2017, at 10:36, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
> 
>>> 
>>> There's a simpler solution: since MH.asType() already uses 1-element cache [1], it should be enough to just mark MH.asTypeCache as @Stable.
>>> 
>> 
>> Would not invalidate the contract of @Stable where the value changes at most once? thereby causes issues for already compiled methods treating that as a constant when other code updates the value via an asType call.
> 
>> i realize that we break similar rules for updating the LF, but that is a special case where we are in control where as we don’t control who calls MH.asType.
> 
> It does break @Stable contract, but the JVM doesn't forbid multiple updates to @Stable fields and it's a benign case: keeping a stale value "cached" in compiled code doesn't break asType() caching logic. (For user it looks like the cache is always stale and MH.asType() should be recomputed.)
> 

Just concerned that biasing to the first caller of asType may push the perf problem around.

I have a hunch for generic invokers we could cache an asType equivalent result at the call site by stuffing into some stable field of an appendix holder. That’s more work though.

Paul.


More information about the valhalla-dev mailing list