RFR: 8303942: os::write should write completely [v6]

David Holmes dholmes at openjdk.org
Tue May 9 01:03:27 UTC 2023


On Mon, 8 May 2023 15:06:42 GMT, Afshin Zafari <duke at openjdk.org> wrote:

>> `os::write` is implemented using loops until the whole bytes are written. All uses of `os::write` in a loop are changed to single call. 
>> Platform dependent versions of the `os::write` are also renamed and moved to private sections accordingly.
>> Wrong uses/interpretations of return values from `os::write` in JFR code are corrected.
>> 
>> ###Test
>> local: hotspot tier1
>> mach5: tiers 1-5
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8303942: os::write should write completely

Thanks for the updates @afshin-zafari ! One last nit with the usage of the boolean function.

src/hotspot/os/posix/perfMemory_posix.cpp line 106:

> 104: 
> 105:     bool successful_write = os::write(fd, addr, size);
> 106:     if (!successful_write) {

You don't need to introduce the local variable here.

src/hotspot/os/posix/perfMemory_posix.cpp line 953:

> 951:     if (result == -1 ) break;
> 952:     bool successful_write = os::write(fd, &zero_int, 1);
> 953:     if (!successful_write) {

Ditto no need for a local

src/hotspot/share/cds/filemap.cpp line 1689:

> 1687:   assert(_file_open, "must be");
> 1688:   bool successful_write = os::write(_fd, buffer, nbytes);
> 1689:   if (!successful_write) {

No local please

src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp line 389:

> 387:         assert(bytes_read - bytes_written <= (int64_t)block_size, "invariant");
> 388:         const bool successful_write = os::write(emergency_fd, copy_block, bytes_read - bytes_written);
> 389:         if (!successful_write) {

No local please.

src/hotspot/share/services/heapDumperCompression.cpp line 59:

> 57: 
> 58:   bool successful_write = os::write(_fd, buf, (size_t)size);
> 59:   if (!successful_write) {

No local please

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

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13750#pullrequestreview-1417684525
PR Review Comment: https://git.openjdk.org/jdk/pull/13750#discussion_r1188013005
PR Review Comment: https://git.openjdk.org/jdk/pull/13750#discussion_r1188013192
PR Review Comment: https://git.openjdk.org/jdk/pull/13750#discussion_r1188013525
PR Review Comment: https://git.openjdk.org/jdk/pull/13750#discussion_r1188013819
PR Review Comment: https://git.openjdk.org/jdk/pull/13750#discussion_r1188018424


More information about the hotspot-dev mailing list