hotspot/src/share/vm/runtime/os.cpp
changeset 46644 a5813fb66270
parent 46625 edefffab74e2
child 46701 f559541c0daa
equal deleted inserted replaced
46643:cb5f289ba033 46644:a5813fb66270
   572 
   572 
   573 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
   573 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
   574   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   574   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   575   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   575   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   576 
   576 
   577 #ifdef ASSERT
   577   // Since os::malloc can be called when the libjvm.{dll,so} is
   578   // checking for the WatcherThread and crash_protection first
   578   // first loaded and we don't have a thread yet we must accept NULL also here.
   579   // since os::malloc can be called when the libjvm.{dll,so} is
   579   assert(!os::ThreadCrashProtection::is_crash_protected(Thread::current_or_null()),
   580   // first loaded and we don't have a thread yet.
   580          "malloc() not allowed when crash protection is set");
   581   // try to find the thread after we see that the watcher thread
       
   582   // exists and has crash protection.
       
   583   WatcherThread *wt = WatcherThread::watcher_thread();
       
   584   if (wt != NULL && wt->has_crash_protection()) {
       
   585     Thread* thread = Thread::current_or_null();
       
   586     if (thread == wt) {
       
   587       assert(!wt->has_crash_protection(),
       
   588           "Can't malloc with crash protection from WatcherThread");
       
   589     }
       
   590   }
       
   591 #endif
       
   592 
   581 
   593   if (size == 0) {
   582   if (size == 0) {
   594     // return a valid pointer if size is zero
   583     // return a valid pointer if size is zero
   595     // if NULL is returned the calling functions assume out of memory.
   584     // if NULL is returned the calling functions assume out of memory.
   596     size = 1;
   585     size = 1;