mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 13:54:38 +02:00
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
In array_size() cast to an unsigned to avoid overflow of intermediate value. Reviewed-by: kvn, tonyp, jmasa, jcoomes, coleenp
This commit is contained in:
parent
203cd9408a
commit
d090b4fe29
1 changed files with 6 additions and 2 deletions
|
@ -58,7 +58,7 @@ private:
|
||||||
old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
|
old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
|
||||||
}
|
}
|
||||||
#endif // ASSERT
|
#endif // ASSERT
|
||||||
int res = (length + OopsPerHeapWord - 1)/OopsPerHeapWord;
|
int res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord;
|
||||||
assert(res == old_res, "Inconsistency between old and new.");
|
assert(res == old_res, "Inconsistency between old and new.");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,11 @@ private:
|
||||||
|
|
||||||
static int object_size(int length) {
|
static int object_size(int length) {
|
||||||
// This returns the object size in HeapWords.
|
// This returns the object size in HeapWords.
|
||||||
return align_object_size(header_size() + array_size(length));
|
uint asz = array_size(length);
|
||||||
|
uint osz = align_object_size(header_size() + asz);
|
||||||
|
assert(osz >= asz, "no overflow");
|
||||||
|
assert((int)osz > 0, "no overflow");
|
||||||
|
return (int)osz;
|
||||||
}
|
}
|
||||||
|
|
||||||
// special iterators for index ranges, returns size of object
|
// special iterators for index ranges, returns size of object
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue