mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8225019: Update JVMCI
Reviewed-by: never, dlong
This commit is contained in:
parent
766a7dd9f7
commit
7356905a83
83 changed files with 609 additions and 210 deletions
|
@ -1592,6 +1592,78 @@ 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);
|
||||
} else {
|
||||
for (int i = 0; i < MIN2((int) current_size, new_size); i++) {
|
||||
new_counters[i] = old_counters[i];
|
||||
}
|
||||
if (new_size > current_size) {
|
||||
memset(new_counters + current_size, 0, sizeof(jlong) * (new_size - current_size));
|
||||
}
|
||||
FREE_C_HEAP_ARRAY(jlong, old_counters);
|
||||
}
|
||||
return new_counters;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
class VM_JVMCIResizeCounters : public VM_Operation {
|
||||
private:
|
||||
int _new_size;
|
||||
bool _failed;
|
||||
|
||||
public:
|
||||
VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { }
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
bool failed() { return _failed; }
|
||||
};
|
||||
|
||||
bool JavaThread::resize_all_jvmci_counters(int new_size) {
|
||||
VM_JVMCIResizeCounters op(new_size);
|
||||
VMThread::execute(&op);
|
||||
return !op.failed();
|
||||
}
|
||||
|
||||
#endif // INCLUDE_JVMCI
|
||||
|
||||
// A JavaThread is a normal Java thread
|
||||
|
@ -1630,11 +1702,9 @@ void JavaThread::initialize() {
|
|||
_in_retryable_allocation = false;
|
||||
_jvmci._alternate_call_target = NULL;
|
||||
assert(_jvmci._implicit_exception_pc == NULL, "must be");
|
||||
_jvmci_counters = NULL;
|
||||
if (JVMCICounterSize > 0) {
|
||||
_jvmci_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal);
|
||||
memset(_jvmci_counters, 0, sizeof(jlong) * JVMCICounterSize);
|
||||
} else {
|
||||
_jvmci_counters = NULL;
|
||||
resize_counters(0, (int) JVMCICounterSize);
|
||||
}
|
||||
#endif // INCLUDE_JVMCI
|
||||
_reserved_stack_activation = NULL; // stack base not known yet
|
||||
|
@ -3773,7 +3843,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
|
|||
|
||||
#if INCLUDE_JVMCI
|
||||
if (JVMCICounterSize > 0) {
|
||||
JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal);
|
||||
JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtJVMCI);
|
||||
memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize);
|
||||
} else {
|
||||
JavaThread::_jvmci_old_thread_counters = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue