changeset 6693:ac58063ca713

8011661, PR3702: Insufficient memory message says "malloc" when sometimes it should say "mmap" Reviewed-by: coleenp, zgu, hseigel
author ccheung
date Wed, 20 Feb 2019 01:05:45 +0000
parents 976e1f2aa48e
children 0553e00f9404
files src/os/aix/vm/os_aix.cpp src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/os/solaris/vm/os_solaris.cpp src/os/windows/vm/os_windows.cpp src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp src/os_cpu/linux_x86/vm/os_linux_x86.cpp src/os_cpu/linux_zero/vm/os_linux_zero.cpp src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp src/share/vm/asm/assembler.cpp src/share/vm/code/stubs.cpp src/share/vm/code/vtableStubs.cpp src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp src/share/vm/interpreter/interpreterRuntime.cpp src/share/vm/memory/allocation.cpp src/share/vm/memory/allocation.inline.hpp src/share/vm/memory/blockOffsetTable.cpp src/share/vm/prims/jvmtiTagMap.cpp src/share/vm/prims/methodHandles.cpp src/share/vm/runtime/objectMonitor.cpp src/share/vm/runtime/stubRoutines.cpp src/share/vm/runtime/synchronizer.cpp src/share/vm/utilities/debug.cpp src/share/vm/utilities/debug.hpp src/share/vm/utilities/vmError.cpp src/share/vm/utilities/vmError.hpp src/share/vm/utilities/workgroup.cpp
diffstat 36 files changed, 86 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/aix/vm/os_aix.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os/aix/vm/os_aix.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -2139,7 +2139,7 @@
   if (!pd_commit_memory(addr, size, exec)) {
     // add extra info in product mode for vm_exit_out_of_memory():
     PRODUCT_ONLY(warn_fail_commit_memory(addr, size, exec, errno);)
-    vm_exit_out_of_memory(size, mesg);
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, mesg);
   }
 }
 
--- a/src/os/bsd/vm/os_bsd.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os/bsd/vm/os_bsd.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -2981,7 +2981,7 @@
   if (!pd_commit_memory(addr, size, exec)) {
     // add extra info in product mode for vm_exit_out_of_memory():
     PRODUCT_ONLY(warn_fail_commit_memory(addr, size, exec, errno);)
-    vm_exit_out_of_memory(size, mesg);
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, mesg);
   }
 }
 
--- a/src/os/linux/vm/os_linux.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os/linux/vm/os_linux.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -2825,7 +2825,7 @@
 
   if (!recoverable_mmap_error(err)) {
     warn_fail_commit_memory(addr, size, exec, err);
-    vm_exit_out_of_memory(size, "committing reserved memory.");
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "committing reserved memory.");
   }
 
   return err;
@@ -2842,7 +2842,7 @@
   if (err != 0) {
     // the caller wants all commit errors to exit with the specified mesg:
     warn_fail_commit_memory(addr, size, exec, err);
-    vm_exit_out_of_memory(size, mesg);
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, mesg);
   }
 }
 
@@ -2878,7 +2878,7 @@
   if (err != 0) {
     // the caller wants all commit errors to exit with the specified mesg:
     warn_fail_commit_memory(addr, size, alignment_hint, exec, err);
-    vm_exit_out_of_memory(size, mesg);
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, mesg);
   }
 }
 
