RFR: 8357086: os::xxx functions returning memory size should return size_t [v11]
Anton Artemov
duke at openjdk.org
Mon Jun 16 08:58:33 UTC 2025
On Mon, 16 Jun 2025 07:51:28 GMT, David Holmes <dholmes at openjdk.org> wrote:
> Can you add some more commentary on this please: what do the fields mean? how are they used? Do we need an assert to check that there is no error if you read the value?
The `value` field transfers a value returned by a call to memory functions (or computed by some other logic, see for instance the container case). The `error` field is introduced in order to signal an error which happened during a call to a memory function. Currently, the presence of error is encoded as -1 in that field, and the absence of error is 0. One could also do it with a boolean value. If later one wants to distinguish between different types of error, more values can be used.
Having these two values separately allows to have the full range of `size_t` in the output of all functions of interest, and be able to signal if something went wrong at the same time.
> It seems most places are not even checking if there may be an error. ??
This is correct, the purpose of this PR is not to enhance/improve handling of errors, but to address the issue of memory functions having different j* types where C++ doesn't interface with Java code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25450#discussion_r2149406896
More information about the hotspot-dev
mailing list