[code-reflection] RFR: Model synchronized statements
Paul Sandoz
psandoz at openjdk.org
Thu Aug 22 20:51:56 UTC 2024
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.
-------------
Commit messages:
- Simple bytecode test.
- Bytecode generation and lifting
- Merge remote-tracking branch 'upstream/code-reflection' into synchronized-op
- Synchronized op
Changes: https://git.openjdk.org/babylon/pull/217/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=217&range=00
Stats: 681 lines in 9 files changed: 673 ins; 6 del; 2 mod
Patch: https://git.openjdk.org/babylon/pull/217.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/217/head:pull/217
PR: https://git.openjdk.org/babylon/pull/217
More information about the babylon-dev
mailing list