--- a/src/os/solaris/vm/os_solaris.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os/solaris/vm/os_solaris.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -833,7 +833,7 @@
       // allocate new buffer and initialize
       info = (Dl_serinfo*)malloc(_info.dls_size);
       if (info == NULL) {
-        vm_exit_out_of_memory(_info.dls_size,
+        vm_exit_out_of_memory(_info.dls_size, OOM_MALLOC_ERROR,
                               "init_system_properties_values info");
       }
       info->dls_size = _info.dls_size;
@@ -875,7 +875,7 @@
       common_path = malloc(bufsize);
       if (common_path == NULL) {
         free(info);
-        vm_exit_out_of_memory(bufsize,
+        vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
                               "init_system_properties_values common_path");
       }
       sprintf(common_path, COMMON_DIR "/lib/%s", cpu_arch);
@@ -888,7 +888,7 @@
       if (library_path == NULL) {
         free(info);
         free(common_path);
-        vm_exit_out_of_memory(bufsize,
+        vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
                               "init_system_properties_values library_path");
       }
       library_path[0] = '\0';
@@ -1632,7 +1632,8 @@
   // %%% this is used only in threadLocalStorage.cpp
   if (thr_setspecific((thread_key_t)index, value)) {
     if (errno == ENOMEM) {
-       vm_exit_out_of_memory(SMALLINT, "thr_setspecific: out of swap space");
+       vm_exit_out_of_memory(SMALLINT, OOM_MALLOC_ERROR,
+                             "thr_setspecific: out of swap space");
     } else {
       fatal(err_msg("os::thread_local_storage_at_put: thr_setspecific failed "
                     "(%s)", strerror(errno)));
@@ -2874,7 +2875,7 @@
 
   if (!recoverable_mmap_error(err)) {
     warn_fail_commit_memory(addr, bytes, exec, err);
-    vm_exit_out_of_memory(bytes, "committing reserved memory.");
+    vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "committing reserved memory.");
   }
 
   return err;
@@ -2891,7 +2892,7 @@
   if (err != 0) {
     // the caller wants all commit errors to exit with the specified mesg:
     warn_fail_commit_memory(addr, bytes, exec, err);
-    vm_exit_out_of_memory(bytes, mesg);
+    vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg);
   }
 }
 
@@ -2937,7 +2938,7 @@
   if (err != 0) {
     // the caller wants all commit errors to exit with the specified mesg:
     warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err);
-    vm_exit_out_of_memory(bytes, mesg);
+    vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg);
   }
 }
 
--- a/src/os/windows/vm/os_windows.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os/windows/vm/os_windows.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -3325,7 +3325,7 @@
   assert(mesg != NULL, "mesg must be specified");
   if (!pd_commit_memory(addr, size, exec)) {
     warn_fail_commit_memory(addr, size, exec);
-    vm_exit_out_of_memory(size, mesg);
+    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, mesg);
   }
 }
 
