8250556: revert JVMCI part of JDK-8230395

Reviewed-by: never, dholmes
This commit is contained in:
Doug Simon 2020-07-27 22:59:27 +02:00
parent 277ec3d260
commit f2e69156c8
5 changed files with 44 additions and 18 deletions

View File

@ -1152,8 +1152,8 @@ C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject))
return (jint) JVMCICounterSize;
C2V_END
C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
JavaThread::resize_all_jvmci_counters(new_size);
C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
return JavaThread::resize_all_jvmci_counters(new_size);
C2V_END
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
@ -2760,7 +2760,7 @@ JNINativeMethod CompilerToVM::methods[] = {
{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)V", FN_PTR(setCountersSize)},
{CC "setCountersSize", CC "(I)Z", 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)},

View File

@ -1575,7 +1575,10 @@ 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);
jlong* new_counters = NEW_C_HEAP_ARRAY_RETURN_NULL(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);
@ -1592,34 +1595,54 @@ jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size
}
// Attempt to enlarge the array for per thread counters.
void JavaThread::resize_counters(int current_size, int new_size) {
_jvmci_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
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) { }
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);
JavaThread::_jvmci_old_thread_counters = new_counters;
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(); ) {
tp->resize_counters(JVMCICounterSize, _new_size);
if (!tp->resize_counters(JVMCICounterSize, _new_size)) {
_failed = true;
break;
}
}
if (!_failed) {
JVMCICounterSize = _new_size;
}
JVMCICounterSize = _new_size;
}
bool failed() { return _failed; }
};
void JavaThread::resize_all_jvmci_counters(int new_size) {
bool JavaThread::resize_all_jvmci_counters(int new_size) {
VM_JVMCIResizeCounters op(new_size);
VMThread::execute(&op);
return !op.failed();
}
#endif // INCLUDE_JVMCI

View File

@ -1183,8 +1183,10 @@ class JavaThread: public Thread {
public:
static jlong* _jvmci_old_thread_counters;
static void collect_counters(jlong* array, int length);
void resize_counters(int current_size, int new_size);
static void resize_all_jvmci_counters(int new_size);
bool resize_counters(int current_size, int new_size);
static bool resize_all_jvmci_counters(int new_size);
private:
#endif // INCLUDE_JVMCI

View File

@ -557,10 +557,10 @@ final class CompilerToVM {
native int getCountersSize();
/**
* Change the size of the counters allocated for JVMCI. This requires a safepoint to
* Attempt 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 void setCountersSize(int newSize);
native boolean setCountersSize(int newSize);
/**
* Determines if {@code metaspaceMethodData} is mature.

View File

@ -899,13 +899,14 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
}
/**
* Enlarge the number of per thread counters available. Requires a safepoint so
* Attempt to 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 void setCountersSize(int newSize) {
compilerToVm.setCountersSize(newSize);
public boolean setCountersSize(int newSize) {
return compilerToVm.setCountersSize(newSize);
}
/**