comparison src/share/vm/runtime/os.cpp @ 8808:81d1b58c078f

8010396: checking MallocMaxTestWords in testMalloc() function is redundant Summary: Remove redundant checks in testMalloc and add assert. Reviewed-by: dcubed, coleenp, dholmes
author rdurbin
date Wed, 20 Mar 2013 20:44:54 -0700
parents eca90b8a06eb
children b9a918201d47 c18152e0554e
comparison
equal deleted inserted replaced
8806:79259e97a072 8808:81d1b58c078f
575 // 575 //
576 // This function supports testing of the malloc out of memory 576 // This function supports testing of the malloc out of memory
577 // condition without really running the system out of memory. 577 // condition without really running the system out of memory.
578 // 578 //
579 static u_char* testMalloc(size_t alloc_size) { 579 static u_char* testMalloc(size_t alloc_size) {
580 580 assert(MallocMaxTestWords > 0, "sanity check");
581 if (MallocMaxTestWords > 0 && 581
582 (cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) { 582 if ((cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) {
583 return NULL; 583 return NULL;
584 } 584 }
585 585
586 u_char* ptr = (u_char*)::malloc(alloc_size); 586 u_char* ptr = (u_char*)::malloc(alloc_size);
587 587
588 if (MallocMaxTestWords > 0 && (ptr != NULL)) { 588 if (ptr != NULL) {
589 Atomic::add(((jint) (alloc_size / BytesPerWord)), 589 Atomic::add(((jint) (alloc_size / BytesPerWord)),
590 (volatile jint *) &cur_malloc_words); 590 (volatile jint *) &cur_malloc_words);
591 } 591 }
592 return ptr; 592 return ptr;
593 } 593 }