--- a/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -982,7 +982,7 @@
      // JVM needs to know exact stack location, abort if it fails
      if (rslt != 0) {
        if (rslt == ENOMEM) {
-         vm_exit_out_of_memory(0, "pthread_getattr_np");
+         vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
        } else {
          fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
        }
--- a/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -372,7 +372,7 @@
   int res = pthread_getattr_np(pthread_self(), &attr);
   if (res != 0) {
     if (res == ENOMEM) {
-      vm_exit_out_of_memory(0, "pthread_getattr_np");
+      vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
     }
     else {
       fatal(err_msg("pthread_getattr_np failed with errno = " INT32_FORMAT,
--- a/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -550,7 +550,7 @@
      // JVM needs to know exact stack location, abort if it fails
      if (rslt != 0) {
        if (rslt == ENOMEM) {
-         vm_exit_out_of_memory(0, "pthread_getattr_np");
+         vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
        } else {
          fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
        }
--- a/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -529,7 +529,7 @@
     // JVM needs to know exact stack location, abort if it fails
     if (rslt != 0) {
       if (rslt == ENOMEM) {
-        vm_exit_out_of_memory(0, "pthread_getattr_np");
+        vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
       } else {
         fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
       }
--- a/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -175,7 +175,7 @@
     // JVM needs to know exact stack location, abort if it fails
     if (rslt != 0) {
       if (rslt == ENOMEM) {
-        vm_exit_out_of_memory(0, "pthread_getattr_np");
+        vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
       } else {
         fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
       }
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -716,7 +716,7 @@
      // JVM needs to know exact stack location, abort if it fails
      if (rslt != 0) {
        if (rslt == ENOMEM) {
-         vm_exit_out_of_memory(0, "pthread_getattr_np");
+         vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
        } else {
          fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
        }
--- a/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -358,7 +358,7 @@
   int res = pthread_getattr_np(pthread_self(), &attr);
   if (res != 0) {
     if (res == ENOMEM) {
-      vm_exit_out_of_memory(0, "pthread_getattr_np");
+      vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
     }
     else {
       fatal(err_msg("pthread_getattr_np failed with errno = %d", res));
--- a/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -579,7 +579,7 @@
   // on the thread stack, which could get a mapping error when touched.
   address addr = (address) info->si_addr;
   if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
-    vm_exit_out_of_memory(0, "Out of swap space to map in thread stack.");
+    vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack.");
   }
 
   VMError err(t, sig, pc, info, ucVoid);
--- a/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -734,7 +734,7 @@
   // on the thread stack, which could get a mapping error when touched.
   address addr = (address) info->si_addr;
   if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
-    vm_exit_out_of_memory(0, "Out of swap space to map in thread stack.");
+    vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack.");
   }
 
   VMError err(t, sig, pc, info, ucVoid);
--- a/src/share/vm/asm/assembler.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/asm/assembler.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -66,7 +66,7 @@
   _oop_recorder= code->oop_recorder();
   DEBUG_ONLY( _short_branch_delta = 0; )
   if (_code_begin == NULL)  {
-    vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s",
+    vm_exit_out_of_memory(0, OOM_MMAP_ERROR, err_msg("CodeCache: no room for %s",
                                      code->name()));
   }
 }
--- a/src/share/vm/code/stubs.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/code/stubs.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -67,7 +67,7 @@
   intptr_t size = round_to(buffer_size, 2*BytesPerWord);
   BufferBlob* blob = BufferBlob::create(name, size);
   if( blob == NULL) {
-    vm_exit_out_of_memory(size, err_msg("CodeCache: no room for %s", name));
+    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, err_msg("CodeCache: no room for %s", name));
   }
   _stub_interface  = stub_interface;
   _buffer_size     = blob->content_size();
--- a/src/share/vm/code/vtableStubs.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/code/vtableStubs.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -60,7 +60,7 @@
     const int bytes = chunk_factor * real_size + pd_code_alignment();
     BufferBlob* blob = BufferBlob::create("vtable chunks", bytes);
     if (blob == NULL) {
-      vm_exit_out_of_memory(bytes, "CodeCache: no room for vtable chunks");
+      vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "CodeCache: no room for vtable chunks");
     }
     _chunk = blob->content_begin();
     _chunk_end = _chunk + bytes;
--- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -77,7 +77,7 @@
     assert(delta > 0, "just checking");
     if (!_vs.expand_by(delta)) {
       // Do better than this for Merlin
-      vm_exit_out_of_memory(delta, "offset table expansion");
+      vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
     }
     assert(_vs.high() == high + delta, "invalid expansion");
     // Initialization of the contents is left to the
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -1806,7 +1806,7 @@
     if (G1ExitOnExpansionFailure &&
         _g1_storage.uncommitted_size() >= aligned_expand_bytes) {
       // We had head room...
-      vm_exit_out_of_memory(aligned_expand_bytes, "G1 heap expansion");
+      vm_exit_out_of_memory(aligned_expand_bytes, OOM_MMAP_ERROR, "G1 heap expansion");
     }
   }
   return successful;
@@ -3781,7 +3781,7 @@
   uint array_length = g1_policy()->young_cset_region_length();
   _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
   if (_surviving_young_words == NULL) {
-    vm_exit_out_of_memory(sizeof(size_t) * array_length,
+    vm_exit_out_of_memory(sizeof(size_t) * array_length, OOM_MALLOC_ERROR,
                           "Not enough space for young surv words summary.");
   }
   memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
@@ -4589,7 +4589,7 @@
                       PADDING_ELEM_NUM;
   _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
   if (_surviving_young_words_base == NULL)
-    vm_exit_out_of_memory(array_length * sizeof(size_t),
+    vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR,
                           "Not enough space for young surv histo.");
   _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
   memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
--- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -286,7 +286,7 @@
   _fine_grain_regions = new PerRegionTablePtr[_max_fine_entries];
 
   if (_fine_grain_regions == NULL) {
-    vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries,
+    vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR,
                           "Failed to allocate _fine_grain_entries.");
   }
 
--- a/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -43,7 +43,7 @@
   _time_stamp_index(0)
 {
   if (!os::create_thread(this, os::pgc_thread))
-    vm_exit_out_of_memory(0, "Cannot create GC thread. Out of system resources.");
+    vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources.");
 
   if (PrintGCTaskTimeStamps) {
     _time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
--- a/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -99,7 +99,7 @@
     // Expand
     size_t expand_by = requested_blocks_size_in_bytes - current_blocks_size_in_bytes;
     if (!_virtual_space.expand_by(expand_by)) {
-      vm_exit_out_of_memory(expand_by, "object start array expansion");
+      vm_exit_out_of_memory(expand_by, OOM_MMAP_ERROR, "object start array expansion");
     }
     // Clear *only* the newly allocated region
     memset(_blocks_region.end(), clean_block, expand_by);
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -1096,7 +1096,7 @@
     return;
   }
   if (set_handler_blob() == NULL) {
-    vm_exit_out_of_memory(blob_size, "native signature handlers");
+    vm_exit_out_of_memory(blob_size, OOM_MALLOC_ERROR, "native signature handlers");
   }
 
   BufferBlob* bb = BufferBlob::create("Signature Handler Temp Buffer",
--- a/src/share/vm/memory/allocation.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/memory/allocation.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -211,7 +211,7 @@
     }
     if (p == NULL) p = os::malloc(bytes, mtChunk, CURRENT_PC);
     if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
-      vm_exit_out_of_memory(bytes, "ChunkPool::allocate");
+      vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "ChunkPool::allocate");
     }
     return p;
   }
@@ -323,7 +323,7 @@
    default: {
      void *p =  os::malloc(bytes, mtChunk, CALLER_PC);
      if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
-       vm_exit_out_of_memory(bytes, "Chunk::new");
+       vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "Chunk::new");
      }
      return p;
    }
@@ -484,7 +484,7 @@
 }
 
 void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
