hotspot/src/share/vm/runtime/os.cpp
changeset 26561 e104c9397ca1
parent 25962 8f95d0407e21
child 26700 8107d0778244
equal deleted inserted replaced
26417:c55a863f2a7f 26561:e104c9397ca1
    51 #include "runtime/stubRoutines.hpp"
    51 #include "runtime/stubRoutines.hpp"
    52 #include "runtime/thread.inline.hpp"
    52 #include "runtime/thread.inline.hpp"
    53 #include "runtime/vm_version.hpp"
    53 #include "runtime/vm_version.hpp"
    54 #include "services/attachListener.hpp"
    54 #include "services/attachListener.hpp"
    55 #include "services/nmtCommon.hpp"
    55 #include "services/nmtCommon.hpp"
       
    56 #include "services/mallocTracker.hpp"
    56 #include "services/memTracker.hpp"
    57 #include "services/memTracker.hpp"
    57 #include "services/threadService.hpp"
    58 #include "services/threadService.hpp"
    58 #include "utilities/defaultStream.hpp"
    59 #include "utilities/defaultStream.hpp"
    59 #include "utilities/events.hpp"
    60 #include "utilities/events.hpp"
    60 
    61 
   568 
   569 
   569 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
   570 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
   570   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   571   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   571   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   572   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   572 
   573 
       
   574 #if INCLUDE_NMT
       
   575   // NMT can not track malloc allocation size > MAX_MALLOC_SIZE, which is
       
   576   // (1GB - 1) on 32-bit system. It is not an issue on 64-bit system, where
       
   577   // MAX_MALLOC_SIZE = ((1 << 62) - 1).
       
   578   // VM code does not have such large malloc allocation. However, it can come
       
   579   // Unsafe call.
       
   580   if (MemTracker::tracking_level() >= NMT_summary && size > MAX_MALLOC_SIZE) {
       
   581     return NULL;
       
   582   }
       
   583 #endif
       
   584 
   573 #ifdef ASSERT
   585 #ifdef ASSERT
   574   // checking for the WatcherThread and crash_protection first
   586   // checking for the WatcherThread and crash_protection first
   575   // since os::malloc can be called when the libjvm.{dll,so} is
   587   // since os::malloc can be called when the libjvm.{dll,so} is
   576   // first loaded and we don't have a thread yet.
   588   // first loaded and we don't have a thread yet.
   577   // try to find the thread after we see that the watcher thread
   589   // try to find the thread after we see that the watcher thread
   638 void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) {
   650 void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) {
   639   return os::realloc(memblock, size, flags, CALLER_PC);
   651   return os::realloc(memblock, size, flags, CALLER_PC);
   640 }
   652 }
   641 
   653 
   642 void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
   654 void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
       
   655 #if INCLUDE_NMT
       
   656   // See comments in os::malloc() above
       
   657   if (MemTracker::tracking_level() >= NMT_summary && size > MAX_MALLOC_SIZE) {
       
   658     return NULL;
       
   659   }
       
   660 #endif
       
   661 
   643 #ifndef ASSERT
   662 #ifndef ASSERT
   644   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   663   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   645   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   664   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   646    // NMT support
   665    // NMT support
   647   void* membase = MemTracker::record_free(memblock);
   666   void* membase = MemTracker::record_free(memblock);