mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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:
parent
0e264cfe36
commit
23ec926327
16 changed files with 80 additions and 176 deletions
|
@ -445,9 +445,6 @@ CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
|
||||||
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||||
size_t array_entry_count = _counters.nProcs + 1;
|
size_t array_entry_count = _counters.nProcs + 1;
|
||||||
_counters.cpus = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
|
_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));
|
memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
|
||||||
|
|
||||||
// For the CPU load total
|
// For the CPU load total
|
||||||
|
@ -535,7 +532,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||||
return NULL == _impl ? false : _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||||
|
@ -688,7 +685,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
||||||
}
|
}
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
|
cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
|
||||||
if (cmdline != NULL) {
|
|
||||||
cmdline[0] = '\0';
|
cmdline[0] = '\0';
|
||||||
if (fseek(fp, 0, SEEK_SET) == 0) {
|
if (fseek(fp, 0, SEEK_SET) == 0) {
|
||||||
if (fread(cmdline, 1, size, fp) == size) {
|
if (fread(cmdline, 1, size, fp) == size) {
|
||||||
|
@ -703,7 +699,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
return cmdline;
|
return cmdline;
|
||||||
|
@ -790,7 +785,7 @@ SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
||||||
|
|
||||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||||
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
||||||
return NULL == _iterator ? false : _iterator->initialize();
|
return _iterator->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||||
|
@ -837,7 +832,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
_impl = new SystemProcessInterface::SystemProcesses();
|
_impl = new SystemProcessInterface::SystemProcesses();
|
||||||
return NULL == _impl ? false : _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::~SystemProcessInterface() {
|
SystemProcessInterface::~SystemProcessInterface() {
|
||||||
|
@ -852,15 +847,11 @@ CPUInformationInterface::CPUInformationInterface() {
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
_cpu_info = new CPUInformation();
|
_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_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_cores(VM_Version_Ext::number_of_cores());
|
||||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
_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_name(VM_Version_Ext::cpu_name());
|
||||||
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +919,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
|
|
||||||
bool NetworkPerformanceInterface::initialize() {
|
bool NetworkPerformanceInterface::initialize() {
|
||||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -234,7 +234,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||||
|
@ -355,7 +355,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
_impl = new SystemProcessInterface::SystemProcesses();
|
_impl = new SystemProcessInterface::SystemProcesses();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::~SystemProcessInterface() {
|
SystemProcessInterface::~SystemProcessInterface() {
|
||||||
|
@ -370,16 +370,11 @@ CPUInformationInterface::CPUInformationInterface() {
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
_cpu_info = new CPUInformation();
|
_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_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_cores(VM_Version_Ext::number_of_cores());
|
||||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
_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_name(VM_Version_Ext::cpu_name());
|
||||||
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +478,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
|
|
||||||
bool NetworkPerformanceInterface::initialize() {
|
bool NetworkPerformanceInterface::initialize() {
|
||||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
|
|
|
@ -505,9 +505,6 @@ CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
|
||||||
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||||
size_t array_entry_count = _counters.nProcs + 1;
|
size_t array_entry_count = _counters.nProcs + 1;
|
||||||
_counters.cpus = NEW_C_HEAP_ARRAY(os::Linux::CPUPerfTicks, array_entry_count, mtInternal);
|
_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));
|
memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
|
||||||
|
|
||||||
// For the CPU load total
|
// For the CPU load total
|
||||||
|
@ -595,7 +592,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||||
return NULL == _impl ? false : _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||||
|
@ -748,7 +745,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
||||||
}
|
}
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
|
cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
|
||||||
if (cmdline != NULL) {
|
|
||||||
cmdline[0] = '\0';
|
cmdline[0] = '\0';
|
||||||
if (fseek(fp, 0, SEEK_SET) == 0) {
|
if (fseek(fp, 0, SEEK_SET) == 0) {
|
||||||
if (fread(cmdline, 1, size, fp) == size) {
|
if (fread(cmdline, 1, size, fp) == size) {
|
||||||
|
@ -763,7 +759,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
return cmdline;
|
return cmdline;
|
||||||
|
@ -854,7 +849,7 @@ SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
||||||
|
|
||||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||||
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
||||||
return NULL == _iterator ? false : _iterator->initialize();
|
return _iterator->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||||
|
@ -901,7 +896,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
_impl = new SystemProcessInterface::SystemProcesses();
|
_impl = new SystemProcessInterface::SystemProcesses();
|
||||||
return NULL == _impl ? false : _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::~SystemProcessInterface() {
|
SystemProcessInterface::~SystemProcessInterface() {
|
||||||
|
@ -916,15 +911,11 @@ CPUInformationInterface::CPUInformationInterface() {
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
_cpu_info = new CPUInformation();
|
_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_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_cores(VM_Version_Ext::number_of_cores());
|
||||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
_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_name(VM_Version_Ext::cpu_name());
|
||||||
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,7 +1029,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
|
|
||||||
bool NetworkPerformanceInterface::initialize() {
|
bool NetworkPerformanceInterface::initialize() {
|
||||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
|
|
|
@ -302,9 +302,6 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||||
// Data structure(s) for saving CPU load (one per CPU)
|
// Data structure(s) for saving CPU load (one per CPU)
|
||||||
size_t array_entry_count = _counters.nProcs;
|
size_t array_entry_count = _counters.nProcs;
|
||||||
_counters.jvmTicks = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
|
_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));
|
memset(_counters.jvmTicks, 0, array_entry_count * sizeof(*_counters.jvmTicks));
|
||||||
|
|
||||||
// Get kstat cpu_stat counters for every CPU
|
// Get kstat cpu_stat counters for every CPU
|
||||||
|
@ -432,7 +429,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface(void) {
|
CPUPerformanceInterface::~CPUPerformanceInterface(void) {
|
||||||
|
@ -574,12 +571,10 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProc
|
||||||
if (path_substring != NULL) {
|
if (path_substring != NULL) {
|
||||||
int len = path_substring - psinfo_data.pr_psargs;
|
int len = path_substring - psinfo_data.pr_psargs;
|
||||||
exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
|
exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
|
||||||
if (exe_path != NULL) {
|
|
||||||
jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
|
jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
|
||||||
exe_path[len] = '\0';
|
exe_path[len] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
process_info->set_pid(atoi(_entry->d_name));
|
process_info->set_pid(atoi(_entry->d_name));
|
||||||
process_info->set_name(allocate_string(psinfo_data.pr_fname));
|
process_info->set_name(allocate_string(psinfo_data.pr_fname));
|
||||||
|
@ -642,7 +637,7 @@ SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
||||||
|
|
||||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||||
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
||||||
return _iterator != NULL && _iterator->initialize();
|
return _iterator->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||||
|
@ -689,7 +684,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
_impl = new SystemProcessInterface::SystemProcesses();
|
_impl = new SystemProcessInterface::SystemProcesses();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,9 +700,6 @@ CPUInformationInterface::CPUInformationInterface() {
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
_cpu_info = new CPUInformation();
|
_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_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_cores(VM_Version_Ext::number_of_cores());
|
||||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
||||||
|
@ -820,7 +812,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
|
|
||||||
bool NetworkPerformanceInterface::initialize() {
|
bool NetworkPerformanceInterface::initialize() {
|
||||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
|
|
|
@ -194,34 +194,27 @@ static int open_query(QueryP query) {
|
||||||
return open_query(&query->query);
|
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 != NULL, "invariant");
|
||||||
assert(!query->initialized, "invariant");
|
assert(!query->initialized, "invariant");
|
||||||
assert(0 == query->noOfCounters, "invariant");
|
assert(0 == query->noOfCounters, "invariant");
|
||||||
assert(query->counters == NULL, "invariant");
|
assert(query->counters == NULL, "invariant");
|
||||||
query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
|
query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
|
||||||
if (query->counters == NULL) {
|
|
||||||
return OS_ERR;
|
|
||||||
}
|
|
||||||
memset(query->counters, 0, nofCounters * sizeof(HCOUNTER));
|
memset(query->counters, 0, nofCounters * sizeof(HCOUNTER));
|
||||||
query->noOfCounters = (int)nofCounters;
|
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 != NULL, "invariant");
|
||||||
assert(!query_set->initialized, "invariant");
|
assert(!query_set->initialized, "invariant");
|
||||||
for (int i = 0; i < query_set->size; ++i) {
|
for (int i = 0; i < query_set->size; ++i) {
|
||||||
if (allocate_counters(&query_set->queries[i], nofCounters) != OS_OK) {
|
allocate_counters(&query_set->queries[i], nofCounters);
|
||||||
return OS_ERR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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");
|
assert(process_query != NULL, "invariant");
|
||||||
return allocate_counters(&process_query->set, nofCounters);
|
allocate_counters(&process_query->set, nofCounters);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deallocate_counters(MultiCounterQueryP query) {
|
static void deallocate_counters(MultiCounterQueryP query) {
|
||||||
|
@ -600,7 +593,7 @@ static OSReturn lookup_name_by_index(DWORD index, char** p_string) {
|
||||||
static const char* copy_string_to_c_heap(const char* string) {
|
static const char* copy_string_to_c_heap(const char* string) {
|
||||||
assert(string != NULL, "invariant");
|
assert(string != NULL, "invariant");
|
||||||
const size_t len = strlen(string);
|
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) {
|
if (NULL == cheap_allocated_string) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -849,9 +842,7 @@ static int initialize_cpu_query(MultiCounterQueryP cpu_query, DWORD pdh_counter_
|
||||||
const int logical_cpu_count = number_of_logical_cpus();
|
const int logical_cpu_count = number_of_logical_cpus();
|
||||||
assert(logical_cpu_count >= os::processor_count(), "invariant");
|
assert(logical_cpu_count >= os::processor_count(), "invariant");
|
||||||
// we also add another counter for instance "_Total"
|
// we also add another counter for instance "_Total"
|
||||||
if (allocate_counters(cpu_query, logical_cpu_count + 1) != OS_OK) {
|
allocate_counters(cpu_query, logical_cpu_count + 1);
|
||||||
return OS_ERR;
|
|
||||||
}
|
|
||||||
assert(cpu_query->noOfCounters == logical_cpu_count + 1, "invariant");
|
assert(cpu_query->noOfCounters == logical_cpu_count + 1, "invariant");
|
||||||
return initialize_cpu_query_counters(cpu_query, pdh_counter_idx);
|
return initialize_cpu_query_counters(cpu_query, pdh_counter_idx);
|
||||||
}
|
}
|
||||||
|
@ -1017,9 +1008,7 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||||
if (_process_cpu_load == NULL) {
|
if (_process_cpu_load == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (allocate_counters(_process_cpu_load, 2) != OS_OK) {
|
allocate_counters(_process_cpu_load, 2);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
|
if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1046,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||||
|
@ -1263,7 +1252,7 @@ SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
||||||
|
|
||||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||||
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
||||||
return _iterator != NULL && _iterator->initialize();
|
return _iterator->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||||
|
@ -1318,7 +1307,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
_impl = new SystemProcessInterface::SystemProcesses();
|
_impl = new SystemProcessInterface::SystemProcesses();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::~SystemProcessInterface() {
|
SystemProcessInterface::~SystemProcessInterface() {
|
||||||
|
@ -1333,9 +1322,6 @@ CPUInformationInterface::CPUInformationInterface() {
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
_cpu_info = new CPUInformation();
|
_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_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_cores(VM_Version_Ext::number_of_cores());
|
||||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
||||||
|
@ -1431,7 +1417,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
|
|
||||||
bool NetworkPerformanceInterface::initialize() {
|
bool NetworkPerformanceInterface::initialize() {
|
||||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||||
return _impl != NULL && _impl->initialize();
|
return _impl->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
|
|
|
@ -224,18 +224,12 @@ void os::init_system_properties_values() {
|
||||||
}
|
}
|
||||||
|
|
||||||
home_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + 1, mtInternal);
|
home_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + 1, mtInternal);
|
||||||
if (home_path == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
strcpy(home_path, home_dir);
|
strcpy(home_path, home_dir);
|
||||||
Arguments::set_java_home(home_path);
|
Arguments::set_java_home(home_path);
|
||||||
FREE_C_HEAP_ARRAY(char, home_path);
|
FREE_C_HEAP_ARRAY(char, home_path);
|
||||||
|
|
||||||
dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1,
|
dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1,
|
||||||
mtInternal);
|
mtInternal);
|
||||||
if (dll_path == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
strcpy(dll_path, home_dir);
|
strcpy(dll_path, home_dir);
|
||||||
strcat(dll_path, bin);
|
strcat(dll_path, bin);
|
||||||
Arguments::set_dll_dir(dll_path);
|
Arguments::set_dll_dir(dll_path);
|
||||||
|
|
|
@ -401,9 +401,6 @@ void AOTCodeHeap::register_stubs() {
|
||||||
int len = Bytes::get_Java_u2((address)stub_name);
|
int len = Bytes::get_Java_u2((address)stub_name);
|
||||||
stub_name += 2;
|
stub_name += 2;
|
||||||
char* full_name = NEW_C_HEAP_ARRAY(char, len+5, mtCode);
|
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, "AOT ", 4);
|
||||||
memcpy(full_name+4, stub_name, len);
|
memcpy(full_name+4, stub_name, len);
|
||||||
full_name[len+4] = 0;
|
full_name[len+4] = 0;
|
||||||
|
|
|
@ -151,7 +151,6 @@ void AOTLoader::initialize() {
|
||||||
if (AOTLibrary != NULL) {
|
if (AOTLibrary != NULL) {
|
||||||
const int len = (int)strlen(AOTLibrary);
|
const int len = (int)strlen(AOTLibrary);
|
||||||
char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
|
char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
|
||||||
if (cp != NULL) { // No memory?
|
|
||||||
memcpy(cp, AOTLibrary, len);
|
memcpy(cp, AOTLibrary, len);
|
||||||
cp[len] = '\0';
|
cp[len] = '\0';
|
||||||
char* end = cp + len;
|
char* end = cp + len;
|
||||||
|
@ -163,7 +162,6 @@ void AOTLoader::initialize() {
|
||||||
load_library(name, true);
|
load_library(name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Load well-know AOT libraries from Java installation directory.
|
// Load well-know AOT libraries from Java installation directory.
|
||||||
const char* home = Arguments::get_java_home();
|
const char* home = Arguments::get_java_home();
|
||||||
|
|
|
@ -1149,8 +1149,8 @@ C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject))
|
||||||
return (jint) JVMCICounterSize;
|
return (jint) JVMCICounterSize;
|
||||||
C2V_END
|
C2V_END
|
||||||
|
|
||||||
C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
|
C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
|
||||||
return JavaThread::resize_all_jvmci_counters(new_size);
|
JavaThread::resize_all_jvmci_counters(new_size);
|
||||||
C2V_END
|
C2V_END
|
||||||
|
|
||||||
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
|
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
|
||||||
|
@ -2696,7 +2696,7 @@ JNINativeMethod CompilerToVM::methods[] = {
|
||||||
{CC "readUncompressedOop", CC "(J)" OBJECTCONSTANT, FN_PTR(readUncompressedOop)},
|
{CC "readUncompressedOop", CC "(J)" OBJECTCONSTANT, FN_PTR(readUncompressedOop)},
|
||||||
{CC "collectCounters", CC "()[J", FN_PTR(collectCounters)},
|
{CC "collectCounters", CC "()[J", FN_PTR(collectCounters)},
|
||||||
{CC "getCountersSize", CC "()I", FN_PTR(getCountersSize)},
|
{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 "allocateCompileId", CC "(" HS_RESOLVED_METHOD "I)I", FN_PTR(allocateCompileId)},
|
||||||
{CC "isMature", CC "(" METASPACE_METHOD_DATA ")Z", FN_PTR(isMature)},
|
{CC "isMature", CC "(" METASPACE_METHOD_DATA ")Z", FN_PTR(isMature)},
|
||||||
{CC "hasCompiledCodeForOSR", CC "(" HS_RESOLVED_METHOD "II)Z", FN_PTR(hasCompiledCodeForOSR)},
|
{CC "hasCompiledCodeForOSR", CC "(" HS_RESOLVED_METHOD "II)Z", FN_PTR(hasCompiledCodeForOSR)},
|
||||||
|
|
|
@ -669,7 +669,7 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data
|
||||||
ClassLoader::unsafe_defineClassCallCounter()->inc();
|
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) {
|
if (body == NULL) {
|
||||||
throw_new(env, "java/lang/OutOfMemoryError");
|
throw_new(env, "java/lang/OutOfMemoryError");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -685,7 +685,7 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data
|
||||||
int unicode_len = env->GetStringLength(name);
|
int unicode_len = env->GetStringLength(name);
|
||||||
|
|
||||||
if (len >= sizeof(buf)) {
|
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) {
|
if (utfName == NULL) {
|
||||||
throw_new(env, "java/lang/OutOfMemoryError");
|
throw_new(env, "java/lang/OutOfMemoryError");
|
||||||
goto free_body;
|
goto free_body;
|
||||||
|
@ -790,7 +790,7 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env,
|
||||||
|
|
||||||
int class_bytes_length = (int) length;
|
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) {
|
if (class_bytes == NULL) {
|
||||||
THROW_0(vmSymbols::java_lang_OutOfMemoryError());
|
THROW_0(vmSymbols::java_lang_OutOfMemoryError());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3472,10 +3472,8 @@ char* Arguments::get_default_shared_archive_path() {
|
||||||
size_t file_sep_len = strlen(os::file_separator());
|
size_t file_sep_len = strlen(os::file_separator());
|
||||||
const size_t len = jvm_path_len + file_sep_len + 20;
|
const size_t len = jvm_path_len + file_sep_len + 20;
|
||||||
default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
|
default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
|
||||||
if (default_archive_path != NULL) {
|
|
||||||
jio_snprintf(default_archive_path, len, "%s%sclasses.jsa",
|
jio_snprintf(default_archive_path, len, "%s%sclasses.jsa",
|
||||||
jvm_path, os::file_separator());
|
jvm_path, os::file_separator());
|
||||||
}
|
|
||||||
return default_archive_path;
|
return default_archive_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1224,9 +1224,6 @@ char* os::format_boot_path(const char* format_string,
|
||||||
}
|
}
|
||||||
|
|
||||||
char* formatted_path = NEW_C_HEAP_ARRAY(char, formatted_path_len + 1, mtInternal);
|
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
|
// Create boot classpath from format, substituting separator chars and
|
||||||
// java home directory.
|
// java home directory.
|
||||||
|
@ -1330,9 +1327,6 @@ char** os::split_path(const char* path, size_t* elements, size_t file_name_lengt
|
||||||
}
|
}
|
||||||
const char psepchar = *os::path_separator();
|
const char psepchar = *os::path_separator();
|
||||||
char* inpath = NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal);
|
char* inpath = NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal);
|
||||||
if (inpath == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strcpy(inpath, path);
|
strcpy(inpath, path);
|
||||||
size_t count = 1;
|
size_t count = 1;
|
||||||
char* p = strchr(inpath, psepchar);
|
char* p = strchr(inpath, psepchar);
|
||||||
|
@ -1357,13 +1351,7 @@ char** os::split_path(const char* path, size_t* elements, size_t file_name_lengt
|
||||||
"sun.boot.library.path, to identify potential sources for this path.");
|
"sun.boot.library.path, to identify potential sources for this path.");
|
||||||
}
|
}
|
||||||
// allocate the string and add terminator storage
|
// allocate the string and add terminator storage
|
||||||
char* s = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
|
char* s = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
|
||||||
|
|
||||||
if (s == NULL) {
|
|
||||||
// release allocated storage before returning null
|
|
||||||
free_array_of_char_arrays(opath, i++);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strncpy(s, p, len);
|
strncpy(s, p, len);
|
||||||
s[len] = '\0';
|
s[len] = '\0';
|
||||||
opath[i] = s;
|
opath[i] = s;
|
||||||
|
|
|
@ -1553,9 +1553,6 @@ void JavaThread::collect_counters(jlong* array, int length) {
|
||||||
// Attempt to enlarge the array for per thread counters.
|
// Attempt to enlarge the array for per thread counters.
|
||||||
jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) {
|
jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) {
|
||||||
jlong* new_counters = NEW_C_HEAP_ARRAY(jlong, new_size, mtJVMCI);
|
jlong* new_counters = NEW_C_HEAP_ARRAY(jlong, new_size, mtJVMCI);
|
||||||
if (new_counters == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (old_counters == NULL) {
|
if (old_counters == NULL) {
|
||||||
old_counters = new_counters;
|
old_counters = new_counters;
|
||||||
memset(old_counters, 0, sizeof(jlong) * new_size);
|
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.
|
// Attempt to enlarge the array for per thread counters.
|
||||||
bool JavaThread::resize_counters(int current_size, int new_size) {
|
void JavaThread::resize_counters(int current_size, int new_size) {
|
||||||
jlong* new_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
|
_jvmci_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
|
||||||
if (new_counters == NULL) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
_jvmci_counters = new_counters;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VM_JVMCIResizeCounters : public VM_Operation {
|
class VM_JVMCIResizeCounters : public VM_Operation {
|
||||||
private:
|
private:
|
||||||
int _new_size;
|
int _new_size;
|
||||||
bool _failed;
|
|
||||||
|
|
||||||
public:
|
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; }
|
VMOp_Type type() const { return VMOp_JVMCIResizeCounters; }
|
||||||
bool allow_nested_vm_operations() const { return true; }
|
bool allow_nested_vm_operations() const { return true; }
|
||||||
void doit() {
|
void doit() {
|
||||||
// Resize the old thread counters array
|
// Resize the old thread counters array
|
||||||
jlong* new_counters = resize_counters_array(JavaThread::_jvmci_old_thread_counters, JVMCICounterSize, _new_size);
|
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
|
// Now resize each threads array
|
||||||
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) {
|
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) {
|
||||||
if (!tp->resize_counters(JVMCICounterSize, _new_size)) {
|
tp->resize_counters(JVMCICounterSize, _new_size);
|
||||||
_failed = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!_failed) {
|
|
||||||
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);
|
VM_JVMCIResizeCounters op(new_size);
|
||||||
VMThread::execute(&op);
|
VMThread::execute(&op);
|
||||||
return !op.failed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INCLUDE_JVMCI
|
#endif // INCLUDE_JVMCI
|
||||||
|
|
|
@ -1143,10 +1143,8 @@ class JavaThread: public Thread {
|
||||||
public:
|
public:
|
||||||
static jlong* _jvmci_old_thread_counters;
|
static jlong* _jvmci_old_thread_counters;
|
||||||
static void collect_counters(jlong* array, int length);
|
static void collect_counters(jlong* array, int length);
|
||||||
|
void resize_counters(int current_size, int new_size);
|
||||||
bool resize_counters(int current_size, int new_size);
|
static void resize_all_jvmci_counters(int new_size);
|
||||||
|
|
||||||
static bool resize_all_jvmci_counters(int new_size);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#endif // INCLUDE_JVMCI
|
#endif // INCLUDE_JVMCI
|
||||||
|
|
|
@ -557,10 +557,10 @@ final class CompilerToVM {
|
||||||
native int getCountersSize();
|
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.
|
* 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.
|
* Determines if {@code metaspaceMethodData} is mature.
|
||||||
|
|
|
@ -812,14 +812,13 @@ assert factories != null : "sanity";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* resizing should be rare to avoid performance effects.
|
||||||
*
|
*
|
||||||
* @param newSize
|
* @param newSize
|
||||||
* @return false if the resizing failed
|
|
||||||
*/
|
*/
|
||||||
public boolean setCountersSize(int newSize) {
|
public void setCountersSize(int newSize) {
|
||||||
return compilerToVm.setCountersSize(newSize);
|
compilerToVm.setCountersSize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue