[code-reflection] Integrated: Model synchronized statements
Paul Sandoz
psandoz at openjdk.org
Fri Aug 23 15:45:16 UTC 2024
On Tue, 20 Aug 2024 20:43:44 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Model synchronized statements.
>
> A synchronized op has two bodies one for the expression yielding the monitor and one for the synchronized block that covers the monitor enter and exit.
>
> The lowering of synchronized op produces a model containing monitor enter and exit operations and operations covered by exception regions, ensuring that a monitor exits under exceptional circumstances.
>
> The interpreter has been updated, but locking is currently on a best effort basis using `ReentrantLock` instances thus we cannot consistently apply synchronization on objects across interpretation, executing in a single thread, and bytecode executing in one or more other threads. We would need to update the interpreter to use native methods that invoke the JNI `MonitorEnter` and `MonitorExit` methods, although it is not clear if those can be mixed in a nested manner with JVM execution of monitor enter and exit bytecode instructions.
>
> A simple test for generated bytecode has been included that tests for the expected number of monitor enter and exit instructions, and single threaded execution for non-exceptional and exceptional cases.
This pull request has now been integrated.
Changeset: 345cfa09
Author: Paul Sandoz <psandoz at openjdk.org>
URL: https://git.openjdk.org/babylon/commit/345cfa0979c382f3e250880e567a5acba285b907
Stats: 681 lines in 9 files changed: 673 ins; 6 del; 2 mod
Model synchronized statements
Reviewed-by: mcimadamore
-------------
PR: https://git.openjdk.org/babylon/pull/217
More information about the babylon-dev
mailing list