[foreign-preview] RFR: 8282070: Drop workaround from memory segment implementation

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Feb 17 19:12:42 UTC 2022


Following some preliminary experiments (see [1]) it is now finally time to drop the various workarounds we have in the memory segment implementation. This patch removes two workarounds:

* special treatment for "small" segments (e.g. segments whose size fits in an int) - see `MemorySegment::isSmall`; these segments were special cased so that bound checks would only involve `int` comparisons. This has now been fixed in JDK-8276116, and special treatment is no longer required.

* special shortcuts to avoid extra alignment checks. Since when generating var handles from a layout we check most of the alignment constraints (except those involving the base address), in the past we have added a fastpath for these var handles, as C2 had trouble hoisting alignment checks outside of the loops. This has now been fixed in JDK-8277850 and is no longer required.

I have run benchmarks before and after and got identical results. Some benchmarkks in `ParallelSum` got a boost, but those always have noise, due to multi-threading.

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

Commit messages:
 - Initial push

Changes: https://git.openjdk.java.net/panama-foreign/pull/644/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=644&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282070
  Stats: 219 lines in 13 files changed: 12 ins; 107 del; 100 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/644.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/644/head:pull/644

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


More information about the panama-dev mailing list