Fri, 20 Jul 2012 12:09:31 -0400
Merge
test/runtime/6294277/Test6294277.sh | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/services/memRecorder.cpp Thu Jul 19 16:17:41 2012 -0700 1.2 +++ b/src/share/vm/services/memRecorder.cpp Fri Jul 20 12:09:31 2012 -0400 1.3 @@ -45,11 +45,11 @@ 1.4 } 1.5 1.6 1.7 -debug_only(volatile jint MemRecorder::_instance_count = 0;) 1.8 +volatile jint MemRecorder::_instance_count = 0; 1.9 1.10 MemRecorder::MemRecorder() { 1.11 assert(MemTracker::is_on(), "Native memory tracking is off"); 1.12 - debug_only(Atomic::inc(&_instance_count);) 1.13 + Atomic::inc(&_instance_count); 1.14 debug_only(set_generation();) 1.15 1.16 if (MemTracker::track_callsite()) { 1.17 @@ -83,9 +83,7 @@ 1.18 delete _next; 1.19 } 1.20 1.21 -#ifdef ASSERT 1.22 Atomic::dec(&_instance_count); 1.23 -#endif 1.24 } 1.25 1.26 // Sorting order:
2.1 --- a/src/share/vm/services/memRecorder.hpp Thu Jul 19 16:17:41 2012 -0700 2.2 +++ b/src/share/vm/services/memRecorder.hpp Fri Jul 20 12:09:31 2012 -0400 2.3 @@ -249,9 +249,9 @@ 2.4 2.5 SequencedRecordIterator pointer_itr(); 2.6 2.7 - public: 2.8 + protected: 2.9 // number of MemRecorder instance 2.10 - debug_only(static volatile jint _instance_count;) 2.11 + static volatile jint _instance_count; 2.12 2.13 private: 2.14 // sorting function, sort records into following order
3.1 --- a/src/share/vm/services/memSnapshot.cpp Thu Jul 19 16:17:41 2012 -0700 3.2 +++ b/src/share/vm/services/memSnapshot.cpp Fri Jul 20 12:09:31 2012 -0400 3.3 @@ -173,7 +173,7 @@ 3.4 _staging_area = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecord>(); 3.5 } 3.6 3.7 - _lock = new (std::nothrow) Mutex(Monitor::native, "memSnapshotLock"); 3.8 + _lock = new (std::nothrow) Mutex(Monitor::max_nonleaf - 1, "memSnapshotLock"); 3.9 NOT_PRODUCT(_untracked_count = 0;) 3.10 } 3.11
4.1 --- a/src/share/vm/services/memTrackWorker.hpp Thu Jul 19 16:17:41 2012 -0700 4.2 +++ b/src/share/vm/services/memTrackWorker.hpp Fri Jul 20 12:09:31 2012 -0400 4.3 @@ -67,7 +67,7 @@ 4.4 NOT_PRODUCT(int _last_gen_in_use;) 4.5 4.6 inline int generations_in_use() const { 4.7 - return (_tail <= _head ? (_head - _tail + 1) : (MAX_GENERATIONS - (_tail - _head) + 1)); 4.8 + return (_tail >= _head ? (_tail - _head + 1) : (MAX_GENERATIONS - (_head - _tail) + 1)); 4.9 } 4.10 }; 4.11
5.1 --- a/src/share/vm/services/memTracker.cpp Thu Jul 19 16:17:41 2012 -0700 5.2 +++ b/src/share/vm/services/memTracker.cpp Fri Jul 20 12:09:31 2012 -0400 5.3 @@ -54,7 +54,7 @@ 5.4 MemRecorder* MemTracker::_global_recorder = NULL; 5.5 MemSnapshot* MemTracker::_snapshot = NULL; 5.6 MemBaseline MemTracker::_baseline; 5.7 -Mutex MemTracker::_query_lock(Monitor::native, "NMT_queryLock"); 5.8 +Mutex* MemTracker::_query_lock = NULL; 5.9 volatile MemRecorder* MemTracker::_merge_pending_queue = NULL; 5.10 volatile MemRecorder* MemTracker::_pooled_recorders = NULL; 5.11 MemTrackWorker* MemTracker::_worker_thread = NULL; 5.12 @@ -89,6 +89,12 @@ 5.13 return; 5.14 } 5.15 5.16 + _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock"); 5.17 + if (_query_lock == NULL) { 5.18 + shutdown(NMT_out_of_memory); 5.19 + return; 5.20 + } 5.21 + 5.22 debug_only(_main_thread_tid = os::current_thread_id();) 5.23 _state = NMT_bootstrapping_single_thread; 5.24 NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack()); 5.25 @@ -164,7 +170,7 @@ 5.26 { 5.27 // shared baseline and snapshot are the only objects needed to 5.28 // create query results 5.29 - MutexLockerEx locker(&_query_lock, true); 5.30 + MutexLockerEx locker(_query_lock, true); 5.31 // cleanup baseline data and snapshot 5.32 _baseline.clear(); 5.33 delete _snapshot; 5.34 @@ -351,21 +357,17 @@ 5.35 } 5.36 5.37 if (thread != NULL) { 5.38 -#ifdef ASSERT 5.39 - // cause assertion on stack base. This ensures that threads call 5.40 - // Thread::record_stack_base_and_size() method, which will create 5.41 - // thread native stack records. 5.42 - thread->stack_base(); 5.43 -#endif 5.44 - // for a JavaThread, if it is running in native state, we need to transition it to 5.45 - // VM state, so it can stop at safepoint. JavaThread running in VM state does not 5.46 - // need lock to write records. 5.47 if (thread->is_Java_thread() && ((JavaThread*)thread)->is_safepoint_visible()) { 5.48 - if (((JavaThread*)thread)->thread_state() == _thread_in_native) { 5.49 - ThreadInVMfromNative trans((JavaThread*)thread); 5.50 - create_record_in_recorder(addr, flags, size, pc, thread); 5.51 + JavaThread* java_thread = static_cast<JavaThread*>(thread); 5.52 + JavaThreadState state = java_thread->thread_state(); 5.53 + if (SafepointSynchronize::safepoint_safe(java_thread, state)) { 5.54 + // JavaThreads that are safepoint safe, can run through safepoint, 5.55 + // so ThreadCritical is needed to ensure no threads at safepoint create 5.56 + // new records while the records are being gathered and the sequence number is changing 5.57 + ThreadCritical tc; 5.58 + create_record_in_recorder(addr, flags, size, pc, java_thread); 5.59 } else { 5.60 - create_record_in_recorder(addr, flags, size, pc, thread); 5.61 + create_record_in_recorder(addr, flags, size, pc, java_thread); 5.62 } 5.63 } else { 5.64 // other threads, such as worker and watcher threads, etc. need to 5.65 @@ -390,10 +392,9 @@ 5.66 // write a record to proper recorder. No lock can be taken from this method 5.67 // down. 5.68 void MemTracker::create_record_in_recorder(address addr, MEMFLAGS flags, 5.69 - size_t size, address pc, Thread* thread) { 5.70 - assert(thread == NULL || thread->is_Java_thread(), "wrong thread"); 5.71 + size_t size, address pc, JavaThread* thread) { 5.72 5.73 - MemRecorder* rc = get_thread_recorder((JavaThread*)thread); 5.74 + MemRecorder* rc = get_thread_recorder(thread); 5.75 if (rc != NULL) { 5.76 rc->record(addr, flags, size, pc); 5.77 } 5.78 @@ -460,17 +461,18 @@ 5.79 } 5.80 } 5.81 _sync_point_skip_count = 0; 5.82 - // walk all JavaThreads to collect recorders 5.83 - SyncThreadRecorderClosure stc; 5.84 - Threads::threads_do(&stc); 5.85 - 5.86 - _thread_count = stc.get_thread_count(); 5.87 - MemRecorder* pending_recorders = get_pending_recorders(); 5.88 - 5.89 { 5.90 // This method is running at safepoint, with ThreadCritical lock, 5.91 // it should guarantee that NMT is fully sync-ed. 5.92 ThreadCritical tc; 5.93 + 5.94 + // walk all JavaThreads to collect recorders 5.95 + SyncThreadRecorderClosure stc; 5.96 + Threads::threads_do(&stc); 5.97 + 5.98 + _thread_count = stc.get_thread_count(); 5.99 + MemRecorder* pending_recorders = get_pending_recorders(); 5.100 + 5.101 if (_global_recorder != NULL) { 5.102 _global_recorder->set_next(pending_recorders); 5.103 pending_recorders = _global_recorder; 5.104 @@ -486,8 +488,6 @@ 5.105 5.106 // now, it is the time to shut whole things off 5.107 if (_state == NMT_final_shutdown) { 5.108 - _tracking_level = NMT_off; 5.109 - 5.110 // walk all JavaThreads to delete all recorders 5.111 SyncThreadRecorderClosure stc; 5.112 Threads::threads_do(&stc); 5.113 @@ -499,8 +499,16 @@ 5.114 _global_recorder = NULL; 5.115 } 5.116 } 5.117 - 5.118 - _state = NMT_shutdown; 5.119 + MemRecorder* pending_recorders = get_pending_recorders(); 5.120 + if (pending_recorders != NULL) { 5.121 + delete pending_recorders; 5.122 + } 5.123 + // try at a later sync point to ensure MemRecorder instance drops to zero to 5.124 + // completely shutdown NMT 5.125 + if (MemRecorder::_instance_count == 0) { 5.126 + _state = NMT_shutdown; 5.127 + _tracking_level = NMT_off; 5.128 + } 5.129 } 5.130 } 5.131 5.132 @@ -534,7 +542,7 @@ 5.133 5.134 // baseline current memory snapshot 5.135 bool MemTracker::baseline() { 5.136 - MutexLockerEx lock(&_query_lock, true); 5.137 + MutexLockerEx lock(_query_lock, true); 5.138 MemSnapshot* snapshot = get_snapshot(); 5.139 if (snapshot != NULL) { 5.140 return _baseline.baseline(*snapshot, false); 5.141 @@ -545,7 +553,7 @@ 5.142 // print memory usage from current snapshot 5.143 bool MemTracker::print_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) { 5.144 MemBaseline baseline; 5.145 - MutexLockerEx lock(&_query_lock, true); 5.146 + MutexLockerEx lock(_query_lock, true); 5.147 MemSnapshot* snapshot = get_snapshot(); 5.148 if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) { 5.149 BaselineReporter reporter(out, unit); 5.150 @@ -557,7 +565,7 @@ 5.151 5.152 // compare memory usage between current snapshot and baseline 5.153 bool MemTracker::compare_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) { 5.154 - MutexLockerEx lock(&_query_lock, true); 5.155 + MutexLockerEx lock(_query_lock, true); 5.156 if (_baseline.baselined()) { 5.157 MemBaseline baseline; 5.158 MemSnapshot* snapshot = get_snapshot();
6.1 --- a/src/share/vm/services/memTracker.hpp Thu Jul 19 16:17:41 2012 -0700 6.2 +++ b/src/share/vm/services/memTracker.hpp Fri Jul 20 12:09:31 2012 -0400 6.3 @@ -126,6 +126,8 @@ 6.4 return "Native memory tracking has been shutdown by user"; 6.5 case NMT_normal: 6.6 return "Native memory tracking has been shutdown due to process exiting"; 6.7 + case NMT_out_of_memory: 6.8 + return "Native memory tracking has been shutdown due to out of native memory"; 6.9 case NMT_initialization: 6.10 return "Native memory tracking failed to initialize"; 6.11 case NMT_error_reporting: 6.12 @@ -326,7 +328,7 @@ 6.13 static void create_memory_record(address addr, MEMFLAGS type, 6.14 size_t size, address pc, Thread* thread); 6.15 static void create_record_in_recorder(address addr, MEMFLAGS type, 6.16 - size_t size, address pc, Thread* thread); 6.17 + size_t size, address pc, JavaThread* thread); 6.18 6.19 private: 6.20 // global memory snapshot 6.21 @@ -336,7 +338,7 @@ 6.22 static MemBaseline _baseline; 6.23 6.24 // query lock 6.25 - static Mutex _query_lock; 6.26 + static Mutex* _query_lock; 6.27 6.28 // a thread can start to allocate memory before it is attached 6.29 // to VM 'Thread', those memory activities are recorded here.
7.1 --- a/test/runtime/6294277/SourceDebugExtension.java Thu Jul 19 16:17:41 2012 -0700 7.2 +++ b/test/runtime/6294277/SourceDebugExtension.java Fri Jul 20 12:09:31 2012 -0400 7.3 @@ -25,6 +25,7 @@ 7.4 * @test 7.5 * @bug 6294277 7.6 * @summary java -Xdebug crashes on SourceDebugExtension attribute larger than 64K 7.7 + * @run main/othervm -Xdebug -Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n SourceDebugExtension 7.8 */ 7.9 import java.io.*; 7.10
8.1 --- a/test/runtime/6294277/Test6294277.sh Thu Jul 19 16:17:41 2012 -0700 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,92 +0,0 @@ 8.4 -# 8.5 -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 8.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 -# 8.8 -# This code is free software; you can redistribute it and/or modify it 8.9 -# under the terms of the GNU General Public License version 2 only, as 8.10 -# published by the Free Software Foundation. 8.11 -# 8.12 -# This code is distributed in the hope that it will be useful, but WITHOUT 8.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 -# version 2 for more details (a copy is included in the LICENSE file that 8.16 -# accompanied this code). 8.17 -# 8.18 -# You should have received a copy of the GNU General Public License version 8.19 -# 2 along with this work; if not, write to the Free Software Foundation, 8.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 -# 8.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 -# or visit www.oracle.com if you need additional information or have any 8.24 -# questions. 8.25 -# 8.26 - 8.27 - 8.28 -# @test Test6294277.sh 8.29 -# @bug 6294277 8.30 -# @summary java -Xdebug crashes on SourceDebugExtension attribute larger than 64K 8.31 -# @run shell Test6294277.sh 8.32 -# 8.33 - 8.34 - 8.35 -if [ "${TESTSRC}" = "" ] 8.36 -then TESTSRC=. 8.37 -fi 8.38 - 8.39 -if [ "${TESTJAVA}" = "" ] 8.40 -then 8.41 - PARENT=`dirname \`which java\`` 8.42 - TESTJAVA=`dirname ${PARENT}` 8.43 - echo "TESTJAVA not set, selecting " ${TESTJAVA} 8.44 - echo "If this is incorrect, try setting the variable manually." 8.45 -fi 8.46 - 8.47 -BIT_FLAG="" 8.48 - 8.49 -# set platform-dependent variables 8.50 -OS=`uname -s` 8.51 -case "$OS" in 8.52 - SunOS | Linux ) 8.53 - NULL=/dev/null 8.54 - PS=":" 8.55 - FS="/" 8.56 - ## for solaris, linux it's HOME 8.57 - FILE_LOCATION=$HOME 8.58 - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" -a `uname -p`='sparc' ] 8.59 - then 8.60 - BIT_FLAG="-d64" 8.61 - fi 8.62 - ;; 8.63 - Windows_* | Darwin ) 8.64 - NULL=NUL 8.65 - PS=";" 8.66 - FS="\\" 8.67 - echo "Test skipped" 8.68 - exit 0 8.69 - ;; 8.70 - * ) 8.71 - echo "Unrecognized system!" 8.72 - exit 1; 8.73 - ;; 8.74 -esac 8.75 - 8.76 -cp ${TESTSRC}${FS}*.java . 8.77 - 8.78 -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -fullversion 8.79 - 8.80 -${TESTJAVA}${FS}bin${FS}javac *.java 8.81 - 8.82 -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -classpath . -Xdebug -Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n SourceDebugExtension > test.out 2>&1 & 8.83 - 8.84 -P_PID=$! 8.85 - 8.86 -sleep 60 8.87 -STATUS=1 8.88 - 8.89 -grep "Test PASSES" test.out > ${NULL} 8.90 -if [ $? = 0 ]; then 8.91 - cat test.out 8.92 - STATUS=0 8.93 -fi 8.94 - 8.95 -exit $STATUS
9.1 --- a/test/runtime/7020373/Test7020373.sh Thu Jul 19 16:17:41 2012 -0700 9.2 +++ b/test/runtime/7020373/Test7020373.sh Fri Jul 20 12:09:31 2012 -0400 9.3 @@ -2,10 +2,9 @@ 9.4 9.5 ## 9.6 ## @test 9.7 -## @bug 7020373 7055247 9.8 +## @bug 7020373 7055247 7053586 9.9 ## @key cte_test 9.10 ## @summary JSR rewriting can overflow memory address size variables 9.11 -## @ignore Ignore it until 7053586 fixed 9.12 ## @run shell Test7020373.sh 9.13 ## 9.14 9.15 @@ -30,7 +29,7 @@ 9.16 # set platform-dependent variables 9.17 OS=`uname -s` 9.18 case "$OS" in 9.19 - SunOS | Linux ) 9.20 + SunOS | Linux | Darwin ) 9.21 NULL=/dev/null 9.22 PS=":" 9.23 FS="/" 9.24 @@ -66,7 +65,7 @@ 9.25 echo "Test Failed" 9.26 exit 1 9.27 else 9.28 - grep "java.lang.LinkageError" test.out 9.29 + egrep "java.lang.LinkageError|java.lang.NoSuchMethodError|Main method not found in class OOMCrashClass4000_1|insufficient memory" test.out 9.30 if [ $? = 0 ] 9.31 then 9.32 echo "Test Passed"