提交 3b09560d 编写于 作者: M morris

8054530: C2: assert(res == old_res) failed: Inconsistency between old and new

Summary: Fixed signedness problem with assertion.
Reviewed-by: kvn
上级 45eeb66c
...@@ -45,9 +45,10 @@ class objArrayOopDesc : public arrayOopDesc { ...@@ -45,9 +45,10 @@ class objArrayOopDesc : public arrayOopDesc {
private: private:
// Give size of objArrayOop in HeapWords minus the header // Give size of objArrayOop in HeapWords minus the header
static int array_size(int length) { static int array_size(int length) {
const int OopsPerHeapWord = HeapWordSize/heapOopSize; const uint OopsPerHeapWord = HeapWordSize/heapOopSize;
assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0), assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),
"Else the following (new) computation would be in error"); "Else the following (new) computation would be in error");
uint res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord;
#ifdef ASSERT #ifdef ASSERT
// The old code is left in for sanity-checking; it'll // The old code is left in for sanity-checking; it'll
// go away pretty soon. XXX // go away pretty soon. XXX
...@@ -55,16 +56,15 @@ private: ...@@ -55,16 +56,15 @@ private:
// oop->length() * HeapWordsPerOop; // oop->length() * HeapWordsPerOop;
// With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer. // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
// The oop elements are aligned up to wordSize // The oop elements are aligned up to wordSize
const int HeapWordsPerOop = heapOopSize/HeapWordSize; const uint HeapWordsPerOop = heapOopSize/HeapWordSize;
int old_res; uint old_res;
if (HeapWordsPerOop > 0) { if (HeapWordsPerOop > 0) {
old_res = length * HeapWordsPerOop; old_res = length * HeapWordsPerOop;
} else { } else {
old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord; old_res = align_size_up((uint)length, OopsPerHeapWord)/OopsPerHeapWord;
} }
#endif // ASSERT
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.");
#endif // ASSERT
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册