Skip to content

Commit f2e6915

Browse files
author
Doug Simon
committedJul 27, 2020
8250556: revert JVMCI part of JDK-8230395
Reviewed-by: never, dholmes
1 parent 277ec3d commit f2e6915

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed
 

‎src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,8 @@ C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject))
11521152
return (jint) JVMCICounterSize;
11531153
C2V_END
11541154

1155-
C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
1156-
JavaThread::resize_all_jvmci_counters(new_size);
1155+
C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
1156+
return JavaThread::resize_all_jvmci_counters(new_size);
11571157
C2V_END
11581158

11591159
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
@@ -2760,7 +2760,7 @@ JNINativeMethod CompilerToVM::methods[] = {
27602760
{CC "readUncompressedOop", CC "(J)" OBJECTCONSTANT, FN_PTR(readUncompressedOop)},
27612761
{CC "collectCounters", CC "()[J", FN_PTR(collectCounters)},
27622762
{CC "getCountersSize", CC "()I", FN_PTR(getCountersSize)},
2763-
{CC "setCountersSize", CC "(I)V", FN_PTR(setCountersSize)},
2763+
{CC "setCountersSize", CC "(I)Z", FN_PTR(setCountersSize)},
27642764
{CC "allocateCompileId", CC "(" HS_RESOLVED_METHOD "I)I", FN_PTR(allocateCompileId)},
27652765
{CC "isMature", CC "(" METASPACE_METHOD_DATA ")Z", FN_PTR(isMature)},
27662766
{CC "hasCompiledCodeForOSR", CC "(" HS_RESOLVED_METHOD "II)Z", FN_PTR(hasCompiledCodeForOSR)},

‎src/hotspot/share/runtime/thread.cpp

+31-8
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,10 @@ void JavaThread::collect_counters(jlong* array, int length) {
15751575

15761576
// Attempt to enlarge the array for per thread counters.
15771577
jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) {
1578-
jlong* new_counters = NEW_C_HEAP_ARRAY(jlong, new_size, mtJVMCI);
1578+
jlong* new_counters = NEW_C_HEAP_ARRAY_RETURN_NULL(jlong, new_size, mtJVMCI);
1579+
if (new_counters == NULL) {
1580+
return NULL;
1581+
}
15791582
if (old_counters == NULL) {
15801583
old_counters = new_counters;
15811584
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
15921595
}
15931596

15941597
// Attempt to enlarge the array for per thread counters.
1595-
void JavaThread::resize_counters(int current_size, int new_size) {
1596-
_jvmci_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
1598+
bool JavaThread::resize_counters(int current_size, int new_size) {
1599+
jlong* new_counters = resize_counters_array(_jvmci_counters, current_size, new_size);
1600+
if (new_counters == NULL) {
1601+
return false;
1602+
} else {
1603+
_jvmci_counters = new_counters;
1604+
return true;
1605+
}
15971606
}
15981607

15991608
class VM_JVMCIResizeCounters : public VM_Operation {
16001609
private:
16011610
int _new_size;
1611+
bool _failed;
16021612

16031613
public:
1604-
VM_JVMCIResizeCounters(int new_size) : _new_size(new_size) { }
1614+
VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { }
16051615
VMOp_Type type() const { return VMOp_JVMCIResizeCounters; }
16061616
bool allow_nested_vm_operations() const { return true; }
16071617
void doit() {
16081618
// Resize the old thread counters array
16091619
jlong* new_counters = resize_counters_array(JavaThread::_jvmci_old_thread_counters, JVMCICounterSize, _new_size);
1610-
JavaThread::_jvmci_old_thread_counters = new_counters;
1620+
if (new_counters == NULL) {
1621+
_failed = true;
1622+
return;
1623+
} else {
1624+
JavaThread::_jvmci_old_thread_counters = new_counters;
1625+
}
16111626

16121627
// Now resize each threads array
16131628
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) {
1614-
tp->resize_counters(JVMCICounterSize, _new_size);
1629+
if (!tp->resize_counters(JVMCICounterSize, _new_size)) {
1630+
_failed = true;
1631+
break;
1632+
}
1633+
}
1634+
if (!_failed) {
1635+
JVMCICounterSize = _new_size;
16151636
}
1616-
JVMCICounterSize = _new_size;
16171637
}
1638+
1639+
bool failed() { return _failed; }
16181640
};
16191641

1620-
void JavaThread::resize_all_jvmci_counters(int new_size) {
1642+
bool JavaThread::resize_all_jvmci_counters(int new_size) {
16211643
VM_JVMCIResizeCounters op(new_size);
16221644
VMThread::execute(&op);
1645+
return !op.failed();
16231646
}
16241647

16251648
#endif // INCLUDE_JVMCI

‎src/hotspot/share/runtime/thread.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,10 @@ class JavaThread: public Thread {
11831183
public:
11841184
static jlong* _jvmci_old_thread_counters;
11851185
static void collect_counters(jlong* array, int length);
1186-
void resize_counters(int current_size, int new_size);
1187-
static void resize_all_jvmci_counters(int new_size);
1186+
1187+
bool resize_counters(int current_size, int new_size);
1188+
1189+
static bool resize_all_jvmci_counters(int new_size);
11881190

11891191
private:
11901192
#endif // INCLUDE_JVMCI

‎src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ public static CompilerToVM compilerToVM() {
557557
native int getCountersSize();
558558

559559
/**
560-
* Change the size of the counters allocated for JVMCI. This requires a safepoint to
560+
* Attempt to change the size of the counters allocated for JVMCI. This requires a safepoint to
561561
* safely reallocate the storage but it's advisable to increase the size in reasonable chunks.
562562
*/
563-
native void setCountersSize(int newSize);
563+
native boolean setCountersSize(int newSize);
564564

565565
/**
566566
* Determines if {@code metaspaceMethodData} is mature.

‎src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,14 @@ public int getCountersSize() {
899899
}
900900

901901
/**
902-
* Enlarge the number of per thread counters available. Requires a safepoint so
902+
* Attempt to enlarge the number of per thread counters available. Requires a safepoint so
903903
* resizing should be rare to avoid performance effects.
904904
*
905905
* @param newSize
906+
* @return false if the resizing failed
906907
*/
907-
public void setCountersSize(int newSize) {
908-
compilerToVm.setCountersSize(newSize);
908+
public boolean setCountersSize(int newSize) {
909+
return compilerToVm.setCountersSize(newSize);
909910
}
910911

911912
/**

0 commit comments

Comments
 (0)
Please sign in to comment.