8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
authordholmes
Tue, 24 Sep 2019 03:28:42 -0400
changeset 58282 03fce7b04b42
parent 58281 49836127542b
child 58283 cdce40c3286f
8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen Reviewed-by: lkorinth, hseigel, thartmann, dnsimon
src/hotspot/os/aix/os_perf_aix.cpp
src/hotspot/os/bsd/os_perf_bsd.cpp
src/hotspot/os/linux/os_perf_linux.cpp
src/hotspot/os/solaris/os_perf_solaris.cpp
src/hotspot/os/windows/os_perf_windows.cpp
src/hotspot/os/windows/os_windows.cpp
src/hotspot/share/aot/aotCodeHeap.cpp
src/hotspot/share/aot/aotLoader.cpp
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
src/hotspot/share/prims/unsafe.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/os.cpp
src/hotspot/share/runtime/thread.cpp
src/hotspot/share/runtime/thread.hpp
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
--- a/src/hotspot/os/aix/os_perf_aix.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/aix/os_perf_aix.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -445,9 +445,6 @@
 bool CPUPerformanceInterface::CPUPerformance::initialize() {
   size_t array_entry_count = _counters.nProcs + 1;
   _counters.cpus = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
-  if (NULL == _counters.cpus) {
-    return false;
-  }
   memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
 
   // For the CPU load total
@@ -535,7 +532,7 @@
 
 bool CPUPerformanceInterface::initialize() {
   _impl = new CPUPerformanceInterface::CPUPerformance();
-  return NULL == _impl ? false : _impl->initialize();
+  return _impl->initialize();
 }
 
 CPUPerformanceInterface::~CPUPerformanceInterface() {
@@ -688,19 +685,17 @@
     }
     if (size > 0) {
       cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
-      if (cmdline != NULL) {
-        cmdline[0] = '\0';
-        if (fseek(fp, 0, SEEK_SET) == 0) {
-          if (fread(cmdline, 1, size, fp) == size) {
-            // the file has the arguments separated by '\0',
-            // so we translate '\0' to ' '
-            for (size_t i = 0; i < size; i++) {
-              if (cmdline[i] == '\0') {
-                cmdline[i] = ' ';
-              }
+      cmdline[0] = '\0';
+      if (fseek(fp, 0, SEEK_SET) == 0) {
+        if (fread(cmdline, 1, size, fp) == size) {
+          // the file has the arguments separated by '\0',
+          // so we translate '\0' to ' '
+          for (size_t i = 0; i < size; i++) {
+            if (cmdline[i] == '\0') {
+              cmdline[i] = ' ';
             }
-            cmdline[size] = '\0';
           }
+          cmdline[size] = '\0';
         }
       }
     }
@@ -790,7 +785,7 @@
 
 bool SystemProcessInterface::SystemProcesses::initialize() {
   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
-  return NULL == _iterator ? false : _iterator->initialize();
+  return _iterator->initialize();
 }
 
 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
@@ -837,7 +832,7 @@
 
 bool SystemProcessInterface::initialize() {
   _impl = new SystemProcessInterface::SystemProcesses();
-  return NULL == _impl ? false : _impl->initialize();
+  return _impl->initialize();
 }
 
 SystemProcessInterface::~SystemProcessInterface() {
@@ -852,15 +847,11 @@
 
 bool CPUInformationInterface::initialize() {
   _cpu_info = new CPUInformation();
-  if (NULL == _cpu_info) {
-    return false;
-  }
   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
-
   return true;
 }
 
@@ -928,7 +919,7 @@
 
 bool NetworkPerformanceInterface::initialize() {
   _impl = new NetworkPerformanceInterface::NetworkPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
--- a/src/hotspot/os/bsd/os_perf_bsd.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/bsd/os_perf_bsd.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -234,7 +234,7 @@
 
 bool CPUPerformanceInterface::initialize() {
   _impl = new CPUPerformanceInterface::CPUPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 CPUPerformanceInterface::~CPUPerformanceInterface() {
@@ -355,7 +355,7 @@
 
 bool SystemProcessInterface::initialize() {
   _impl = new SystemProcessInterface::SystemProcesses();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 SystemProcessInterface::~SystemProcessInterface() {
@@ -370,16 +370,11 @@
 
 bool CPUInformationInterface::initialize() {
   _cpu_info = new CPUInformation();
-
-  if (NULL == _cpu_info) {
-    return false;
-  }
   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
-
   return true;
 }
 
@@ -483,7 +478,7 @@
 
 bool NetworkPerformanceInterface::initialize() {
   _impl = new NetworkPerformanceInterface::NetworkPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
--- a/src/hotspot/os/linux/os_perf_linux.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/linux/os_perf_linux.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -505,9 +505,6 @@
 bool CPUPerformanceInterface::CPUPerformance::initialize() {
   size_t array_entry_count = _counters.nProcs + 1;
   _counters.cpus = NEW_C_HEAP_ARRAY(os::Linux::CPUPerfTicks, array_entry_count, mtInternal);
-  if (NULL == _counters.cpus) {
-    return false;
-  }
   memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
 
   // For the CPU load total
@@ -595,7 +592,7 @@
 
 bool CPUPerformanceInterface::initialize() {
   _impl = new CPUPerformanceInterface::CPUPerformance();
-  return NULL == _impl ? false : _impl->initialize();
+  return _impl->initialize();
 }
 
 CPUPerformanceInterface::~CPUPerformanceInterface() {
@@ -748,19 +745,17 @@
     }
     if (size > 0) {
       cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
-      if (cmdline != NULL) {
-        cmdline[0] = '\0';
-        if (fseek(fp, 0, SEEK_SET) == 0) {
-          if (fread(cmdline, 1, size, fp) == size) {
-            // the file has the arguments separated by '\0',
-            // so we translate '\0' to ' '
-            for (size_t i = 0; i < size; i++) {
-              if (cmdline[i] == '\0') {
-                cmdline[i] = ' ';
-              }
+      cmdline[0] = '\0';
+      if (fseek(fp, 0, SEEK_SET) == 0) {
+        if (fread(cmdline, 1, size, fp) == size) {
+          // the file has the arguments separated by '\0',
+          // so we translate '\0' to ' '
+          for (size_t i = 0; i < size; i++) {
+            if (cmdline[i] == '\0') {
+              cmdline[i] = ' ';
             }
-            cmdline[size] = '\0';
           }
+          cmdline[size] = '\0';
         }
       }
     }
@@ -854,7 +849,7 @@
 
 bool SystemProcessInterface::SystemProcesses::initialize() {
   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
-  return NULL == _iterator ? false : _iterator->initialize();
+  return _iterator->initialize();
 }
 
 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
@@ -901,7 +896,7 @@
 
 bool SystemProcessInterface::initialize() {
   _impl = new SystemProcessInterface::SystemProcesses();
-  return NULL == _impl ? false : _impl->initialize();
+  return _impl->initialize();
 }
 
 SystemProcessInterface::~SystemProcessInterface() {
@@ -916,15 +911,11 @@
 
 bool CPUInformationInterface::initialize() {
   _cpu_info = new CPUInformation();
-  if (NULL == _cpu_info) {
-    return false;
-  }
   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
-
   return true;
 }
 
@@ -1038,7 +1029,7 @@
 
 bool NetworkPerformanceInterface::initialize() {
   _impl = new NetworkPerformanceInterface::NetworkPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
--- a/src/hotspot/os/solaris/os_perf_solaris.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/solaris/os_perf_solaris.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -302,9 +302,6 @@
   // Data structure(s) for saving CPU load (one per CPU)
   size_t array_entry_count = _counters.nProcs;
   _counters.jvmTicks = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
-  if (NULL == _counters.jvmTicks) {
-    return false;
-  }
   memset(_counters.jvmTicks, 0, array_entry_count * sizeof(*_counters.jvmTicks));
 
   // Get kstat cpu_stat counters for every CPU
@@ -432,7 +429,7 @@
 
 bool CPUPerformanceInterface::initialize() {
   _impl = new CPUPerformanceInterface::CPUPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 CPUPerformanceInterface::~CPUPerformanceInterface(void) {
@@ -574,10 +571,8 @@
     if (path_substring != NULL) {
       int len = path_substring - psinfo_data.pr_psargs;
       exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
-      if (exe_path != NULL) {
-        jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
-        exe_path[len] = '\0';
-      }
+      jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
+      exe_path[len] = '\0';
     }
   }
 
@@ -642,7 +637,7 @@
 
 bool SystemProcessInterface::SystemProcesses::initialize() {
   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
-  return _iterator != NULL && _iterator->initialize();
+  return _iterator->initialize();
 }
 
 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
@@ -689,7 +684,7 @@
 
 bool SystemProcessInterface::initialize() {
   _impl = new SystemProcessInterface::SystemProcesses();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 
 }
 
@@ -705,9 +700,6 @@
 
 bool CPUInformationInterface::initialize() {
   _cpu_info = new CPUInformation();
-  if (_cpu_info == NULL) {
-    return false;
-  }
   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
@@ -820,7 +812,7 @@
 
 bool NetworkPerformanceInterface::initialize() {
   _impl = new NetworkPerformanceInterface::NetworkPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
--- a/src/hotspot/os/windows/os_perf_windows.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/windows/os_perf_windows.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -194,34 +194,27 @@
   return open_query(&query->query);
 }
 
-static int allocate_counters(MultiCounterQueryP query, size_t nofCounters) {
+static void allocate_counters(MultiCounterQueryP query, size_t nofCounters) {
   assert(query != NULL, "invariant");
   assert(!query->initialized, "invariant");
   assert(0 == query->noOfCounters, "invariant");
   assert(query->counters == NULL, "invariant");
   query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
-  if (query->counters == NULL) {
-    return OS_ERR;
-  }
   memset(query->counters, 0, nofCounters * sizeof(HCOUNTER));
   query->noOfCounters = (int)nofCounters;
-  return OS_OK;
 }
 
-static int allocate_counters(MultiCounterQuerySetP query_set, size_t nofCounters) {
+static void allocate_counters(MultiCounterQuerySetP query_set, size_t nofCounters) {
   assert(query_set != NULL, "invariant");
   assert(!query_set->initialized, "invariant");
   for (int i = 0; i < query_set->size; ++i) {
-    if (allocate_counters(&query_set->queries[i], nofCounters) != OS_OK) {
-      return OS_ERR;
-    }
+    allocate_counters(&query_set->queries[i], nofCounters);
   }
-  return OS_OK;
 }
 
-static int allocate_counters(ProcessQueryP process_query, size_t nofCounters) {
+static void allocate_counters(ProcessQueryP process_query, size_t nofCounters) {
   assert(process_query != NULL, "invariant");
-  return allocate_counters(&process_query->set, nofCounters);
+  allocate_counters(&process_query->set, nofCounters);
 }
 
 static void deallocate_counters(MultiCounterQueryP query) {
@@ -600,7 +593,7 @@
 static const char* copy_string_to_c_heap(const char* string) {
   assert(string != NULL, "invariant");
   const size_t len = strlen(string);
-  char* const cheap_allocated_string = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
+  char* const cheap_allocated_string = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
   if (NULL == cheap_allocated_string) {
     return NULL;
   }
@@ -849,9 +842,7 @@
   const int logical_cpu_count = number_of_logical_cpus();
   assert(logical_cpu_count >= os::processor_count(), "invariant");
   // we also add another counter for instance "_Total"
-  if (allocate_counters(cpu_query, logical_cpu_count + 1) != OS_OK) {
-    return OS_ERR;
-  }
+  allocate_counters(cpu_query, logical_cpu_count + 1);
   assert(cpu_query->noOfCounters == logical_cpu_count + 1, "invariant");
   return initialize_cpu_query_counters(cpu_query, pdh_counter_idx);
 }
@@ -1017,9 +1008,7 @@
   if (_process_cpu_load == NULL) {
     return true;
   }
-  if (allocate_counters(_process_cpu_load, 2) != OS_OK) {
-    return true;
-  }
+  allocate_counters(_process_cpu_load, 2);
   if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
     return true;
   }
@@ -1057,7 +1046,7 @@
 
 bool CPUPerformanceInterface::initialize() {
   _impl = new CPUPerformanceInterface::CPUPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 CPUPerformanceInterface::~CPUPerformanceInterface() {
@@ -1263,7 +1252,7 @@
 
 bool SystemProcessInterface::SystemProcesses::initialize() {
   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
-  return _iterator != NULL && _iterator->initialize();
+  return _iterator->initialize();
 }
 
 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
@@ -1318,7 +1307,7 @@
 
 bool SystemProcessInterface::initialize() {
   _impl = new SystemProcessInterface::SystemProcesses();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 SystemProcessInterface::~SystemProcessInterface() {
@@ -1333,9 +1322,6 @@
 
 bool CPUInformationInterface::initialize() {
   _cpu_info = new CPUInformation();
-  if (NULL == _cpu_info) {
-    return false;
-  }
   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
@@ -1431,7 +1417,7 @@
 
 bool NetworkPerformanceInterface::initialize() {
   _impl = new NetworkPerformanceInterface::NetworkPerformance();
-  return _impl != NULL && _impl->initialize();
+  return _impl->initialize();
 }
 
 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
--- a/src/hotspot/os/windows/os_windows.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/os/windows/os_windows.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -224,18 +224,12 @@
     }
 
     home_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + 1, mtInternal);
-    if (home_path == NULL) {
-      return;
-    }
     strcpy(home_path, home_dir);
     Arguments::set_java_home(home_path);
     FREE_C_HEAP_ARRAY(char, home_path);
 
     dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1,
                                 mtInternal);
-    if (dll_path == NULL) {
-      return;
-    }
     strcpy(dll_path, home_dir);
     strcat(dll_path, bin);
     Arguments::set_dll_dir(dll_path);
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -401,9 +401,6 @@
     int len = Bytes::get_Java_u2((address)stub_name);
     stub_name += 2;
     char* full_name = NEW_C_HEAP_ARRAY(char, len+5, mtCode);
-    if (full_name == NULL) { // No memory?
-      break;
-    }
     memcpy(full_name, "AOT ", 4);
     memcpy(full_name+4, stub_name, len);
     full_name[len+4] = 0;
--- a/src/hotspot/share/aot/aotLoader.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/aot/aotLoader.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -151,17 +151,15 @@
     if (AOTLibrary != NULL) {
       const int len = (int)strlen(AOTLibrary);
       char* cp  = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
-      if (cp != NULL) { // No memory?
-        memcpy(cp, AOTLibrary, len);
-        cp[len] = '\0';
-        char* end = cp + len;
-        while (cp < end) {
-          const char* name = cp;
-          while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != pathSep) cp++;
-          cp[0] = '\0';  // Terminate name
-          cp++;
-          load_library(name, true);
-        }
+      memcpy(cp, AOTLibrary, len);
+      cp[len] = '\0';
+      char* end = cp + len;
+      while (cp < end) {
+        const char* name = cp;
+        while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != pathSep) cp++;
+        cp[0] = '\0';  // Terminate name
+        cp++;
+        load_library(name, true);
       }
     }
 
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -1149,8 +1149,8 @@
   return (jint) JVMCICounterSize;
 C2V_END
 
-C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
-  return JavaThread::resize_all_jvmci_counters(new_size);
+C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
+  JavaThread::resize_all_jvmci_counters(new_size);
 C2V_END
 
 C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
@@ -2696,7 +2696,7 @@
   {CC "readUncompressedOop",                          CC "(J)" OBJECTCONSTANT,                                                              FN_PTR(readUncompressedOop)},
   {CC "collectCounters",                              CC "()[J",                                                                            FN_PTR(collectCounters)},
   {CC "getCountersSize",                              CC "()I",                                                                             FN_PTR(getCountersSize)},
-  {CC "setCountersSize",                              CC "(I)Z",                                                                            FN_PTR(setCountersSize)},
+  {CC "setCountersSize",                              CC "(I)V",                                                                            FN_PTR(setCountersSize)},
   {CC "allocateCompileId",                            CC "(" HS_RESOLVED_METHOD "I)I",                                                      FN_PTR(allocateCompileId)},
   {CC "isMature",                                     CC "(" METASPACE_METHOD_DATA ")Z",                                                    FN_PTR(isMature)},
   {CC "hasCompiledCodeForOSR",                        CC "(" HS_RESOLVED_METHOD "II)Z",                                                     FN_PTR(hasCompiledCodeForOSR)},
--- a/src/hotspot/share/prims/unsafe.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/prims/unsafe.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -669,7 +669,7 @@
     ClassLoader::unsafe_defineClassCallCounter()->inc();
   }
 
-  body = NEW_C_HEAP_ARRAY(jbyte, length, mtInternal);
+  body = NEW_C_HEAP_ARRAY_RETURN_NULL(jbyte, length, mtInternal);
   if (body == NULL) {
     throw_new(env, "java/lang/OutOfMemoryError");
     return 0;
@@ -685,7 +685,7 @@
     int unicode_len = env->GetStringLength(name);
 
     if (len >= sizeof(buf)) {
-      utfName = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
+      utfName = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
       if (utfName == NULL) {
         throw_new(env, "java/lang/OutOfMemoryError");
         goto free_body;
@@ -790,7 +790,7 @@
 
   int class_bytes_length = (int) length;
 
-  u1* class_bytes = NEW_C_HEAP_ARRAY(u1, length, mtInternal);
+  u1* class_bytes = NEW_C_HEAP_ARRAY_RETURN_NULL(u1, length, mtInternal);
   if (class_bytes == NULL) {
     THROW_0(vmSymbols::java_lang_OutOfMemoryError());
   }
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -3472,10 +3472,8 @@
   size_t file_sep_len = strlen(os::file_separator());
   const size_t len = jvm_path_len + file_sep_len + 20;
   default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
-  if (default_archive_path != NULL) {
-    jio_snprintf(default_archive_path, len, "%s%sclasses.jsa",
-      jvm_path, os::file_separator());
-  }
+  jio_snprintf(default_archive_path, len, "%s%sclasses.jsa",
+               jvm_path, os::file_separator());
   return default_archive_path;
 }
 
--- a/src/hotspot/share/runtime/os.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/runtime/os.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -1224,9 +1224,6 @@
     }
 
     char* formatted_path = NEW_C_HEAP_ARRAY(char, formatted_path_len + 1, mtInternal);
-    if (formatted_path == NULL) {
-        return NULL;
-    }
 
     // Create boot classpath from format, substituting separator chars and
     // java home directory.
@@ -1330,9 +1327,6 @@
   }
   const char psepchar = *os::path_separator();
   char* inpath = NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal);
-  if (inpath == NULL) {
-    return NULL;
-  }
   strcpy(inpath, path);
   size_t count = 1;
   char* p = strchr(inpath, psepchar);
@@ -1357,13 +1351,7 @@
                                     "sun.boot.library.path, to identify potential sources for this path.");
     }
     // allocate the string and add terminator storage
-    char* s  = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
-
-    if (s == NULL) {
-      // release allocated storage before returning null
-      free_array_of_char_arrays(opath, i++);
-      return NULL;
-    }
+    char* s = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
     strncpy(s, p, len);
     s[len] = '\0';
     opath[i] = s;
--- a/src/hotspot/share/runtime/thread.cpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/runtime/thread.cpp	Tue Sep 24 03:28:42 2019 -0400
@@ -1553,9 +1553,6 @@
 // Attempt to enlarge the array for per thread counters.
 jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) {
   jlong* new_counters = NEW_C_HEAP_ARRAY(jlong, new_size, mtJVMCI);
-  if (new_counters == NULL) {
-    return NULL;
-  }
   if (old_counters == NULL) {
     old_counters = new_counters;
     memset(old_counters, 0, sizeof(jlong) * new_size);
@@ -1572,54 +1569,34 @@
 }
 
 // Attempt to enlarge the array for per thread counters.
-bool JavaThread::resize_counters(int current_size, int new_size) {
-  jlong* new_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
-  if (new_counters == NULL) {
-    return false;
-  } else {
-    _jvmci_counters = new_counters;
-    return true;
-  }
+void JavaThread::resize_counters(int current_size, int new_size) {
+  _jvmci_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
 }
 
 class VM_JVMCIResizeCounters : public VM_Operation {
  private:
   int _new_size;
-  bool _failed;
 
  public:
-  VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { }
+  VM_JVMCIResizeCounters(int new_size) : _new_size(new_size) { }
   VMOp_Type type()                  const        { return VMOp_JVMCIResizeCounters; }
   bool allow_nested_vm_operations() const        { return true; }
   void doit() {
     // Resize the old thread counters array
     jlong* new_counters = resize_counters_array(JavaThread::_jvmci_old_thread_counters, JVMCICounterSize, _new_size);
-    if (new_counters == NULL) {
-      _failed = true;
-      return;
-    } else {
-      JavaThread::_jvmci_old_thread_counters = new_counters;
-    }
+    JavaThread::_jvmci_old_thread_counters = new_counters;
 
     // Now resize each threads array
     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) {
-      if (!tp->resize_counters(JVMCICounterSize, _new_size)) {
-        _failed = true;
-        break;
-      }
+      tp->resize_counters(JVMCICounterSize, _new_size);
     }
-    if (!_failed) {
-      JVMCICounterSize = _new_size;
-    }
-  }
-
-  bool failed() { return _failed; }
+    JVMCICounterSize = _new_size;
+  }
 };
 
-bool JavaThread::resize_all_jvmci_counters(int new_size) {
+void JavaThread::resize_all_jvmci_counters(int new_size) {
   VM_JVMCIResizeCounters op(new_size);
   VMThread::execute(&op);
-  return !op.failed();
 }
 
 #endif // INCLUDE_JVMCI
--- a/src/hotspot/share/runtime/thread.hpp	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/hotspot/share/runtime/thread.hpp	Tue Sep 24 03:28:42 2019 -0400
@@ -1143,10 +1143,8 @@
  public:
   static jlong* _jvmci_old_thread_counters;
   static void collect_counters(jlong* array, int length);
-
-  bool resize_counters(int current_size, int new_size);
-
-  static bool resize_all_jvmci_counters(int new_size);
+  void resize_counters(int current_size, int new_size);
+  static void resize_all_jvmci_counters(int new_size);
 
  private:
 #endif // INCLUDE_JVMCI
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Tue Sep 24 03:28:42 2019 -0400
@@ -557,10 +557,10 @@
     native int getCountersSize();
 
     /**
-     * Attempt to change the size of the counters allocated for JVMCI. This requires a safepoint to
+     * Change the size of the counters allocated for JVMCI. This requires a safepoint to
      * safely reallocate the storage but it's advisable to increase the size in reasonable chunks.
      */
-    native boolean setCountersSize(int newSize);
+    native void setCountersSize(int newSize);
 
     /**
      * Determines if {@code metaspaceMethodData} is mature.
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Mon Sep 23 17:02:08 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Tue Sep 24 03:28:42 2019 -0400
@@ -812,14 +812,13 @@
     }
 
     /**
-     * Attempt to enlarge the number of per thread counters available. Requires a safepoint so
+     * Enlarge the number of per thread counters available. Requires a safepoint so
      * resizing should be rare to avoid performance effects.
      *
      * @param newSize
-     * @return false if the resizing failed
      */
-    public boolean setCountersSize(int newSize) {
-        return compilerToVm.setCountersSize(newSize);
+    public void setCountersSize(int newSize) {
+        compilerToVm.setCountersSize(newSize);
     }
 
     /**