-  vm_exit_out_of_memory(sz, whence);
+  vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, whence);
 }
 
 // Grow a new Chunk
--- a/src/share/vm/memory/allocation.inline.hpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/memory/allocation.inline.hpp	Wed Feb 20 01:05:45 2019 +0000
@@ -60,8 +60,9 @@
   #ifdef ASSERT
   if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
   #endif
-  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM)
-    vm_exit_out_of_memory(size, "AllocateHeap");
+  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
+  }
   return p;
 }
 
@@ -74,8 +75,9 @@
   #ifdef ASSERT
   if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
   #endif
-  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM)
-    vm_exit_out_of_memory(size, "ReallocateHeap");
+  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
+  }
   return p;
 }
 
@@ -135,7 +137,7 @@
 
   _addr = os::reserve_memory(_size, NULL, alignment, F);
   if (_addr == NULL) {
-    vm_exit_out_of_memory(_size, "Allocator (reserve)");
+    vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (reserve)");
   }
 
   os::commit_memory_or_exit(_addr, _size, !ExecMem, "Allocator (commit)");
--- a/src/share/vm/memory/blockOffsetTable.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/memory/blockOffsetTable.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -80,7 +80,7 @@
     assert(delta > 0, "just checking");
     if (!_vs.expand_by(delta)) {
       // Do better than this for Merlin
-      vm_exit_out_of_memory(delta, "offset table expansion");
+      vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
     }
     assert(_vs.high() == high + delta, "invalid expansion");
   } else {
--- a/src/share/vm/prims/jvmtiTagMap.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/prims/jvmtiTagMap.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -152,7 +152,8 @@
     size_t s = initial_size * sizeof(JvmtiTagHashmapEntry*);
     _table = (JvmtiTagHashmapEntry**)os::malloc(s, mtInternal);
     if (_table == NULL) {
-      vm_exit_out_of_memory(s, "unable to allocate initial hashtable for jvmti object tags");
+      vm_exit_out_of_memory(s, OOM_MALLOC_ERROR,
+        "unable to allocate initial hashtable for jvmti object tags");
     }
     for (int i=0; i<initial_size; i++) {
       _table[i] = NULL;
--- a/src/share/vm/prims/methodHandles.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/prims/methodHandles.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -68,7 +68,8 @@
   TraceTime timer("MethodHandles adapters generation", TraceStartupTime);
   _adapter_code = MethodHandlesAdapterBlob::create(MethodHandles::adapter_code_size());
   if (_adapter_code == NULL)
-    vm_exit_out_of_memory(MethodHandles::adapter_code_size(), "CodeCache: no room for MethodHandles adapters");
+    vm_exit_out_of_memory(MethodHandles::adapter_code_size(), OOM_MALLOC_ERROR,
+                          "CodeCache: no room for MethodHandles adapters");
   {
     CodeBuffer code(_adapter_code);
     MethodHandlesAdapterGenerator g(&code);
--- a/src/share/vm/runtime/objectMonitor.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/runtime/objectMonitor.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -2542,7 +2542,7 @@
   size_t sz = strlen (SyncKnobs) ;
   char * knobs = (char *) malloc (sz + 2) ;
   if (knobs == NULL) {
-     vm_exit_out_of_memory (sz + 2, "Parse SyncKnobs") ;
+     vm_exit_out_of_memory (sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs") ;
      guarantee (0, "invariant") ;
   }
   strcpy (knobs, SyncKnobs) ;
--- a/src/share/vm/runtime/stubRoutines.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/runtime/stubRoutines.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -156,7 +156,7 @@
     TraceTime timer("StubRoutines generation 1", TraceStartupTime);
     _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
     if (_code1 == NULL) {
-      vm_exit_out_of_memory(code_size1, "CodeCache: no room for StubRoutines (1)");
+      vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
     }
     CodeBuffer buffer(_code1);
     StubGenerator_generate(&buffer, false);
@@ -208,7 +208,7 @@
     TraceTime timer("StubRoutines generation 2", TraceStartupTime);
     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
     if (_code2 == NULL) {
-      vm_exit_out_of_memory(code_size2, "CodeCache: no room for StubRoutines (2)");
+      vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
     }
     CodeBuffer buffer(_code2);
     StubGenerator_generate(&buffer, true);
--- a/src/share/vm/runtime/synchronizer.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/runtime/synchronizer.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -1019,7 +1019,8 @@
         // We might be able to induce a STW safepoint and scavenge enough
         // objectMonitors to permit progress.
         if (temp == NULL) {
-            vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), "Allocate ObjectMonitors") ;
+            vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), OOM_MALLOC_ERROR,
+                                   "Allocate ObjectMonitors");
         }
 
         // Format the block.
