8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen

Reviewed-by: lkorinth, hseigel, thartmann, dnsimon
This commit is contained in:
David Holmes 2019-09-24 03:28:42 -04:00
parent 0e264cfe36
commit 23ec926327
16 changed files with 80 additions and 176 deletions

View file

@ -1553,9 +1553,6 @@ void JavaThread::collect_counters(jlong* array, int length) {
// 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 @@ jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size
}
// 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;
}
}
if (!_failed) {
JVMCICounterSize = _new_size;
tp->resize_counters(JVMCICounterSize, _new_size);
}
JVMCICounterSize = _new_size;
}
bool failed() { return _failed; }
};
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