RFR: 8291555: Replace stack-locking with fast-locking

Roman Kennke rkennke at openjdk.org
Thu Oct 6 07:47:17 UTC 2022


On Wed, 17 Aug 2022 07:29:23 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

> > Strictly speaking, I believe the conditions check for the (weaker) balanced property, but not for the (stronger) structured property.
> 
> I know but the text says:
> 
>     * "every exit on a given monitor matches a preceding entry on that monitor."
> 
>     * "implementations of the Java Virtual Machine are permitted but not required to enforce both of the following two rules guaranteeing structured locking"
> 
> 
> I read this as if the rules do not guarantee structured locking the rules are not correct. The VM is allowed to enforce it. But thats just my take on it.
> 
> EDIT: Maybe I'm reading to much into it. Lock A,B then unlock A,B maybe is considered structured locking?
> 
> But then again what if:
> 
> ```
> void foo_lock() {
>   monitorenter(A);
>   monitorenter(B);
>   // If VM abruptly returns here
>   // VM can unlock them in reverse order first B and then A ?
>   monitorexit(A);
>   monitorexit(B);
> }
> ```

Do you think there would be any chance to clarify the spec there? Or even outright disallow unstructured/not-properly-nested locking altogether (and maybe allow the verifier to check it)? That would certainly be the right thing to do. And, afaict, it would do no harm because no compiler of any language would ever emit unstructured locking anyway - because if it did, the resulting code would crawl interpreted-only).

-------------

PR: https://git.openjdk.org/jdk/pull/9680


More information about the serviceability-dev mailing list