Integrated: 8321467: MemorySegment.setString(long, String, Charset) throws IAE(Misaligned access)
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Dec 7 12:54:41 UTC 2023
On Wed, 6 Dec 2023 16:49:30 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This PR fixes a couple of aligned accesses when reading/writing strings. Such aligned accesses crept in when we optimized string read/write operations to work in bulk. As a result, depending on the maximum alignment constraints supported by the heap segment, some string operations might fail.
>
> I've added some tests to make sure that all operations work as expected with unaligned semantics.
>
> Note: I've considered inferring an alignment constraint from the provided charset, and then use aligned operations (and document that behavior), but I found that to be unsatisfactory: memory operations typically accept a layout, which allow clients to opt out from alignment checks if needed. But if we always infer an alignment constraint from the provided charset, clients would find themselves w/o an escape hatch. For this reason, I think the best way to fix this is to use unaligned operations when reading/writing the string.
This pull request has now been integrated.
Changeset: 42bb8526
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/42bb8526967ce6d74b409c0f7aa6f8580af1aaa0
Stats: 56 lines in 2 files changed: 43 ins; 6 del; 7 mod
8321467: MemorySegment.setString(long, String, Charset) throws IAE(Misaligned access)
Reviewed-by: pminborg
-------------
PR: https://git.openjdk.org/jdk/pull/16999
More information about the core-libs-dev
mailing list