src/hotspot/share/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File open Cdiff src/hotspot/share/runtime/thread.cpp

src/hotspot/share/runtime/thread.cpp

Print this page

        

*** 1589,1598 **** --- 1589,1670 ---- } } } } + // 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 void JavaThread::initialize() {
*** 1627,1641 **** _pending_failed_speculation = 0; _pending_transfer_to_interpreter = false; _in_retryable_allocation = false; _jvmci._alternate_call_target = NULL; assert(_jvmci._implicit_exception_pc == NULL, "must be"); - if (JVMCICounterSize > 0) { - _jvmci_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); - memset(_jvmci_counters, 0, sizeof(jlong) * JVMCICounterSize); - } else { _jvmci_counters = NULL; } #endif // INCLUDE_JVMCI _reserved_stack_activation = NULL; // stack base not known yet (void)const_cast<oop&>(_exception_oop = oop(NULL)); _exception_pc = 0; --- 1699,1711 ---- _pending_failed_speculation = 0; _pending_transfer_to_interpreter = false; _in_retryable_allocation = false; _jvmci._alternate_call_target = NULL; assert(_jvmci._implicit_exception_pc == NULL, "must be"); _jvmci_counters = NULL; + if (JVMCICounterSize > 0) { + resize_counters(0, (int) JVMCICounterSize); } #endif // INCLUDE_JVMCI _reserved_stack_activation = NULL; // stack base not known yet (void)const_cast<oop&>(_exception_oop = oop(NULL)); _exception_pc = 0;
*** 3767,3777 **** // Initialize global data structures and create system classes in heap vm_init_globals(); #if INCLUDE_JVMCI if (JVMCICounterSize > 0) { ! JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); } else { JavaThread::_jvmci_old_thread_counters = NULL; } #endif // INCLUDE_JVMCI --- 3837,3847 ---- // Initialize global data structures and create system classes in heap vm_init_globals(); #if INCLUDE_JVMCI if (JVMCICounterSize > 0) { ! 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; } #endif // INCLUDE_JVMCI
src/hotspot/share/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File