Thu, 12 Mar 2015 17:47:28 -0400
Merge
1.1 --- a/.hgtags Thu Mar 12 15:16:12 2015 -0400 1.2 +++ b/.hgtags Thu Mar 12 17:47:28 2015 -0400 1.3 @@ -599,3 +599,5 @@ 1.4 0fb1ac49ae7764c5d7c6dfb9fe046d0e1a4eb5aa hs25.60-b04 1.5 586a449cd30332dd53c0f74bf2ead6f3d4724bfc jdk8u60-b04 1.6 74931e85352be8556eaa511ca0dd7c38fe272ec3 hs25.60-b05 1.7 +b13f1890afb8abc31ecb9c21fd2ba95aba3e33f8 jdk8u60-b05 1.8 +b17a8a22a0344e3c93e2e4677de20d35f99cf4f5 hs25.60-b06
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Thu Mar 12 15:16:12 2015 -0400 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Thu Mar 12 17:47:28 2015 -0400 2.3 @@ -51,6 +51,9 @@ 2.4 private static final int C_INT32_SIZE = 4; 2.5 private static final int C_INT64_SIZE = 8; 2.6 private static int pointerSize = UNINITIALIZED_SIZE; 2.7 + // Counter to ensure read loops terminate: 2.8 + private static final int MAX_DUPLICATE_DEFINITIONS = 100; 2.9 + private int duplicateDefCount = 0; 2.10 2.11 private static final boolean DEBUG; 2.12 static { 2.13 @@ -166,6 +169,10 @@ 2.14 typeEntrySizeOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset"); 2.15 typeEntryArrayStride = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride"); 2.16 2.17 + if (typeEntryArrayStride == 0L) { 2.18 + throw new RuntimeException("zero stride: cannot read types."); 2.19 + } 2.20 + 2.21 // Start iterating down it until we find an entry with no name 2.22 Address typeNameAddr = null; 2.23 do { 2.24 @@ -192,7 +199,11 @@ 2.25 } 2.26 2.27 entryAddr = entryAddr.addOffsetTo(typeEntryArrayStride); 2.28 - } while (typeNameAddr != null); 2.29 + } while (typeNameAddr != null && duplicateDefCount < MAX_DUPLICATE_DEFINITIONS); 2.30 + 2.31 + if (duplicateDefCount >= MAX_DUPLICATE_DEFINITIONS) { 2.32 + throw new RuntimeException("too many duplicate definitions"); 2.33 + } 2.34 } 2.35 2.36 private void initializePrimitiveTypes() { 2.37 @@ -395,6 +406,10 @@ 2.38 structEntryAddressOffset = getLongValueFromProcess("gHotSpotVMStructEntryAddressOffset"); 2.39 structEntryArrayStride = getLongValueFromProcess("gHotSpotVMStructEntryArrayStride"); 2.40 2.41 + if (structEntryArrayStride == 0L) { 2.42 + throw new RuntimeException("zero stride: cannot read types."); 2.43 + } 2.44 + 2.45 // Fetch the address of the VMStructEntry* 2.46 Address entryAddr = lookupInProcess("gHotSpotVMStructs"); 2.47 // Dereference this once to get the pointer to the first VMStructEntry 2.48 @@ -472,6 +487,11 @@ 2.49 intConstantEntryValueOffset = getLongValueFromProcess("gHotSpotVMIntConstantEntryValueOffset"); 2.50 intConstantEntryArrayStride = getLongValueFromProcess("gHotSpotVMIntConstantEntryArrayStride"); 2.51 2.52 + if (intConstantEntryArrayStride == 0L) { 2.53 + throw new RuntimeException("zero stride: cannot read types."); 2.54 + } 2.55 + 2.56 + 2.57 // Fetch the address of the VMIntConstantEntry* 2.58 Address entryAddr = lookupInProcess("gHotSpotVMIntConstants"); 2.59 // Dereference this once to get the pointer to the first VMIntConstantEntry 2.60 @@ -501,12 +521,17 @@ 2.61 } else { 2.62 System.err.println("Warning: the int constant \"" + name + "\" (declared in the remote VM in VMStructs::localHotSpotVMIntConstants) " + 2.63 "had its value declared as " + value + " twice. Continuing."); 2.64 + duplicateDefCount++; 2.65 } 2.66 } 2.67 } 2.68 2.69 entryAddr = entryAddr.addOffsetTo(intConstantEntryArrayStride); 2.70 - } while (nameAddr != null); 2.71 + } while (nameAddr != null && duplicateDefCount < MAX_DUPLICATE_DEFINITIONS); 2.72 + 2.73 + if (duplicateDefCount >= MAX_DUPLICATE_DEFINITIONS) { 2.74 + throw new RuntimeException("too many duplicate definitions"); 2.75 + } 2.76 } 2.77 2.78 private void readVMLongConstants() { 2.79 @@ -519,6 +544,10 @@ 2.80 longConstantEntryValueOffset = getLongValueFromProcess("gHotSpotVMLongConstantEntryValueOffset"); 2.81 longConstantEntryArrayStride = getLongValueFromProcess("gHotSpotVMLongConstantEntryArrayStride"); 2.82 2.83 + if (longConstantEntryArrayStride == 0L) { 2.84 + throw new RuntimeException("zero stride: cannot read types."); 2.85 + } 2.86 + 2.87 // Fetch the address of the VMLongConstantEntry* 2.88 Address entryAddr = lookupInProcess("gHotSpotVMLongConstants"); 2.89 // Dereference this once to get the pointer to the first VMLongConstantEntry 2.90 @@ -548,12 +577,17 @@ 2.91 } else { 2.92 System.err.println("Warning: the long constant \"" + name + "\" (declared in the remote VM in VMStructs::localHotSpotVMLongConstants) " + 2.93 "had its value declared as " + value + " twice. Continuing."); 2.94 + duplicateDefCount++; 2.95 } 2.96 } 2.97 } 2.98 2.99 entryAddr = entryAddr.addOffsetTo(longConstantEntryArrayStride); 2.100 - } while (nameAddr != null); 2.101 + } while (nameAddr != null && duplicateDefCount < MAX_DUPLICATE_DEFINITIONS); 2.102 + 2.103 + if (duplicateDefCount >= MAX_DUPLICATE_DEFINITIONS) { 2.104 + throw new RuntimeException("too many duplicate definitions."); 2.105 + } 2.106 } 2.107 2.108 private BasicType lookupOrFail(String typeName) { 2.109 @@ -740,9 +774,10 @@ 2.110 } 2.111 2.112 if (!typeNameIsPointerType(typeName)) { 2.113 - System.err.println("Warning: the type \"" + typeName + "\" (declared in the remote VM in VMStructs::localHotSpotVMTypes) " + 2.114 - "had its size declared as " + size + " twice. Continuing."); 2.115 - } 2.116 + System.err.println("Warning: the type \"" + typeName + "\" (declared in the remote VM in VMStructs::localHotSpotVMTypes) " + 2.117 + "had its size declared as " + size + " twice. Continuing."); 2.118 + duplicateDefCount++; 2.119 + } 2.120 } 2.121 2.122 }
3.1 --- a/make/hotspot_version Thu Mar 12 15:16:12 2015 -0400 3.2 +++ b/make/hotspot_version Thu Mar 12 17:47:28 2015 -0400 3.3 @@ -35,7 +35,7 @@ 3.4 3.5 HS_MAJOR_VER=25 3.6 HS_MINOR_VER=60 3.7 -HS_BUILD_NUMBER=06 3.8 +HS_BUILD_NUMBER=07 3.9 3.10 JDK_MAJOR_VER=1 3.11 JDK_MINOR_VER=8
4.1 --- a/src/os/solaris/vm/jvm_solaris.h Thu Mar 12 15:16:12 2015 -0400 4.2 +++ b/src/os/solaris/vm/jvm_solaris.h Thu Mar 12 17:47:28 2015 -0400 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -41,7 +41,9 @@ 4.11 * JNI conversion, which should be sorted out later. 4.12 */ 4.13 4.14 +#define __USE_LEGACY_PROTOTYPES__ 4.15 #include <dirent.h> /* For DIR */ 4.16 +#undef __USE_LEGACY_PROTOTYPES__ 4.17 #include <sys/param.h> /* For MAXPATHLEN */ 4.18 #include <sys/socket.h> /* For socklen_t */ 4.19 #include <unistd.h> /* For F_OK, R_OK, W_OK */
5.1 --- a/src/share/vm/ci/bcEscapeAnalyzer.cpp Thu Mar 12 15:16:12 2015 -0400 5.2 +++ b/src/share/vm/ci/bcEscapeAnalyzer.cpp Thu Mar 12 17:47:28 2015 -0400 5.3 @@ -42,7 +42,7 @@ 5.4 #define TRACE_BCEA(level, code) 5.5 #endif 5.6 5.7 -// Maintain a map of which aguments a local variable or 5.8 +// Maintain a map of which arguments a local variable or 5.9 // stack slot may contain. In addition to tracking 5.10 // arguments, it tracks two special values, "allocated" 5.11 // which represents any object allocated in the current 5.12 @@ -318,14 +318,16 @@ 5.13 bool must_record_dependencies = false; 5.14 for (i = arg_size - 1; i >= 0; i--) { 5.15 ArgumentMap arg = state.raw_pop(); 5.16 - if (!is_argument(arg)) 5.17 + // Check if callee arg is a caller arg or an allocated object 5.18 + bool allocated = arg.contains_allocated(); 5.19 + if (!(is_argument(arg) || allocated)) 5.20 continue; 5.21 for (int j = 0; j < _arg_size; j++) { 5.22 if (arg.contains(j)) { 5.23 _arg_modified[j] |= analyzer._arg_modified[i]; 5.24 } 5.25 } 5.26 - if (!is_arg_stack(arg)) { 5.27 + if (!(is_arg_stack(arg) || allocated)) { 5.28 // arguments have already been recognized as escaping 5.29 } else if (analyzer.is_arg_stack(i) && !analyzer.is_arg_returned(i)) { 5.30 set_method_escape(arg);
6.1 --- a/src/share/vm/memory/guardedMemory.hpp Thu Mar 12 15:16:12 2015 -0400 6.2 +++ b/src/share/vm/memory/guardedMemory.hpp Thu Mar 12 17:47:28 2015 -0400 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -235,7 +235,7 @@ 6.11 * @return the size of the user data. 6.12 */ 6.13 size_t get_user_size() const { 6.14 - assert(_base_addr, "Not wrapping any memory"); 6.15 + assert(_base_addr != NULL, "Not wrapping any memory"); 6.16 return get_head_guard()->get_user_size(); 6.17 } 6.18 6.19 @@ -245,7 +245,7 @@ 6.20 * @return the user data pointer. 6.21 */ 6.22 u_char* get_user_ptr() const { 6.23 - assert(_base_addr, "Not wrapping any memory"); 6.24 + assert(_base_addr != NULL, "Not wrapping any memory"); 6.25 return _base_addr + sizeof(GuardHeader); 6.26 } 6.27 6.28 @@ -281,7 +281,7 @@ 6.29 memset(get_user_ptr(), ch, get_user_size()); 6.30 } 6.31 6.32 -public: 6.33 + public: 6.34 /** 6.35 * Return the total size required for wrapping the given user size. 6.36 *
7.1 --- a/src/share/vm/prims/jniCheck.cpp Thu Mar 12 15:16:12 2015 -0400 7.2 +++ b/src/share/vm/prims/jniCheck.cpp Thu Mar 12 17:47:28 2015 -0400 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -53,6 +53,8 @@ 7.11 # include "jniTypes_ppc.hpp" 7.12 #endif 7.13 7.14 +// Complain every extra number of unplanned local refs 7.15 +#define CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD 32 7.16 7.17 // Heap objects are allowed to be directly referenced only in VM code, 7.18 // not in native code. 7.19 @@ -168,12 +170,42 @@ 7.20 * SUPPORT FUNCTIONS 7.21 */ 7.22 7.23 +/** 7.24 + * Check whether or not a programmer has actually checked for exceptions. According 7.25 + * to the JNI Specification ("jni/spec/design.html#java_exceptions"): 7.26 + * 7.27 + * There are two cases where the programmer needs to check for exceptions without 7.28 + * being able to first check an error code: 7.29 + * 7.30 + * - The JNI functions that invoke a Java method return the result of the Java method. 7.31 + * The programmer must call ExceptionOccurred() to check for possible exceptions 7.32 + * that occurred during the execution of the Java method. 7.33 + * 7.34 + * - Some of the JNI array access functions do not return an error code, but may 7.35 + * throw an ArrayIndexOutOfBoundsException or ArrayStoreException. 7.36 + * 7.37 + * In all other cases, a non-error return value guarantees that no exceptions have been thrown. 7.38 + */ 7.39 +static inline void 7.40 +check_pending_exception(JavaThread* thr) { 7.41 + if (thr->has_pending_exception()) { 7.42 + NativeReportJNIWarning(thr, "JNI call made with exception pending"); 7.43 + } 7.44 + if (thr->is_pending_jni_exception_check()) { 7.45 + IN_VM( 7.46 + tty->print_cr("WARNING in native method: JNI call made without checking exceptions when required to from %s", 7.47 + thr->get_pending_jni_exception_check()); 7.48 + thr->print_stack(); 7.49 + ) 7.50 + thr->clear_pending_jni_exception_check(); // Just complain once 7.51 + } 7.52 +} 7.53 + 7.54 + 7.55 static inline void 7.56 functionEnterCritical(JavaThread* thr) 7.57 { 7.58 - if (thr->has_pending_exception()) { 7.59 - NativeReportJNIWarning(thr, "JNI call made with exception pending"); 7.60 - } 7.61 + check_pending_exception(thr); 7.62 } 7.63 7.64 static inline void 7.65 @@ -187,9 +219,7 @@ 7.66 if (thr->in_critical()) { 7.67 tty->print_cr("%s", warn_other_function_in_critical); 7.68 } 7.69 - if (thr->has_pending_exception()) { 7.70 - NativeReportJNIWarning(thr, "JNI call made with exception pending"); 7.71 - } 7.72 + check_pending_exception(thr); 7.73 } 7.74 7.75 static inline void 7.76 @@ -201,9 +231,20 @@ 7.77 } 7.78 7.79 static inline void 7.80 -functionExit(JNIEnv *env) 7.81 +functionExit(JavaThread* thr) 7.82 { 7.83 - /* nothing to do at this time */ 7.84 + JNIHandleBlock* handles = thr->active_handles(); 7.85 + size_t planned_capacity = handles->get_planned_capacity(); 7.86 + size_t live_handles = handles->get_number_of_live_handles(); 7.87 + if (live_handles > planned_capacity) { 7.88 + IN_VM( 7.89 + tty->print_cr("WARNING: JNI local refs: %zu, exceeds capacity: %zu", 7.90 + live_handles, planned_capacity); 7.91 + thr->print_stack(); 7.92 + ) 7.93 + // Complain just the once, reset to current + warn threshold 7.94 + handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); 7.95 + } 7.96 } 7.97 7.98 static inline void 7.99 @@ -508,7 +549,7 @@ 7.100 jniCheck::validate_object(thr, loader); 7.101 ) 7.102 jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len); 7.103 - functionExit(env); 7.104 + functionExit(thr); 7.105 return result; 7.106 JNI_END 7.107 7.108 @@ -520,7 +561,7 @@ 7.109 jniCheck::validate_class_descriptor(thr, name); 7.110 ) 7.111 jclass result = UNCHECKED()->FindClass(env, name); 7.112 - functionExit(env); 7.113 + functionExit(thr); 7.114 return result; 7.115 JNI_END 7.116 7.117 @@ -532,7 +573,7 @@ 7.118 jniCheck::validate_object(thr, method); 7.119 ) 7.120 jmethodID result = UNCHECKED()->FromReflectedMethod(env, method); 7.121 - functionExit(env); 7.122 + functionExit(thr); 7.123 return result; 7.124 JNI_END 7.125 7.126 @@ -544,7 +585,7 @@ 7.127 jniCheck::validate_object(thr, field); 7.128 ) 7.129 jfieldID result = UNCHECKED()->FromReflectedField(env, field); 7.130 - functionExit(env); 7.131 + functionExit(thr); 7.132 return result; 7.133 JNI_END 7.134 7.135 @@ -560,7 +601,7 @@ 7.136 ) 7.137 jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID, 7.138 isStatic); 7.139 - functionExit(env); 7.140 + functionExit(thr); 7.141 return result; 7.142 JNI_END 7.143 7.144 @@ -572,7 +613,7 @@ 7.145 jniCheck::validate_class(thr, sub, true); 7.146 ) 7.147 jclass result = UNCHECKED()->GetSuperclass(env, sub); 7.148 - functionExit(env); 7.149 + functionExit(thr); 7.150 return result; 7.151 JNI_END 7.152 7.153 @@ -586,7 +627,7 @@ 7.154 jniCheck::validate_class(thr, sup, true); 7.155 ) 7.156 jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup); 7.157 - functionExit(env); 7.158 + functionExit(thr); 7.159 return result; 7.160 JNI_END 7.161 7.162 @@ -601,7 +642,7 @@ 7.163 ) 7.164 jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID, 7.165 isStatic); 7.166 - functionExit(env); 7.167 + functionExit(thr); 7.168 return result; 7.169 JNI_END 7.170 7.171 @@ -619,7 +660,7 @@ 7.172 } 7.173 ) 7.174 jint result = UNCHECKED()->Throw(env, obj); 7.175 - functionExit(env); 7.176 + functionExit(thr); 7.177 return result; 7.178 JNI_END 7.179 7.180 @@ -634,15 +675,16 @@ 7.181 jniCheck::validate_throwable_klass(thr, k); 7.182 ) 7.183 jint result = UNCHECKED()->ThrowNew(env, clazz, msg); 7.184 - functionExit(env); 7.185 + functionExit(thr); 7.186 return result; 7.187 JNI_END 7.188 7.189 JNI_ENTRY_CHECKED(jthrowable, 7.190 checked_jni_ExceptionOccurred(JNIEnv *env)) 7.191 + thr->clear_pending_jni_exception_check(); 7.192 functionEnterExceptionAllowed(thr); 7.193 jthrowable result = UNCHECKED()->ExceptionOccurred(env); 7.194 - functionExit(env); 7.195 + functionExit(thr); 7.196 return result; 7.197 JNI_END 7.198 7.199 @@ -650,22 +692,24 @@ 7.200 checked_jni_ExceptionDescribe(JNIEnv *env)) 7.201 functionEnterExceptionAllowed(thr); 7.202 UNCHECKED()->ExceptionDescribe(env); 7.203 - functionExit(env); 7.204 + functionExit(thr); 7.205 JNI_END 7.206 7.207 JNI_ENTRY_CHECKED(void, 7.208 checked_jni_ExceptionClear(JNIEnv *env)) 7.209 + thr->clear_pending_jni_exception_check(); 7.210 functionEnterExceptionAllowed(thr); 7.211 UNCHECKED()->ExceptionClear(env); 7.212 - functionExit(env); 7.213 + functionExit(thr); 7.214 JNI_END 7.215 7.216 JNI_ENTRY_CHECKED(void, 7.217 checked_jni_FatalError(JNIEnv *env, 7.218 const char *msg)) 7.219 + thr->clear_pending_jni_exception_check(); 7.220 functionEnter(thr); 7.221 UNCHECKED()->FatalError(env, msg); 7.222 - functionExit(env); 7.223 + functionExit(thr); 7.224 JNI_END 7.225 7.226 JNI_ENTRY_CHECKED(jint, 7.227 @@ -675,7 +719,10 @@ 7.228 if (capacity < 0) 7.229 NativeReportJNIFatalError(thr, "negative capacity"); 7.230 jint result = UNCHECKED()->PushLocalFrame(env, capacity); 7.231 - functionExit(env); 7.232 + if (result == JNI_OK) { 7.233 + thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); 7.234 + } 7.235 + functionExit(thr); 7.236 return result; 7.237 JNI_END 7.238 7.239 @@ -684,7 +731,7 @@ 7.240 jobject result)) 7.241 functionEnterExceptionAllowed(thr); 7.242 jobject res = UNCHECKED()->PopLocalFrame(env, result); 7.243 - functionExit(env); 7.244 + functionExit(thr); 7.245 return res; 7.246 JNI_END 7.247 7.248 @@ -698,7 +745,7 @@ 7.249 } 7.250 ) 7.251 jobject result = UNCHECKED()->NewGlobalRef(env,lobj); 7.252 - functionExit(env); 7.253 + functionExit(thr); 7.254 return result; 7.255 JNI_END 7.256 7.257 @@ -714,7 +761,7 @@ 7.258 } 7.259 ) 7.260 UNCHECKED()->DeleteGlobalRef(env,gref); 7.261 - functionExit(env); 7.262 + functionExit(thr); 7.263 JNI_END 7.264 7.265 JNI_ENTRY_CHECKED(void, 7.266 @@ -729,7 +776,7 @@ 7.267 "Invalid local JNI handle passed to DeleteLocalRef"); 7.268 ) 7.269 UNCHECKED()->DeleteLocalRef(env, obj); 7.270 - functionExit(env); 7.271 + functionExit(thr); 7.272 JNI_END 7.273 7.274 JNI_ENTRY_CHECKED(jboolean, 7.275 @@ -750,7 +797,7 @@ 7.276 } 7.277 ) 7.278 jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2); 7.279 - functionExit(env); 7.280 + functionExit(thr); 7.281 return result; 7.282 JNI_END 7.283 7.284 @@ -764,7 +811,7 @@ 7.285 } 7.286 ) 7.287 jobject result = UNCHECKED()->NewLocalRef(env, ref); 7.288 - functionExit(env); 7.289 + functionExit(thr); 7.290 return result; 7.291 JNI_END 7.292 7.293 @@ -776,7 +823,10 @@ 7.294 NativeReportJNIFatalError(thr, "negative capacity"); 7.295 } 7.296 jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity); 7.297 - functionExit(env); 7.298 + if (result == JNI_OK) { 7.299 + thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); 7.300 + } 7.301 + functionExit(thr); 7.302 return result; 7.303 JNI_END 7.304 7.305 @@ -788,7 +838,7 @@ 7.306 jniCheck::validate_class(thr, clazz, false); 7.307 ) 7.308 jobject result = UNCHECKED()->AllocObject(env,clazz); 7.309 - functionExit(env); 7.310 + functionExit(thr); 7.311 return result; 7.312 JNI_END 7.313 7.314 @@ -806,7 +856,7 @@ 7.315 va_start(args, methodID); 7.316 jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args); 7.317 va_end(args); 7.318 - functionExit(env); 7.319 + functionExit(thr); 7.320 return result; 7.321 JNI_END 7.322 7.323 @@ -821,7 +871,7 @@ 7.324 jniCheck::validate_jmethod_id(thr, methodID); 7.325 ) 7.326 jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args); 7.327 - functionExit(env); 7.328 + functionExit(thr); 7.329 return result; 7.330 JNI_END 7.331 7.332 @@ -836,7 +886,7 @@ 7.333 jniCheck::validate_jmethod_id(thr, methodID); 7.334 ) 7.335 jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args); 7.336 - functionExit(env); 7.337 + functionExit(thr); 7.338 return result; 7.339 JNI_END 7.340 7.341 @@ -848,7 +898,7 @@ 7.342 jniCheck::validate_object(thr, obj); 7.343 ) 7.344 jclass result = UNCHECKED()->GetObjectClass(env,obj); 7.345 - functionExit(env); 7.346 + functionExit(thr); 7.347 return result; 7.348 JNI_END 7.349 7.350 @@ -862,7 +912,7 @@ 7.351 jniCheck::validate_class(thr, clazz, true); 7.352 ) 7.353 jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz); 7.354 - functionExit(env); 7.355 + functionExit(thr); 7.356 return result; 7.357 JNI_END 7.358 7.359 @@ -876,7 +926,7 @@ 7.360 jniCheck::validate_class(thr, clazz, false); 7.361 ) 7.362 jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig); 7.363 - functionExit(env); 7.364 + functionExit(thr); 7.365 return result; 7.366 JNI_END 7.367 7.368 @@ -895,7 +945,8 @@ 7.369 ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \ 7.370 args); \ 7.371 va_end(args); \ 7.372 - functionExit(env); \ 7.373 + thr->set_pending_jni_exception_check("Call"#Result"Method"); \ 7.374 + functionExit(thr); \ 7.375 return result; \ 7.376 JNI_END \ 7.377 \ 7.378 @@ -910,7 +961,8 @@ 7.379 ) \ 7.380 ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\ 7.381 args); \ 7.382 - functionExit(env); \ 7.383 + thr->set_pending_jni_exception_check("Call"#Result"MethodV"); \ 7.384 + functionExit(thr); \ 7.385 return result; \ 7.386 JNI_END \ 7.387 \ 7.388 @@ -925,7 +977,8 @@ 7.389 ) \ 7.390 ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\ 7.391 args); \ 7.392 - functionExit(env); \ 7.393 + thr->set_pending_jni_exception_check("Call"#Result"MethodA"); \ 7.394 + functionExit(thr); \ 7.395 return result; \ 7.396 JNI_END 7.397 7.398 @@ -952,7 +1005,8 @@ 7.399 va_start(args,methodID); 7.400 UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); 7.401 va_end(args); 7.402 - functionExit(env); 7.403 + thr->set_pending_jni_exception_check("CallVoidMethod"); 7.404 + functionExit(thr); 7.405 JNI_END 7.406 7.407 JNI_ENTRY_CHECKED(void, 7.408 @@ -965,7 +1019,8 @@ 7.409 jniCheck::validate_call_object(thr, obj, methodID); 7.410 ) 7.411 UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); 7.412 - functionExit(env); 7.413 + thr->set_pending_jni_exception_check("CallVoidMethodV"); 7.414 + functionExit(thr); 7.415 JNI_END 7.416 7.417 JNI_ENTRY_CHECKED(void, 7.418 @@ -978,7 +1033,8 @@ 7.419 jniCheck::validate_call_object(thr, obj, methodID); 7.420 ) 7.421 UNCHECKED()->CallVoidMethodA(env,obj,methodID,args); 7.422 - functionExit(env); 7.423 + thr->set_pending_jni_exception_check("CallVoidMethodA"); 7.424 + functionExit(thr); 7.425 JNI_END 7.426 7.427 #define WRAPPER_CallNonvirtualMethod(ResultType, Result) \ 7.428 @@ -1001,7 +1057,8 @@ 7.429 methodID,\ 7.430 args); \ 7.431 va_end(args); \ 7.432 - functionExit(env); \ 7.433 + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"Method"); \ 7.434 + functionExit(thr); \ 7.435 return result; \ 7.436 JNI_END \ 7.437 \ 7.438 @@ -1021,7 +1078,8 @@ 7.439 clazz, \ 7.440 methodID,\ 7.441 args); \ 7.442 - functionExit(env); \ 7.443 + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodV"); \ 7.444 + functionExit(thr); \ 7.445 return result; \ 7.446 JNI_END \ 7.447 \ 7.448 @@ -1041,7 +1099,8 @@ 7.449 clazz, \ 7.450 methodID,\ 7.451 args); \ 7.452 - functionExit(env); \ 7.453 + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodA"); \ 7.454 + functionExit(thr); \ 7.455 return result; \ 7.456 JNI_END 7.457 7.458 @@ -1070,7 +1129,8 @@ 7.459 va_start(args,methodID); 7.460 UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args); 7.461 va_end(args); 7.462 - functionExit(env); 7.463 + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethod"); 7.464 + functionExit(thr); 7.465 JNI_END 7.466 7.467 JNI_ENTRY_CHECKED(void, 7.468 @@ -1085,7 +1145,8 @@ 7.469 jniCheck::validate_call_class(thr, clazz, methodID); 7.470 ) 7.471 UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args); 7.472 - functionExit(env); 7.473 + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodV"); 7.474 + functionExit(thr); 7.475 JNI_END 7.476 7.477 JNI_ENTRY_CHECKED(void, 7.478 @@ -1100,7 +1161,8 @@ 7.479 jniCheck::validate_call_class(thr, clazz, methodID); 7.480 ) 7.481 UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args); 7.482 - functionExit(env); 7.483 + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodA"); 7.484 + functionExit(thr); 7.485 JNI_END 7.486 7.487 JNI_ENTRY_CHECKED(jfieldID, 7.488 @@ -1113,7 +1175,7 @@ 7.489 jniCheck::validate_class(thr, clazz, false); 7.490 ) 7.491 jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig); 7.492 - functionExit(env); 7.493 + functionExit(thr); 7.494 return result; 7.495 JNI_END 7.496 7.497 @@ -1127,7 +1189,7 @@ 7.498 checkInstanceFieldID(thr, fieldID, obj, FieldType); \ 7.499 ) \ 7.500 ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \ 7.501 - functionExit(env); \ 7.502 + functionExit(thr); \ 7.503 return result; \ 7.504 JNI_END 7.505 7.506 @@ -1152,7 +1214,7 @@ 7.507 checkInstanceFieldID(thr, fieldID, obj, FieldType); \ 7.508 ) \ 7.509 UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \ 7.510 - functionExit(env); \ 7.511 + functionExit(thr); \ 7.512 JNI_END 7.513 7.514 WRAPPER_SetField(jobject, Object, T_OBJECT) 7.515 @@ -1176,7 +1238,7 @@ 7.516 jniCheck::validate_class(thr, clazz, false); 7.517 ) 7.518 jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig); 7.519 - functionExit(env); 7.520 + functionExit(thr); 7.521 return result; 7.522 JNI_END 7.523 7.524 @@ -1198,7 +1260,8 @@ 7.525 methodID, \ 7.526 args); \ 7.527 va_end(args); \ 7.528 - functionExit(env); \ 7.529 + thr->set_pending_jni_exception_check("CallStatic"#Result"Method"); \ 7.530 + functionExit(thr); \ 7.531 return result; \ 7.532 JNI_END \ 7.533 \ 7.534 @@ -1216,7 +1279,8 @@ 7.535 clazz, \ 7.536 methodID, \ 7.537 args); \ 7.538 - functionExit(env); \ 7.539 + thr->set_pending_jni_exception_check("CallStatic"#Result"MethodV"); \ 7.540 + functionExit(thr); \ 7.541 return result; \ 7.542 JNI_END \ 7.543 \ 7.544 @@ -1234,7 +1298,8 @@ 7.545 clazz, \ 7.546 methodID, \ 7.547 args); \ 7.548 - functionExit(env); \ 7.549 + thr->set_pending_jni_exception_check("CallStatic"#Result"MethodA"); \ 7.550 + functionExit(thr); \ 7.551 return result; \ 7.552 JNI_END 7.553 7.554 @@ -1262,7 +1327,8 @@ 7.555 va_start(args,methodID); 7.556 UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args); 7.557 va_end(args); 7.558 - functionExit(env); 7.559 + thr->set_pending_jni_exception_check("CallStaticVoidMethod"); 7.560 + functionExit(thr); 7.561 JNI_END 7.562 7.563 JNI_ENTRY_CHECKED(void, 7.564 @@ -1276,7 +1342,8 @@ 7.565 jniCheck::validate_class(thr, cls, false); 7.566 ) 7.567 UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args); 7.568 - functionExit(env); 7.569 + thr->set_pending_jni_exception_check("CallStaticVoidMethodV"); 7.570 + functionExit(thr); 7.571 JNI_END 7.572 7.573 JNI_ENTRY_CHECKED(void, 7.574 @@ -1290,7 +1357,8 @@ 7.575 jniCheck::validate_class(thr, cls, false); 7.576 ) 7.577 UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args); 7.578 - functionExit(env); 7.579 + thr->set_pending_jni_exception_check("CallStaticVoidMethodA"); 7.580 + functionExit(thr); 7.581 JNI_END 7.582 7.583 JNI_ENTRY_CHECKED(jfieldID, 7.584 @@ -1303,7 +1371,7 @@ 7.585 jniCheck::validate_class(thr, clazz, false); 7.586 ) 7.587 jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig); 7.588 - functionExit(env); 7.589 + functionExit(thr); 7.590 return result; 7.591 JNI_END 7.592 7.593 @@ -1320,7 +1388,7 @@ 7.594 ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \ 7.595 clazz, \ 7.596 fieldID); \ 7.597 - functionExit(env); \ 7.598 + functionExit(thr); \ 7.599 return result; \ 7.600 JNI_END 7.601 7.602 @@ -1346,7 +1414,7 @@ 7.603 checkStaticFieldID(thr, fieldID, clazz, FieldType); \ 7.604 ) \ 7.605 UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \ 7.606 - functionExit(env); \ 7.607 + functionExit(thr); \ 7.608 JNI_END 7.609 7.610 WRAPPER_SetStaticField(jobject, Object, T_OBJECT) 7.611 @@ -1366,7 +1434,7 @@ 7.612 jsize len)) 7.613 functionEnter(thr); 7.614 jstring result = UNCHECKED()->NewString(env,unicode,len); 7.615 - functionExit(env); 7.616 + functionExit(thr); 7.617 return result; 7.618 JNI_END 7.619 7.620 @@ -1378,7 +1446,7 @@ 7.621 checkString(thr, str); 7.622 ) 7.623 jsize result = UNCHECKED()->GetStringLength(env,str); 7.624 - functionExit(env); 7.625 + functionExit(thr); 7.626 return result; 7.627 JNI_END 7.628 7.629 @@ -1407,7 +1475,7 @@ 7.630 // Note that the dtrace arguments for the allocated memory will not match up with this solution. 7.631 FreeHeap((char*)result); 7.632 } 7.633 - functionExit(env); 7.634 + functionExit(thr); 7.635 return new_result; 7.636 JNI_END 7.637 7.638 @@ -1442,7 +1510,7 @@ 7.639 UNCHECKED()->ReleaseStringChars(env, str, 7.640 (const jchar*) guarded.release_for_freeing()); 7.641 } 7.642 - functionExit(env); 7.643 + functionExit(thr); 7.644 JNI_END 7.645 7.646 JNI_ENTRY_CHECKED(jstring, 7.647 @@ -1450,7 +1518,7 @@ 7.648 const char *utf)) 7.649 functionEnter(thr); 7.650 jstring result = UNCHECKED()->NewStringUTF(env,utf); 7.651 - functionExit(env); 7.652 + functionExit(thr); 7.653 return result; 7.654 JNI_END 7.655 7.656 @@ -1462,7 +1530,7 @@ 7.657 checkString(thr, str); 7.658 ) 7.659 jsize result = UNCHECKED()->GetStringUTFLength(env,str); 7.660 - functionExit(env); 7.661 + functionExit(thr); 7.662 return result; 7.663 JNI_END 7.664 7.665 @@ -1490,7 +1558,7 @@ 7.666 // Note that the dtrace arguments for the allocated memory will not match up with this solution. 7.667 FreeHeap((char*)result, mtInternal); 7.668 } 7.669 - functionExit(env); 7.670 + functionExit(thr); 7.671 return new_result; 7.672 JNI_END 7.673 7.674 @@ -1525,7 +1593,7 @@ 7.675 UNCHECKED()->ReleaseStringUTFChars(env, str, 7.676 (const char*) guarded.release_for_freeing()); 7.677 } 7.678 - functionExit(env); 7.679 + functionExit(thr); 7.680 JNI_END 7.681 7.682 JNI_ENTRY_CHECKED(jsize, 7.683 @@ -1536,7 +1604,7 @@ 7.684 check_is_array(thr, array); 7.685 ) 7.686 jsize result = UNCHECKED()->GetArrayLength(env,array); 7.687 - functionExit(env); 7.688 + functionExit(thr); 7.689 return result; 7.690 JNI_END 7.691 7.692 @@ -1547,7 +1615,7 @@ 7.693 jobject init)) 7.694 functionEnter(thr); 7.695 jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init); 7.696 - functionExit(env); 7.697 + functionExit(thr); 7.698 return result; 7.699 JNI_END 7.700 7.701 @@ -1560,7 +1628,8 @@ 7.702 check_is_obj_array(thr, array); 7.703 ) 7.704 jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index); 7.705 - functionExit(env); 7.706 + thr->set_pending_jni_exception_check("GetObjectArrayElement"); 7.707 + functionExit(thr); 7.708 return result; 7.709 JNI_END 7.710 7.711 @@ -1574,7 +1643,8 @@ 7.712 check_is_obj_array(thr, array); 7.713 ) 7.714 UNCHECKED()->SetObjectArrayElement(env,array,index,val); 7.715 - functionExit(env); 7.716 + thr->set_pending_jni_exception_check("SetObjectArrayElement"); 7.717 + functionExit(thr); 7.718 JNI_END 7.719 7.720 #define WRAPPER_NewScalarArray(Return, Result) \ 7.721 @@ -1583,7 +1653,7 @@ 7.722 jsize len)) \ 7.723 functionEnter(thr); \ 7.724 Return result = UNCHECKED()->New##Result##Array(env,len); \ 7.725 - functionExit(env); \ 7.726 + functionExit(thr); \ 7.727 return (Return) result; \ 7.728 JNI_END 7.729 7.730 @@ -1611,7 +1681,7 @@ 7.731 if (result != NULL) { \ 7.732 result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \ 7.733 } \ 7.734 - functionExit(env); \ 7.735 + functionExit(thr); \ 7.736 return result; \ 7.737 JNI_END 7.738 7.739 @@ -1639,7 +1709,7 @@ 7.740 ElementType* orig_result = (ElementType *) check_wrapped_array_release( \ 7.741 thr, "checked_jni_Release"#Result"ArrayElements", array, elems, mode); \ 7.742 UNCHECKED()->Release##Result##ArrayElements(env, array, orig_result, mode); \ 7.743 - functionExit(env); \ 7.744 + functionExit(thr); \ 7.745 JNI_END 7.746 7.747 WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool) 7.748 @@ -1663,7 +1733,8 @@ 7.749 check_primitive_array_type(thr, array, ElementTag); \ 7.750 ) \ 7.751 UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \ 7.752 - functionExit(env); \ 7.753 + thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \ 7.754 + functionExit(thr); \ 7.755 JNI_END 7.756 7.757 WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean) 7.758 @@ -1687,7 +1758,8 @@ 7.759 check_primitive_array_type(thr, array, ElementTag); \ 7.760 ) \ 7.761 UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \ 7.762 - functionExit(env); \ 7.763 + thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \ 7.764 + functionExit(thr); \ 7.765 JNI_END 7.766 7.767 WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean) 7.768 @@ -1706,7 +1778,7 @@ 7.769 jint nMethods)) 7.770 functionEnter(thr); 7.771 jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods); 7.772 - functionExit(env); 7.773 + functionExit(thr); 7.774 return result; 7.775 JNI_END 7.776 7.777 @@ -1715,7 +1787,7 @@ 7.778 jclass clazz)) 7.779 functionEnter(thr); 7.780 jint result = UNCHECKED()->UnregisterNatives(env,clazz); 7.781 - functionExit(env); 7.782 + functionExit(thr); 7.783 return result; 7.784 JNI_END 7.785 7.786 @@ -1727,7 +1799,7 @@ 7.787 jniCheck::validate_object(thr, obj); 7.788 ) 7.789 jint result = UNCHECKED()->MonitorEnter(env,obj); 7.790 - functionExit(env); 7.791 + functionExit(thr); 7.792 return result; 7.793 JNI_END 7.794 7.795 @@ -1739,7 +1811,7 @@ 7.796 jniCheck::validate_object(thr, obj); 7.797 ) 7.798 jint result = UNCHECKED()->MonitorExit(env,obj); 7.799 - functionExit(env); 7.800 + functionExit(thr); 7.801 return result; 7.802 JNI_END 7.803 7.804 @@ -1748,7 +1820,7 @@ 7.805 JavaVM **vm)) 7.806 functionEnter(thr); 7.807 jint result = UNCHECKED()->GetJavaVM(env,vm); 7.808 - functionExit(env); 7.809 + functionExit(thr); 7.810 return result; 7.811 JNI_END 7.812 7.813 @@ -1763,7 +1835,8 @@ 7.814 checkString(thr, str); 7.815 ) 7.816 UNCHECKED()->GetStringRegion(env, str, start, len, buf); 7.817 - functionExit(env); 7.818 + thr->set_pending_jni_exception_check("GetStringRegion"); 7.819 + functionExit(thr); 7.820 JNI_END 7.821 7.822 JNI_ENTRY_CHECKED(void, 7.823 @@ -1777,7 +1850,8 @@ 7.824 checkString(thr, str); 7.825 ) 7.826 UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf); 7.827 - functionExit(env); 7.828 + thr->set_pending_jni_exception_check("GetStringUTFRegion"); 7.829 + functionExit(thr); 7.830 JNI_END 7.831 7.832 JNI_ENTRY_CHECKED(void *, 7.833 @@ -1792,7 +1866,7 @@ 7.834 if (result != NULL) { 7.835 result = check_jni_wrap_copy_array(thr, array, result); 7.836 } 7.837 - functionExit(env); 7.838 + functionExit(thr); 7.839 return result; 7.840 JNI_END 7.841 7.842 @@ -1808,7 +1882,7 @@ 7.843 // Check the element array... 7.844 void* orig_result = check_wrapped_array_release(thr, "ReleasePrimitiveArrayCritical", array, carray, mode); 7.845 UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, orig_result, mode); 7.846 - functionExit(env); 7.847 + functionExit(thr); 7.848 JNI_END 7.849 7.850 JNI_ENTRY_CHECKED(const jchar*, 7.851 @@ -1820,7 +1894,7 @@ 7.852 checkString(thr, string); 7.853 ) 7.854 const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy); 7.855 - functionExit(env); 7.856 + functionExit(thr); 7.857 return result; 7.858 JNI_END 7.859 7.860 @@ -1836,7 +1910,7 @@ 7.861 * string parameter as a minor sanity check 7.862 */ 7.863 UNCHECKED()->ReleaseStringCritical(env, str, chars); 7.864 - functionExit(env); 7.865 + functionExit(thr); 7.866 JNI_END 7.867 7.868 JNI_ENTRY_CHECKED(jweak, 7.869 @@ -1849,7 +1923,7 @@ 7.870 } 7.871 ) 7.872 jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj); 7.873 - functionExit(env); 7.874 + functionExit(thr); 7.875 return result; 7.876 JNI_END 7.877 7.878 @@ -1858,14 +1932,15 @@ 7.879 jweak ref)) 7.880 functionEnterExceptionAllowed(thr); 7.881 UNCHECKED()->DeleteWeakGlobalRef(env, ref); 7.882 - functionExit(env); 7.883 + functionExit(thr); 7.884 JNI_END 7.885 7.886 JNI_ENTRY_CHECKED(jboolean, 7.887 checked_jni_ExceptionCheck(JNIEnv *env)) 7.888 + thr->clear_pending_jni_exception_check(); 7.889 functionEnterExceptionAllowed(thr); 7.890 jboolean result = UNCHECKED()->ExceptionCheck(env); 7.891 - functionExit(env); 7.892 + functionExit(thr); 7.893 return result; 7.894 JNI_END 7.895 7.896 @@ -1875,7 +1950,7 @@ 7.897 jlong capacity)) 7.898 functionEnter(thr); 7.899 jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity); 7.900 - functionExit(env); 7.901 + functionExit(thr); 7.902 return result; 7.903 JNI_END 7.904 7.905 @@ -1884,7 +1959,7 @@ 7.906 jobject buf)) 7.907 functionEnter(thr); 7.908 void* result = UNCHECKED()->GetDirectBufferAddress(env, buf); 7.909 - functionExit(env); 7.910 + functionExit(thr); 7.911 return result; 7.912 JNI_END 7.913 7.914 @@ -1893,7 +1968,7 @@ 7.915 jobject buf)) 7.916 functionEnter(thr); 7.917 jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf); 7.918 - functionExit(env); 7.919 + functionExit(thr); 7.920 return result; 7.921 JNI_END 7.922 7.923 @@ -1906,7 +1981,7 @@ 7.924 jniCheck::validate_object(thr, obj); 7.925 ) 7.926 jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj); 7.927 - functionExit(env); 7.928 + functionExit(thr); 7.929 return result; 7.930 JNI_END 7.931 7.932 @@ -1915,7 +1990,7 @@ 7.933 checked_jni_GetVersion(JNIEnv *env)) 7.934 functionEnter(thr); 7.935 jint result = UNCHECKED()->GetVersion(env); 7.936 - functionExit(env); 7.937 + functionExit(thr); 7.938 return result; 7.939 JNI_END 7.940
8.1 --- a/src/share/vm/runtime/jniHandles.cpp Thu Mar 12 15:16:12 2015 -0400 8.2 +++ b/src/share/vm/runtime/jniHandles.cpp Thu Mar 12 17:47:28 2015 -0400 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -296,6 +296,7 @@ 8.11 block->_top = 0; 8.12 block->_next = NULL; 8.13 block->_pop_frame_link = NULL; 8.14 + block->_planned_capacity = block_size_in_oops; 8.15 // _last, _free_list & _allocate_before_rebuild initialized in allocate_handle 8.16 debug_only(block->_last = NULL); 8.17 debug_only(block->_free_list = NULL); 8.18 @@ -529,6 +530,12 @@ 8.19 return result; 8.20 } 8.21 8.22 +const size_t JNIHandleBlock::get_number_of_live_handles() { 8.23 + CountHandleClosure counter; 8.24 + oops_do(&counter); 8.25 + return counter.count(); 8.26 +} 8.27 + 8.28 // This method is not thread-safe, i.e., must be called whule holding a lock on the 8.29 // structure. 8.30 long JNIHandleBlock::memory_usage() const {
9.1 --- a/src/share/vm/runtime/jniHandles.hpp Thu Mar 12 15:16:12 2015 -0400 9.2 +++ b/src/share/vm/runtime/jniHandles.hpp Thu Mar 12 17:47:28 2015 -0400 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -112,6 +112,9 @@ 9.11 oop* _free_list; // Handle free list 9.12 int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list 9.13 9.14 + // Check JNI, "planned capacity" for current frame (or push/ensure) 9.15 + size_t _planned_capacity; 9.16 + 9.17 #ifndef PRODUCT 9.18 JNIHandleBlock* _block_list_link; // Link for list below 9.19 static JNIHandleBlock* _block_list; // List of all allocated blocks (for debugging only) 9.20 @@ -152,6 +155,11 @@ 9.21 // Traversal of weak handles. Unreachable oops are cleared. 9.22 void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f); 9.23 9.24 + // Checked JNI support 9.25 + void set_planned_capacity(size_t planned_capacity) { _planned_capacity = planned_capacity; } 9.26 + const size_t get_planned_capacity() { return _planned_capacity; } 9.27 + const size_t get_number_of_live_handles(); 9.28 + 9.29 // Debugging 9.30 bool chain_contains(jobject handle) const; // Does this block or following blocks contain handle 9.31 bool contains(jobject handle) const; // Does this block contain handle
10.1 --- a/src/share/vm/runtime/thread.cpp Thu Mar 12 15:16:12 2015 -0400 10.2 +++ b/src/share/vm/runtime/thread.cpp Thu Mar 12 17:47:28 2015 -0400 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -1465,6 +1465,7 @@ 10.11 _thread_stat = new ThreadStatistics(); 10.12 _blocked_on_compilation = false; 10.13 _jni_active_critical = 0; 10.14 + _pending_jni_exception_check_fn = NULL; 10.15 _do_not_unlock_if_synchronized = false; 10.16 _cached_monitor_info = NULL; 10.17 _parker = Parker::Allocate(this) ;
11.1 --- a/src/share/vm/runtime/thread.hpp Thu Mar 12 15:16:12 2015 -0400 11.2 +++ b/src/share/vm/runtime/thread.hpp Thu Mar 12 17:47:28 2015 -0400 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -926,6 +926,9 @@ 11.11 // support for JNI critical regions 11.12 jint _jni_active_critical; // count of entries into JNI critical region 11.13 11.14 + // Checked JNI: function name requires exception check 11.15 + char* _pending_jni_exception_check_fn; 11.16 + 11.17 // For deadlock detection. 11.18 int _depth_first_number; 11.19 11.20 @@ -1408,6 +1411,12 @@ 11.21 assert(_jni_active_critical >= 0, 11.22 "JNI critical nesting problem?"); } 11.23 11.24 + // Checked JNI, is the programmer required to check for exceptions, specify which function name 11.25 + bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; } 11.26 + void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; } 11.27 + const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; } 11.28 + void set_pending_jni_exception_check(const char* fn_name) { _pending_jni_exception_check_fn = (char*) fn_name; } 11.29 + 11.30 // For deadlock detection 11.31 int depth_first_number() { return _depth_first_number; } 11.32 void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
12.1 --- a/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp Thu Mar 12 15:16:12 2015 -0400 12.2 +++ b/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp Thu Mar 12 17:47:28 2015 -0400 12.3 @@ -1,5 +1,5 @@ 12.4 /* 12.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 12.6 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. 12.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.8 * 12.9 * This code is free software; you can redistribute it and/or modify it 12.10 @@ -33,7 +33,9 @@ 12.11 12.12 12.13 # include <ctype.h> 12.14 +#define __USE_LEGACY_PROTOTYPES__ 12.15 # include <dirent.h> 12.16 +#undef __USE_LEGACY_PROTOTYPES__ 12.17 # include <string.h> 12.18 # include <strings.h> // for bsd'isms 12.19 # include <stdarg.h>
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/compiler/escapeAnalysis/TestEscapeThroughInvoke.java Thu Mar 12 17:47:28 2015 -0400 13.3 @@ -0,0 +1,74 @@ 13.4 +/* 13.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +/** 13.28 + * @test 13.29 + * @bug 8073956 13.30 + * @summary Tests C2 EA with allocated object escaping through a call. 13.31 + * @run main/othervm -XX:CompileCommand=dontinline,TestEscapeThroughInvoke::create TestEscapeThroughInvoke 13.32 + */ 13.33 +public class TestEscapeThroughInvoke { 13.34 + private A a; 13.35 + 13.36 + public static void main(String[] args) { 13.37 + TestEscapeThroughInvoke test = new TestEscapeThroughInvoke(); 13.38 + test.a = new A(42); 13.39 + // Make sure run gets compiled by C2 13.40 + for (int i = 0; i < 100_000; ++i) { 13.41 + test.run(); 13.42 + } 13.43 + } 13.44 + 13.45 + private void run() { 13.46 + // Allocate something to trigger EA 13.47 + new Object(); 13.48 + // Create a new escaping instance of A and 13.49 + // verify that it is always equal to 'a.saved'. 13.50 + A escapingA = create(42); 13.51 + a.check(escapingA); 13.52 + } 13.53 + 13.54 + // Create and return a new instance of A that escaped through 'A::saveInto'. 13.55 + // The 'dummy' parameters are needed to avoid EA skipping the methods. 13.56 + private A create(Integer dummy) { 13.57 + A result = new A(dummy); 13.58 + result.saveInto(a, dummy); // result escapes into 'a' here 13.59 + return result; 13.60 + } 13.61 +} 13.62 + 13.63 +class A { 13.64 + private A saved; 13.65 + 13.66 + public A(Integer dummy) { } 13.67 + 13.68 + public void saveInto(A other, Integer dummy) { 13.69 + other.saved = this; 13.70 + } 13.71 + 13.72 + public void check(A other) { 13.73 + if (this.saved != other) { 13.74 + throw new RuntimeException("TEST FAILED: Objects not equal."); 13.75 + } 13.76 + } 13.77 +}