hotspot/src/share/vm/runtime/os.cpp
changeset 18943 7d0ef675e808
parent 18086 f44cf213a775
child 19694 84bcddefd0d7
child 19553 9bbd930be684
child 22823 40b2c6c30123
equal deleted inserted replaced
18942:705506c1bf49 18943:7d0ef675e808
   593 
   593 
   594 void* os::malloc(size_t size, MEMFLAGS memflags, address caller) {
   594 void* os::malloc(size_t size, MEMFLAGS memflags, address caller) {
   595   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   595   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   596   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   596   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   597 
   597 
       
   598 #ifdef ASSERT
       
   599   // checking for the WatcherThread and crash_protection first
       
   600   // since os::malloc can be called when the libjvm.{dll,so} is
       
   601   // first loaded and we don't have a thread yet.
       
   602   // try to find the thread after we see that the watcher thread
       
   603   // exists and has crash protection.
       
   604   WatcherThread *wt = WatcherThread::watcher_thread();
       
   605   if (wt != NULL && wt->has_crash_protection()) {
       
   606     Thread* thread = ThreadLocalStorage::get_thread_slow();
       
   607     if (thread == wt) {
       
   608       assert(!wt->has_crash_protection(),
       
   609           "Can't malloc with crash protection from WatcherThread");
       
   610     }
       
   611   }
       
   612 #endif
       
   613 
   598   if (size == 0) {
   614   if (size == 0) {
   599     // return a valid pointer if size is zero
   615     // return a valid pointer if size is zero
   600     // if NULL is returned the calling functions assume out of memory.
   616     // if NULL is returned the calling functions assume out of memory.
   601     size = 1;
   617     size = 1;
   602   }
   618   }