-
Enhancement
-
Resolution: Fixed
-
P4
-
hs23, 17, 18
-
b21
-
generic
-
generic
Many quantities are kept as signed quantities that should be unsigned.
Consider oopDesc::size() which returns an int. Since the size can never
be negative, we could extend the range of the result. In fact, we should
make these quantities size_t, so that on LP64 machines they expand with
the address space. What's the size of long[Integer.MAX_VALUE]? Much
bigger than will fit in a int!
There are probably hundreds of these.
There are places where we've started the conversion, and at the transitions
from signed to unsigned there are sometimes asserts that the quantities are
>= 0 -- since otherwise they won't convert well to unsigned. We can clean
up all those asserts when we have uniformly converted to unsigned.
Paul Hohensee points out that
// Returns the actual oop size of the object
inline int oopDesc::size();
actually returns the size in HeapWords, not in oops. Actually it uses
wordSize, not HeapWordSize.
I just noticed
inline intx byte_size(void* from, void* to) {
return (address)to - (address)from;
}
which only works as well as it does because it casts the arguments
to u_char*, and I guess sizeof(u_char) is 1, so the signed divide
by the size of the elements computes the right representation, if
not the right type. But then the return type is intx, rather than
uintx (or size_t), so we lose (except for the representation) if
the answer is more than intx.MAX_VALUE.
Also, VirtualSpace::committed_size() and friends say they return
size_t's but they also only compute the right representation because
they use naked pointer subtraction.
Consider oopDesc::size() which returns an int. Since the size can never
be negative, we could extend the range of the result. In fact, we should
make these quantities size_t, so that on LP64 machines they expand with
the address space. What's the size of long[Integer.MAX_VALUE]? Much
bigger than will fit in a int!
There are probably hundreds of these.
There are places where we've started the conversion, and at the transitions
from signed to unsigned there are sometimes asserts that the quantities are
>= 0 -- since otherwise they won't convert well to unsigned. We can clean
up all those asserts when we have uniformly converted to unsigned.
Paul Hohensee points out that
// Returns the actual oop size of the object
inline int oopDesc::size();
actually returns the size in HeapWords, not in oops. Actually it uses
wordSize, not HeapWordSize.
I just noticed
inline intx byte_size(void* from, void* to) {
return (address)to - (address)from;
}
which only works as well as it does because it casts the arguments
to u_char*, and I guess sizeof(u_char) is 1, so the signed divide
by the size of the elements computes the right representation, if
not the right type. But then the return type is intx, rather than
uintx (or size_t), so we lose (except for the representation) if
the answer is more than intx.MAX_VALUE.
Also, VirtualSpace::committed_size() and friends say they return
size_t's but they also only compute the right representation because
they use naked pointer subtraction.
- duplicates
-
JDK-7110613 Make sure that Hotspot uses size_t and not int when object sizes are passed around
- Closed
- relates to
-
JDK-6464834 ObjectOutputStream's internal array management limits maximum size
- Open
-
JDK-8233189 [lworld] Flat array allocations are limited to 16 GB
- Open