8013726: runtime/memory/ReserveMemory.java fails due to 'assert(bytes % os::vm_allocation_granularity() == 0) failed: reserve block size'

Fix regression test to work on all platforms

Reviewed-by: ctornqvi, dholmes
This commit is contained in:
Mikael Vidstedt 2013-05-21 09:43:23 -07:00
parent a462587e4b
commit de93893f4e
3 changed files with 22 additions and 18 deletions

View file

@ -37,6 +37,7 @@
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#include "utilities/exceptions.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/g1/concurrentMark.hpp"
@ -330,8 +331,18 @@ WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
WB_END
WB_ENTRY(jlong, WB_ReserveMemory(JNIEnv* env, jobject o, jlong size))
return (jlong)os::reserve_memory(size, NULL, 0);
WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
// static+volatile in order to force the read to happen
// (not be eliminated by the compiler)
static char c;
static volatile char* p;
p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0);
if (p == NULL) {
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory");
}
c = *p;
WB_END
//Some convenience methods to deal with objects from java
@ -437,7 +448,7 @@ static JNINativeMethod methods[] = {
{CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable },
{CC"fullGC", CC"()V", (void*)&WB_FullGC },
{CC"reserveMemory", CC"(J)J", (void*)&WB_ReserveMemory },
{CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory },
};
#undef CC