--- a/src/share/vm/utilities/debug.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/utilities/debug.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -240,7 +240,7 @@
 static jint _exiting_out_of_mem = 0;
 
 void report_vm_out_of_memory(const char* file, int line, size_t size,
-                             const char* message) {
+                             VMErrorType vm_err_type, const char* message) {
   if (Debugging) return;
 
   // We try to gather additional information for the first out of memory
@@ -253,7 +253,7 @@
 
   if (first_time_here) {
     Thread* thread = ThreadLocalStorage::get_thread_slow();
-    VMError(thread, file, line, size, message).report_and_die();
+    VMError(thread, file, line, size, vm_err_type, message).report_and_die();
   }
 
   // Dump core and abort
@@ -376,7 +376,7 @@
                            msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
                            msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
                            msg, eol, msg, eol, msg, eol, msg, eol, msg));
-    case  8: vm_exit_out_of_memory(num, "ChunkPool::allocate");
+    case  8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
     case  9: ShouldNotCallThis();
     case 10: ShouldNotReachHere();
     case 11: Unimplemented();
--- a/src/share/vm/utilities/debug.hpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/utilities/debug.hpp	Wed Feb 20 01:05:45 2019 +0000
@@ -174,9 +174,9 @@
 } while (0)
 
 // out of memory
-#define vm_exit_out_of_memory(size, msg)                                     \
+#define vm_exit_out_of_memory(size, vm_err_type, msg)                        \
 do {                                                                         \
-  report_vm_out_of_memory(__FILE__, __LINE__, size, msg);                    \
+  report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, msg);       \
   BREAKPOINT;                                                                \
 } while (0)
 
@@ -204,12 +204,20 @@
   BREAKPOINT;                                                                \
 } while (0);
 
+
+// types of VM error - originally in vmError.hpp
+enum VMErrorType {
+  INTERNAL_ERROR   = 0xe0000000,
+  OOM_MALLOC_ERROR = 0xe0000001,
+  OOM_MMAP_ERROR   = 0xe0000002
+};
+
 // error reporting helper functions
 void report_vm_error(const char* file, int line, const char* error_msg,
                      const char* detail_msg = NULL);
 void report_fatal(const char* file, int line, const char* message);
 void report_vm_out_of_memory(const char* file, int line, size_t size,
-                             const char* message);
+                             VMErrorType vm_err_type, const char* message);
 void report_should_not_call(const char* file, int line);
 void report_should_not_reach_here(const char* file, int line);
 void report_unimplemented(const char* file, int line);
