comparison src/share/vm/prims/jni.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 104304a54b0c b12a2a9b05ca
children be896a1983c0
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
69 #include "runtime/handles.inline.hpp" 69 #include "runtime/handles.inline.hpp"
70 #include "runtime/interfaceSupport.hpp" 70 #include "runtime/interfaceSupport.hpp"
71 #include "runtime/java.hpp" 71 #include "runtime/java.hpp"
72 #include "runtime/javaCalls.hpp" 72 #include "runtime/javaCalls.hpp"
73 #include "runtime/jfieldIDWorkaround.hpp" 73 #include "runtime/jfieldIDWorkaround.hpp"
74 #include "runtime/orderAccess.inline.hpp"
74 #include "runtime/reflection.hpp" 75 #include "runtime/reflection.hpp"
75 #include "runtime/sharedRuntime.hpp" 76 #include "runtime/sharedRuntime.hpp"
76 #include "runtime/signature.hpp" 77 #include "runtime/signature.hpp"
77 #include "runtime/thread.inline.hpp" 78 #include "runtime/thread.inline.hpp"
78 #include "runtime/vm_operations.hpp" 79 #include "runtime/vm_operations.hpp"
80 #include "services/memTracker.hpp"
79 #include "services/runtimeService.hpp" 81 #include "services/runtimeService.hpp"
80 #include "trace/tracing.hpp" 82 #include "trace/tracing.hpp"
81 #include "utilities/defaultStream.hpp" 83 #include "utilities/defaultStream.hpp"
82 #include "utilities/dtrace.hpp" 84 #include "utilities/dtrace.hpp"
83 #include "utilities/events.hpp" 85 #include "utilities/events.hpp"
292 } 294 }
293 } 295 }
294 guarantee(InstanceKlass::cast(k)->contains_field_offset(offset), 296 guarantee(InstanceKlass::cast(k)->contains_field_offset(offset),
295 "Bug in native code: jfieldID offset must address interior of object"); 297 "Bug in native code: jfieldID offset must address interior of object");
296 } 298 }
297
298 // Pick a reasonable higher bound for local capacity requested
299 // for EnsureLocalCapacity and PushLocalFrame. We don't want it too
300 // high because a test (or very unusual application) may try to allocate
301 // that many handles and run out of swap space. An implementation is
302 // permitted to allocate more handles than the ensured capacity, so this
303 // value is set high enough to prevent compatibility problems.
304 const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K;
305
306 299
307 // Wrapper to trace JNI functions 300 // Wrapper to trace JNI functions
308 301
309 #ifdef ASSERT 302 #ifdef ASSERT
310 Histogram* JNIHistogram; 303 Histogram* JNIHistogram;
881 #else /* USDT2 */ 874 #else /* USDT2 */
882 HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY( 875 HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(
883 env, capacity); 876 env, capacity);
884 #endif /* USDT2 */ 877 #endif /* USDT2 */
885 //%note jni_11 878 //%note jni_11
886 if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) { 879 if (capacity < 0 ||
880 ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) {
887 #ifndef USDT2 881 #ifndef USDT2
888 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); 882 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR);
889 #else /* USDT2 */ 883 #else /* USDT2 */
890 HOTSPOT_JNI_PUSHLOCALFRAME_RETURN( 884 HOTSPOT_JNI_PUSHLOCALFRAME_RETURN(
891 (uint32_t)JNI_ERR); 885 (uint32_t)JNI_ERR);
1040 #else /* USDT2 */ 1034 #else /* USDT2 */
1041 HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY( 1035 HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(
1042 env, capacity); 1036 env, capacity);
1043 #endif /* USDT2 */ 1037 #endif /* USDT2 */
1044 jint ret; 1038 jint ret;
1045 if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { 1039 if (capacity >= 0 &&
1040 ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) {
1046 ret = JNI_OK; 1041 ret = JNI_OK;
1047 } else { 1042 } else {
1048 ret = JNI_ERR; 1043 ret = JNI_ERR;
1049 } 1044 }
1050 #ifndef USDT2 1045 #ifndef USDT2
3590 size_t size = os::vm_allocation_granularity(); 3585 size_t size = os::vm_allocation_granularity();
3591 bad_address = os::reserve_memory(size); 3586 bad_address = os::reserve_memory(size);
3592 if (bad_address != NULL) { 3587 if (bad_address != NULL) {
3593 os::protect_memory(bad_address, size, os::MEM_PROT_READ, 3588 os::protect_memory(bad_address, size, os::MEM_PROT_READ,
3594 /*is_committed*/false); 3589 /*is_committed*/false);
3590 MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal);
3595 } 3591 }
3596 } 3592 }
3597 return bad_address; 3593 return bad_address;
3598 } 3594 }
3599 3595
5065 #include "gc_implementation/shared/gcTimer.hpp" 5061 #include "gc_implementation/shared/gcTimer.hpp"
5066 #include "gc_interface/collectedHeap.hpp" 5062 #include "gc_interface/collectedHeap.hpp"
5067 #if INCLUDE_ALL_GCS 5063 #if INCLUDE_ALL_GCS
5068 #include "gc_implementation/g1/heapRegionRemSet.hpp" 5064 #include "gc_implementation/g1/heapRegionRemSet.hpp"
5069 #endif 5065 #endif
5066 #include "memory/guardedMemory.hpp"
5070 #include "utilities/quickSort.hpp" 5067 #include "utilities/quickSort.hpp"
5071 #include "utilities/ostream.hpp" 5068 #include "utilities/ostream.hpp"
5072 #if INCLUDE_VM_STRUCTS 5069 #if INCLUDE_VM_STRUCTS
5073 #include "runtime/vmStructs.hpp" 5070 #include "runtime/vmStructs.hpp"
5074 #endif 5071 #endif
5083 void TestVirtualSpace_test(); 5080 void TestVirtualSpace_test();
5084 void TestMetaspaceAux_test(); 5081 void TestMetaspaceAux_test();
5085 void TestMetachunk_test(); 5082 void TestMetachunk_test();
5086 void TestVirtualSpaceNode_test(); 5083 void TestVirtualSpaceNode_test();
5087 void TestNewSize_test(); 5084 void TestNewSize_test();
5085 void TestKlass_test();
5086 void Test_linked_list();
5087 void TestChunkedList_test();
5088 #if INCLUDE_ALL_GCS 5088 #if INCLUDE_ALL_GCS
5089 void TestOldFreeSpaceCalculation_test(); 5089 void TestOldFreeSpaceCalculation_test();
5090 void TestG1BiasedArray_test(); 5090 void TestG1BiasedArray_test();
5091 void TestBufferingOopClosure_test();
5091 void TestCodeCacheRemSet_test(); 5092 void TestCodeCacheRemSet_test();
5093 void FreeRegionList_test();
5092 #endif 5094 #endif
5093 5095
5094 void execute_internal_vm_tests() { 5096 void execute_internal_vm_tests() {
5095 if (ExecuteInternalVMTests) { 5097 if (ExecuteInternalVMTests) {
5096 tty->print_cr("Running internal VM tests"); 5098 tty->print_cr("Running internal VM tests");
5103 run_unit_test(GlobalDefinitions::test_globals()); 5105 run_unit_test(GlobalDefinitions::test_globals());
5104 run_unit_test(GCTimerAllTest::all()); 5106 run_unit_test(GCTimerAllTest::all());
5105 run_unit_test(arrayOopDesc::test_max_array_length()); 5107 run_unit_test(arrayOopDesc::test_max_array_length());
5106 run_unit_test(CollectedHeap::test_is_in()); 5108 run_unit_test(CollectedHeap::test_is_in());
5107 run_unit_test(QuickSort::test_quick_sort()); 5109 run_unit_test(QuickSort::test_quick_sort());
5110 run_unit_test(GuardedMemory::test_guarded_memory());
5108 run_unit_test(AltHashing::test_alt_hash()); 5111 run_unit_test(AltHashing::test_alt_hash());
5109 run_unit_test(test_loggc_filename()); 5112 run_unit_test(test_loggc_filename());
5110 run_unit_test(TestNewSize_test()); 5113 run_unit_test(TestNewSize_test());
5114 run_unit_test(TestKlass_test());
5115 run_unit_test(Test_linked_list());
5116 run_unit_test(TestChunkedList_test());
5111 #if INCLUDE_VM_STRUCTS 5117 #if INCLUDE_VM_STRUCTS
5112 run_unit_test(VMStructs::test()); 5118 run_unit_test(VMStructs::test());
5113 #endif 5119 #endif
5114 #if INCLUDE_ALL_GCS 5120 #if INCLUDE_ALL_GCS
5115 run_unit_test(TestOldFreeSpaceCalculation_test()); 5121 run_unit_test(TestOldFreeSpaceCalculation_test());
5116 run_unit_test(TestG1BiasedArray_test()); 5122 run_unit_test(TestG1BiasedArray_test());
5117 run_unit_test(HeapRegionRemSet::test_prt()); 5123 run_unit_test(HeapRegionRemSet::test_prt());
5124 run_unit_test(TestBufferingOopClosure_test());
5118 run_unit_test(TestCodeCacheRemSet_test()); 5125 run_unit_test(TestCodeCacheRemSet_test());
5126 if (UseG1GC) {
5127 run_unit_test(FreeRegionList_test());
5128 }
5119 #endif 5129 #endif
5120 tty->print_cr("All internal VM tests passed"); 5130 tty->print_cr("All internal VM tests passed");
5121 } 5131 }
5122 } 5132 }
5123 5133