8010396: checking MallocMaxTestWords in testMalloc() function is redundant
authorrdurbin
Wed, 20 Mar 2013 20:44:54 -0700
changeset 16434 67b70a1edf27
parent 16432 1c1a3b0a15df
child 16435 9d574995aabb
8010396: checking MallocMaxTestWords in testMalloc() function is redundant Summary: Remove redundant checks in testMalloc and add assert. Reviewed-by: dcubed, coleenp, dholmes
hotspot/src/share/vm/runtime/os.cpp
--- a/hotspot/src/share/vm/runtime/os.cpp	Wed Mar 20 12:20:10 2013 -0400
+++ b/hotspot/src/share/vm/runtime/os.cpp	Wed Mar 20 20:44:54 2013 -0700
@@ -577,15 +577,15 @@
 // condition without really running the system out of memory.
 //
 static u_char* testMalloc(size_t alloc_size) {
+  assert(MallocMaxTestWords > 0, "sanity check");
 
-  if (MallocMaxTestWords > 0 &&
-      (cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) {
+  if ((cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) {
     return NULL;
   }
 
   u_char* ptr = (u_char*)::malloc(alloc_size);
 
-  if (MallocMaxTestWords > 0 && (ptr != NULL)) {
+  if (ptr != NULL) {
     Atomic::add(((jint) (alloc_size / BytesPerWord)),
                 (volatile jint *) &cur_malloc_words);
   }