8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY

Thu, 14 Aug 2014 10:56:34 +0200

author
dsimms
date
Thu, 14 Aug 2014 10:56:34 +0200
changeset 7038
8ae0d26ab728
parent 7037
5c8178d7dd35
child 7039
43aa571c1131

8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY
Summary: Increase the previous limit from 4k to 64k, added "-XX:MaxJNILocalCapacity=<capacity>" flag
Reviewed-by: hseigel, fparain

src/share/vm/prims/jni.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/globals.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/prims/jni.cpp	Thu Aug 14 12:58:56 2014 -0700
     1.2 +++ b/src/share/vm/prims/jni.cpp	Thu Aug 14 10:56:34 2014 +0200
     1.3 @@ -292,15 +292,6 @@
     1.4        "Bug in native code: jfieldID offset must address interior of object");
     1.5  }
     1.6  
     1.7 -// Pick a reasonable higher bound for local capacity requested
     1.8 -// for EnsureLocalCapacity and PushLocalFrame.  We don't want it too
     1.9 -// high because a test (or very unusual application) may try to allocate
    1.10 -// that many handles and run out of swap space.  An implementation is
    1.11 -// permitted to allocate more handles than the ensured capacity, so this
    1.12 -// value is set high enough to prevent compatibility problems.
    1.13 -const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K;
    1.14 -
    1.15 -
    1.16  // Wrapper to trace JNI functions
    1.17  
    1.18  #ifdef ASSERT
    1.19 @@ -880,7 +871,8 @@
    1.20                                     env, capacity);
    1.21  #endif /* USDT2 */
    1.22    //%note jni_11
    1.23 -  if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) {
    1.24 +  if (capacity < 0 ||
    1.25 +      ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) {
    1.26  #ifndef USDT2
    1.27      DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR);
    1.28  #else /* USDT2 */
    1.29 @@ -1039,7 +1031,8 @@
    1.30                                          env, capacity);
    1.31  #endif /* USDT2 */
    1.32    jint ret;
    1.33 -  if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) {
    1.34 +  if (capacity >= 0 &&
    1.35 +      ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) {
    1.36      ret = JNI_OK;
    1.37    } else {
    1.38      ret = JNI_ERR;
     2.1 --- a/src/share/vm/runtime/globals.hpp	Thu Aug 14 12:58:56 2014 -0700
     2.2 +++ b/src/share/vm/runtime/globals.hpp	Thu Aug 14 10:56:34 2014 +0200
     2.3 @@ -1216,6 +1216,11 @@
     2.4    product(bool, UseFastJNIAccessors, true,                                  \
     2.5            "Use optimized versions of Get<Primitive>Field")                  \
     2.6                                                                              \
     2.7 +  product(intx, MaxJNILocalCapacity, 65536,                                 \
     2.8 +          "Maximum allowable local JNI handle capacity to "                 \
     2.9 +          "EnsureLocalCapacity() and PushLocalFrame(), "                    \
    2.10 +          "where <= 0 is unlimited, default: 65536")                        \
    2.11 +                                                                            \
    2.12    product(bool, EagerXrunInit, false,                                       \
    2.13            "Eagerly initialize -Xrun libraries; allows startup profiling, "  \
    2.14            "but not all -Xrun libraries may support the state of the VM "    \

mercurial