JDK-8253593 : Extend ByteSize and WordSize
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 16
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2020-09-24
  • Updated: 2020-10-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
In the review of JDK-8253555 it was suggested that it would be good to extend ByteSize and WordSize with the following:

---
Consider adding
constexpr ByteSize in_ByteSize(WordSize size) { ... }
constexpr int in_bytes(WordSize size) { ... }

Also consider adding the identity conversion
constexpr ByteSize in_ByteSize(ByteSize size) { return size; }
which might be useful in generic code?
---

---
It would be nice to have a more complete set of operations for ByteSize.
That way, when writing new code, one doesn't need to remember or look up
whether the operation you want to use is supported.

ByteSize operator*(int, ByteSize) -- so multiplicative scaling is commutative

ByteSize operator/(ByteSize, int) -- division scaling ?

-- op= variants
ByteSize& operator+=(ByteSize& x, ByteSize y)
ByteSize& operator-=(ByteSize& x, ByteSize y)
ByteSize& operator*=(ByteSize& x, int y)
ByteSize& operator/=(ByteSize& x, int y)
---
Comments
Also pre/post increment/decrement: ByteSize& operator++(ByteSize&) ByteSize operator++(ByteSize&, int) ByteSize& operator--(ByteSize&) ByteSize operator--(ByteSize&, int)
24-09-2020