提交 6c178b55 编写于 作者: S stefank

7125503: Compiling collectedHeap.cpp fails with -Werror=int-to-pointer-cast with g++ 4.6.1

Summary: Used uintptr_t and void* for all the casts and checks in test_is_in.
Reviewed-by: tonyp, jmasa
上级 1baf2cd4
......@@ -478,18 +478,22 @@ oop CollectedHeap::Class_obj_allocate(KlassHandle klass, int size, KlassHandle r
void CollectedHeap::test_is_in() {
CollectedHeap* heap = Universe::heap();
uintptr_t epsilon = (uintptr_t) MinObjAlignment;
uintptr_t heap_start = (uintptr_t) heap->_reserved.start();
uintptr_t heap_end = (uintptr_t) heap->_reserved.end();
// Test that NULL is not in the heap.
assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
// Test that a pointer to before the heap start is reported as outside the heap.
assert(heap->_reserved.start() >= (void*)MinObjAlignment, "sanity");
void* before_heap = (void*)((intptr_t)heap->_reserved.start() - MinObjAlignment);
assert(heap_start >= ((uintptr_t)NULL + epsilon), "sanity");
void* before_heap = (void*)(heap_start - epsilon);
assert(!heap->is_in(before_heap),
err_msg("before_heap: " PTR_FORMAT " is unexpectedly in the heap", before_heap));
// Test that a pointer to after the heap end is reported as outside the heap.
assert(heap->_reserved.end() <= (void*)(uintptr_t(-1) - (uint)MinObjAlignment), "sanity");
void* after_heap = (void*)((intptr_t)heap->_reserved.end() + MinObjAlignment);
assert(heap_end <= ((uintptr_t)-1 - epsilon), "sanity");
void* after_heap = (void*)(heap_end + epsilon);
assert(!heap->is_in(after_heap),
err_msg("after_heap: " PTR_FORMAT " is unexpectedly in the heap", after_heap));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册