mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
parent
277ec3d260
commit
f2e69156c8
5 changed files with 44 additions and 18 deletions
|
@ -1152,8 +1152,8 @@ C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject))
|
||||||
return (jint) JVMCICounterSize;
|
return (jint) JVMCICounterSize;
|
||||||
C2V_END
|
C2V_END
|
||||||
|
|
||||||
C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
|
C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
|
||||||
JavaThread::resize_all_jvmci_counters(new_size);
|
return 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))
|
||||||
|
@ -2760,7 +2760,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)V", FN_PTR(setCountersSize)},
|
{CC "setCountersSize", CC "(I)Z", 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)},
|
||||||
|
|
|
@ -1575,7 +1575,10 @@ 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_RETURN_NULL(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);
|
||||||
|
@ -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.
|
// Attempt to enlarge the array for per thread counters.
|
||||||
void JavaThread::resize_counters(int current_size, int new_size) {
|
bool JavaThread::resize_counters(int current_size, int new_size) {
|
||||||
_jvmci_counters = resize_counters_array(_jvmci_counters, current_size, 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 {
|
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) { }
|
VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { }
|
||||||
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(); ) {
|
||||||
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);
|
VM_JVMCIResizeCounters op(new_size);
|
||||||
VMThread::execute(&op);
|
VMThread::execute(&op);
|
||||||
|
return !op.failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INCLUDE_JVMCI
|
#endif // INCLUDE_JVMCI
|
||||||
|
|
|
@ -1183,8 +1183,10 @@ 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);
|
|
||||||
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:
|
private:
|
||||||
#endif // INCLUDE_JVMCI
|
#endif // INCLUDE_JVMCI
|
||||||
|
|
|
@ -557,10 +557,10 @@ final class CompilerToVM {
|
||||||
native int getCountersSize();
|
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.
|
* 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.
|
* Determines if {@code metaspaceMethodData} is mature.
|
||||||
|
|
|
@ -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.
|
* resizing should be rare to avoid performance effects.
|
||||||
*
|
*
|
||||||
* @param newSize
|
* @param newSize
|
||||||
|
* @return false if the resizing failed
|
||||||
*/
|
*/
|
||||||
public void setCountersSize(int newSize) {
|
public boolean setCountersSize(int newSize) {
|
||||||
compilerToVm.setCountersSize(newSize);
|
return compilerToVm.setCountersSize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue