Skip to content

Commit 2076952

Browse files
committed
8297106: Remove the -Xcheck:jni local reference capacity checking
Reviewed-by: mbaesken Backport-of: 692bedbc1df153f362b8e85693f20b089b5594e2
1 parent 39a6bf2 commit 2076952

File tree

8 files changed

+1
-290
lines changed

8 files changed

+1
-290
lines changed

src/hotspot/share/prims/jniCheck.cpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
#include "utilities/formatBuffer.hpp"
4747
#include "utilities/utf8.hpp"
4848

49-
// Complain every extra number of unplanned local refs
50-
#define CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD 32
51-
5249
// Heap objects are allowed to be directly referenced only in VM code,
5350
// not in native code.
5451

@@ -202,17 +199,6 @@ check_pending_exception(JavaThread* thr) {
202199
}
203200
}
204201

205-
/**
206-
* Add to the planned number of handles. I.e. plus current live & warning threshold
207-
*/
208-
static inline void
209-
add_planned_handle_capacity(JNIHandleBlock* handles, size_t capacity) {
210-
handles->set_planned_capacity(capacity +
211-
handles->get_number_of_live_handles() +
212-
CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
213-
}
214-
215-
216202
static inline void
217203
functionEnterCritical(JavaThread* thr)
218204
{
@@ -244,18 +230,7 @@ functionEnterExceptionAllowed(JavaThread* thr)
244230
static inline void
245231
functionExit(JavaThread* thr)
246232
{
247-
JNIHandleBlock* handles = thr->active_handles();
248-
size_t planned_capacity = handles->get_planned_capacity();
249-
size_t live_handles = handles->get_number_of_live_handles();
250-
if (live_handles > planned_capacity) {
251-
IN_VM(
252-
tty->print_cr("WARNING: JNI local refs: " SIZE_FORMAT ", exceeds capacity: " SIZE_FORMAT,
253-
live_handles, planned_capacity);
254-
thr->print_stack();
255-
)
256-
// Complain just the once, reset to current + warn threshold
257-
add_planned_handle_capacity(handles, 0);
258-
}
233+
// No checks at this time
259234
}
260235

261236
static inline void
@@ -746,9 +721,6 @@ JNI_ENTRY_CHECKED(jint,
746721
if (capacity < 0)
747722
NativeReportJNIFatalError(thr, "negative capacity");
748723
jint result = UNCHECKED()->PushLocalFrame(env, capacity);
749-
if (result == JNI_OK) {
750-
add_planned_handle_capacity(thr->active_handles(), capacity);
751-
}
752724
functionExit(thr);
753725
return result;
754726
JNI_END
@@ -850,12 +822,6 @@ JNI_ENTRY_CHECKED(jint,
850822
NativeReportJNIFatalError(thr, "negative capacity");
851823
}
852824
jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
853-
if (result == JNI_OK) {
854-
// increase local ref capacity if needed
855-
if ((size_t)capacity > thr->active_handles()->get_planned_capacity()) {
856-
add_planned_handle_capacity(thr->active_handles(), capacity);
857-
}
858-
}
859825
functionExit(thr);
860826
return result;
861827
JNI_END

src/hotspot/share/runtime/jniHandles.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread, AllocFailType all
385385
block->_top = 0;
386386
block->_next = NULL;
387387
block->_pop_frame_link = NULL;
388-
block->_planned_capacity = block_size_in_oops;
389388
// _last, _free_list & _allocate_before_rebuild initialized in allocate_handle
390389
debug_only(block->_last = NULL);
391390
debug_only(block->_free_list = NULL);
@@ -591,22 +590,6 @@ size_t JNIHandleBlock::length() const {
591590
return result;
592591
}
593592

594-
class CountJNIHandleClosure: public OopClosure {
595-
private:
596-
int _count;
597-
public:
598-
CountJNIHandleClosure(): _count(0) {}
599-
virtual void do_oop(oop* ooph) { _count++; }
600-
virtual void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
601-
int count() { return _count; }
602-
};
603-
604-
const size_t JNIHandleBlock::get_number_of_live_handles() {
605-
CountJNIHandleClosure counter;
606-
oops_do(&counter);
607-
return counter.count();
608-
}
609-
610593
// This method is not thread-safe, i.e., must be called while holding a lock on the
611594
// structure.
612595
size_t JNIHandleBlock::memory_usage() const {

src/hotspot/share/runtime/jniHandles.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ class JNIHandleBlock : public CHeapObj<mtInternal> {
154154
uintptr_t* _free_list; // Handle free list
155155
int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list
156156

157-
// Check JNI, "planned capacity" for current frame (or push/ensure)
158-
size_t _planned_capacity;
159-
160157
#ifndef PRODUCT
161158
JNIHandleBlock* _block_list_link; // Link for list below
162159
static JNIHandleBlock* _block_list; // List of all allocated blocks (for debugging only)
@@ -193,11 +190,6 @@ class JNIHandleBlock : public CHeapObj<mtInternal> {
193190
// Traversal of handles
194191
void oops_do(OopClosure* f);
195192

196-
// Checked JNI support
197-
void set_planned_capacity(size_t planned_capacity) { _planned_capacity = planned_capacity; }
198-
const size_t get_planned_capacity() { return _planned_capacity; }
199-
const size_t get_number_of_live_handles();
200-
201193
// Debugging
202194
bool chain_contains(jobject handle) const; // Does this block or following blocks contain handle
203195
bool contains(jobject handle) const; // Does this block contain handle

src/java.base/share/man/java.1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,6 @@ A JNI call was made without checking for a pending exception from a
843843
previous JNI call, and the current call is not safe when an exception
844844
may be pending.
845845
.IP \[bu] 2
846-
The number of JNI local references existing when a JNI function
847-
terminates exceeds the number guaranteed to be available.
848-
See the \f[CB]EnsureLocalcapacity\f[R] function.
849-
.IP \[bu] 2
850846
A class descriptor is in decorated format (\f[CB]Lname;\f[R]) when it
851847
should not be.
852848
.IP \[bu] 2

test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java

Lines changed: 0 additions & 91 deletions
This file was deleted.

test/hotspot/jtreg/runtime/jni/checked/libTestCheckedEnsureLocalCapacity.c

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ tools/jlink/plugins/CompressorPluginTest.java 8247407 generic-
749749
############################################################################
750750

751751
# core_svc
752-
tools/launcher/TestXcheckJNIWarnings.java#jdwp-agent 8296936 generic-all
753752

754753
############################################################################
755754

test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTestCheckJni.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)