[foreign-memaccess+abi] RFR: 8269807: Implement the fix for JDK-8269240 in the panama-foreign repo

Jorn Vernee jvernee at openjdk.java.net
Wed Jul 7 18:36:01 UTC 2021


Hi,

This patch re-writes the prologue and epilogue code of upcalls to model what is done for JNI by `JavaCallWrapper`. The old code did more or less the inverse of what was happening for downcalls, but this is not correct. The new code uses a pair of calls in the prologue and epilogue to `ProgrammableUpcallHandler::on_entry` and `ProgrammableUpcallHandler::on_exit`.

We now also need to save a little bit more information about the entry frame, namely the `JNIHandle` block that the prologue allocates, and the old handle block to restore later and for the GC to inspect. I've expanded the existing `AuxiliarySaves` struct for this and renamed and moved it to be a nested type in `OptimizedEntryBlob`. The move is mostly to avoid circular dependencies between headers.

During this rewrite, I also noticed that the return value of an upcall was not properly spilled around a call to detach a thread in the epilogue (only needed when we attached it in the prologue). Since we now always have a call in the epilogue, I've added the missing spill and fill code.

Since this was not caught by our existing testing, I've added an additional mode to TestUpcall to run test cases on a separate thread as well. I've split the three cases in TestUpcall into separate jtreg tests to keep execution times down, and to make it easier to see what failed if there is a test failure. (I'm not sure if there's a better way to ignore some testng test methods in jtreg other than throwing a `SkipException`, which also fills the console log unfortunately).

I've also added cases for testing with concurrent GCs to the test (`AsyncStackWalk`) against which the original failure was reported.

Besides that, there is a minor cleanup of some existing assert code that was copy/pasted, as well as a change to `TestByteBuffer` that was failing on WSL because of an function not being implemented, which I've now handled by skipping the test in that case.

Thanks,
Jorn

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

Commit messages:
 - Add async testing of upcalls
 - Upcall fixes

Changes: https://git.openjdk.java.net/panama-foreign/pull/565/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=565&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8269807
  Stats: 773 lines in 23 files changed: 592 ins; 147 del; 34 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/565.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/565/head:pull/565

PR: https://git.openjdk.java.net/panama-foreign/pull/565


More information about the panama-dev mailing list