--- a/src/share/vm/utilities/vmError.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/utilities/vmError.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -102,7 +102,7 @@
                  const char* message, const char * detail_msg)
 {
   _thread = thread;
-  _id = internal_error;     // Value that's not an OS exception/signal
+  _id = INTERNAL_ERROR;     // Value that's not an OS exception/signal
   _filename = filename;
   _lineno = lineno;
   _message = message;
@@ -121,9 +121,9 @@
 
 // Constructor for OOM errors
 VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size,
-                 const char* message) {
+                 VMErrorType vm_err_type, const char* message) {
     _thread = thread;
-    _id = oom_error;     // Value that's not an OS exception/signal
+    _id = vm_err_type; // Value that's not an OS exception/signal
     _filename = filename;
     _lineno = lineno;
     _message = message;
@@ -144,7 +144,7 @@
 // Constructor for non-fatal errors
 VMError::VMError(const char* message) {
     _thread = NULL;
-    _id = internal_error;     // Value that's not an OS exception/signal
+    _id = INTERNAL_ERROR;     // Value that's not an OS exception/signal
     _filename = NULL;
     _lineno = 0;
     _message = message;
@@ -367,9 +367,12 @@
   STEP(15, "(printing type of error)")
 
      switch(_id) {
-       case oom_error:
+       case OOM_MALLOC_ERROR:
+       case OOM_MMAP_ERROR:
          if (_size) {
-           st->print("# Native memory allocation (malloc) failed to allocate ");
+           st->print("# Native memory allocation ");
+           st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
+                                                 "(mmap) failed to map ");
            jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
            st->print("%s", buf);
            st->print(" bytes");
@@ -402,7 +405,7 @@
            return;  // that's enough for the screen
          }
          break;
-       case internal_error:
+       case INTERNAL_ERROR:
        default:
          break;
      }
--- a/src/share/vm/utilities/vmError.hpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/utilities/vmError.hpp	Wed Feb 20 01:05:45 2019 +0000
@@ -38,10 +38,6 @@
   friend class VM_ReportJavaOutOfMemory;
   friend class Decoder;
 
-  enum ErrorType {
-    internal_error = 0xe0000000,
-    oom_error      = 0xe0000001
-  };
   int          _id;          // Solaris/Linux signals: 0 - SIGRTMAX
                              // Windows exceptions: 0xCxxxxxxx system errors
                              //                     0x8xxxxxxx system warnings
@@ -100,13 +96,16 @@
   // accessor
   const char* message() const    { return _message; }
   const char* detail_msg() const { return _detail_msg; }
-  bool should_report_bug(unsigned int id) { return id != oom_error; }
+  bool should_report_bug(unsigned int id) {
+    return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
+  }
 
 #ifdef PRODUCT
   friend void _ps();
 #endif // PRODUCT
 
 public:
+
   // Constructor for crashes
   VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
           void* context);
@@ -116,7 +115,7 @@
 
   // Constructor for VM OOM errors
   VMError(Thread* thread, const char* filename, int lineno, size_t size,
-          const char* message);
+          VMErrorType vm_err_type, const char* message);
   // Constructor for non-fatal errors
   VMError(const char* message);
 
--- a/src/share/vm/utilities/workgroup.cpp	Thu Jan 10 21:00:11 2013 -0500
+++ b/src/share/vm/utilities/workgroup.cpp	Wed Feb 20 01:05:45 2019 +0000
@@ -79,7 +79,7 @@
   }
   _gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal);
   if (gang_workers() == NULL) {
-    vm_exit_out_of_memory(0, "Cannot create GangWorker array.");
+    vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array.");
     return false;
   }
   os::ThreadType worker_type;
@@ -93,7 +93,8 @@
     assert(new_worker != NULL, "Failed to allocate GangWorker");
     _gang_workers[worker] = new_worker;
     if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
-      vm_exit_out_of_memory(0, "Cannot create worker GC thread. Out of system resources.");
+      vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
+              "Cannot create worker GC thread. Out of system resources.");
       return false;
     }
     if (!DisableStartThread) {