8178489: Make align functions more type safe and consistent

Reviewed-by: mgerdin, rehn
This commit is contained in:
Stefan Karlsson 2017-04-12 17:53:18 +02:00
parent 229f386a8f
commit 0fcf645cff
49 changed files with 134 additions and 140 deletions

View file

@ -78,7 +78,7 @@ protected:
int length = (int)elements;
assert((size_t)size(length) * BytesPerWord == bytes,
assert((size_t)size(length) * BytesPerWord == (size_t)bytes,
"Expected: " SIZE_FORMAT " got: " SIZE_FORMAT,
bytes, (size_t)size(length) * BytesPerWord);
@ -122,7 +122,12 @@ protected:
void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); }
static int size(int length) {
return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord;
size_t bytes = align_size_up(byte_sizeof(length), BytesPerWord);
size_t words = bytes / BytesPerWord;
assert(words <= INT_MAX, "Overflow: " SIZE_FORMAT, words);
return (int)words;
}
int size() {