Tue, 24 Sep 2013 10:14:02 +0200
Merge
test/runtime/6878713/Test6878713.sh | file | annotate | diff | comparison | revisions | |
test/runtime/6878713/testcase.jar | file | annotate | diff | comparison | revisions | |
test/runtime/7020373/Test7020373.sh | file | annotate | diff | comparison | revisions | |
test/runtime/7020373/testcase.jar | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Sat Sep 21 10:09:42 2013 +0200 1.2 +++ b/.hgtags Tue Sep 24 10:14:02 2013 +0200 1.3 @@ -377,3 +377,5 @@ 1.4 50794d8ac11c9579b41dec4de23b808fef9f34a1 hs25-b49 1.5 5b7f90aab3ad25a25b75b7b2bb18d5ae23d8231c jdk8-b107 1.6 a09fe9d1e016c285307507a5793bc4fa6215e9c9 hs25-b50 1.7 +85072013aad46050a362d10ab78e963121c8014c jdk8-b108 1.8 +566db1b0e6efca31f181456e54c8911d0192410d hs25-b51
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Sat Sep 21 10:09:42 2013 +0200 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Tue Sep 24 10:14:02 2013 +0200 2.3 @@ -1213,6 +1213,7 @@ 2.4 } 2.5 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase(); 2.6 if (t.countTokens() == 1) { 2.7 + String name = t.nextToken(); 2.8 out.println("intConstant " + name + " " + db.lookupIntConstant(name)); 2.9 } else if (t.countTokens() == 0) { 2.10 Iterator i = db.getIntConstants(); 2.11 @@ -1235,6 +1236,7 @@ 2.12 } 2.13 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase(); 2.14 if (t.countTokens() == 1) { 2.15 + String name = t.nextToken(); 2.16 out.println("longConstant " + name + " " + db.lookupLongConstant(name)); 2.17 } else if (t.countTokens() == 0) { 2.18 Iterator i = db.getLongConstants();
3.1 --- a/make/bsd/makefiles/gcc.make Sat Sep 21 10:09:42 2013 +0200 3.2 +++ b/make/bsd/makefiles/gcc.make Tue Sep 24 10:14:02 2013 +0200 3.3 @@ -80,7 +80,7 @@ 3.4 HOSTCC = $(CC) 3.5 endif 3.6 3.7 - AS = $(CC) -c -x assembler-with-cpp 3.8 + AS = $(CC) -c 3.9 endif 3.10 3.11 3.12 @@ -347,6 +347,13 @@ 3.13 LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) 3.14 endif 3.15 3.16 + 3.17 +#------------------------------------------------------------------------ 3.18 +# Assembler flags 3.19 + 3.20 +# Enforce prerpocessing of .s files 3.21 +ASFLAGS += -x assembler-with-cpp 3.22 + 3.23 #------------------------------------------------------------------------ 3.24 # Linker flags 3.25
4.1 --- a/make/excludeSrc.make Sat Sep 21 10:09:42 2013 +0200 4.2 +++ b/make/excludeSrc.make Tue Sep 24 10:14:02 2013 +0200 4.3 @@ -99,7 +99,7 @@ 4.4 psTasks.cpp psVirtualspace.cpp psYoungGen.cpp vmPSOperations.cpp asParNewGeneration.cpp \ 4.5 parCardTableModRefBS.cpp parGCAllocBuffer.cpp parNewGeneration.cpp mutableSpace.cpp \ 4.6 gSpaceCounters.cpp allocationStats.cpp spaceCounters.cpp gcAdaptivePolicyCounters.cpp \ 4.7 - mutableNUMASpace.cpp immutableSpace.cpp yieldingWorkGroup.cpp 4.8 + mutableNUMASpace.cpp immutableSpace.cpp yieldingWorkGroup.cpp hSpaceCounters.cpp 4.9 endif 4.10 4.11 ifeq ($(INCLUDE_NMT), false)
5.1 --- a/make/hotspot_version Sat Sep 21 10:09:42 2013 +0200 5.2 +++ b/make/hotspot_version Tue Sep 24 10:14:02 2013 +0200 5.3 @@ -35,7 +35,7 @@ 5.4 5.5 HS_MAJOR_VER=25 5.6 HS_MINOR_VER=0 5.7 -HS_BUILD_NUMBER=51 5.8 +HS_BUILD_NUMBER=52 5.9 5.10 JDK_MAJOR_VER=1 5.11 JDK_MINOR_VER=8
6.1 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Sat Sep 21 10:09:42 2013 +0200 6.2 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Sep 24 10:14:02 2013 +0200 6.3 @@ -1724,14 +1724,6 @@ 6.4 } 6.5 6.6 assert_different_registers(obj, k_RInfo, klass_RInfo); 6.7 - if (!k->is_loaded()) { 6.8 - klass2reg_with_patching(k_RInfo, op->info_for_patch()); 6.9 - } else { 6.10 -#ifdef _LP64 6.11 - __ mov_metadata(k_RInfo, k->constant_encoding()); 6.12 -#endif // _LP64 6.13 - } 6.14 - assert(obj != k_RInfo, "must be different"); 6.15 6.16 __ cmpptr(obj, (int32_t)NULL_WORD); 6.17 if (op->should_profile()) { 6.18 @@ -1748,6 +1740,14 @@ 6.19 } else { 6.20 __ jcc(Assembler::equal, *obj_is_null); 6.21 } 6.22 + 6.23 + if (!k->is_loaded()) { 6.24 + klass2reg_with_patching(k_RInfo, op->info_for_patch()); 6.25 + } else { 6.26 +#ifdef _LP64 6.27 + __ mov_metadata(k_RInfo, k->constant_encoding()); 6.28 +#endif // _LP64 6.29 + } 6.30 __ verify_oop(obj); 6.31 6.32 if (op->fast_check()) {
7.1 --- a/src/cpu/x86/vm/templateInterpreter_x86.hpp Sat Sep 21 10:09:42 2013 +0200 7.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86.hpp Tue Sep 24 10:14:02 2013 +0200 7.3 @@ -34,9 +34,9 @@ 7.4 // Run with +PrintInterpreter to get the VM to print out the size. 7.5 // Max size with JVMTI 7.6 #ifdef AMD64 7.7 - const static int InterpreterCodeSize = 200 * 1024; 7.8 + const static int InterpreterCodeSize = 208 * 1024; 7.9 #else 7.10 - const static int InterpreterCodeSize = 168 * 1024; 7.11 + const static int InterpreterCodeSize = 176 * 1024; 7.12 #endif // AMD64 7.13 7.14 #endif // CPU_X86_VM_TEMPLATEINTERPRETER_X86_HPP
8.1 --- a/src/os/linux/vm/os_linux.cpp Sat Sep 21 10:09:42 2013 +0200 8.2 +++ b/src/os/linux/vm/os_linux.cpp Tue Sep 24 10:14:02 2013 +0200 8.3 @@ -131,6 +131,7 @@ 8.4 bool os::Linux::_supports_fast_thread_cpu_time = false; 8.5 const char * os::Linux::_glibc_version = NULL; 8.6 const char * os::Linux::_libpthread_version = NULL; 8.7 +pthread_condattr_t os::Linux::_condattr[1]; 8.8 8.9 static jlong initial_time_count=0; 8.10 8.11 @@ -1399,12 +1400,15 @@ 8.12 clock_gettime_func(CLOCK_MONOTONIC, &tp) == 0) { 8.13 // yes, monotonic clock is supported 8.14 _clock_gettime = clock_gettime_func; 8.15 + return; 8.16 } else { 8.17 // close librt if there is no monotonic clock 8.18 dlclose(handle); 8.19 } 8.20 } 8.21 } 8.22 + warning("No monotonic clock was available - timed services may " \ 8.23 + "be adversely affected if the time-of-day clock changes"); 8.24 } 8.25 8.26 #ifndef SYS_clock_getres 8.27 @@ -2165,23 +2169,49 @@ 8.28 } 8.29 8.30 // Try to identify popular distros. 8.31 -// Most Linux distributions have /etc/XXX-release file, which contains 8.32 -// the OS version string. Some have more than one /etc/XXX-release file 8.33 -// (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.), 8.34 -// so the order is important. 8.35 +// Most Linux distributions have a /etc/XXX-release file, which contains 8.36 +// the OS version string. Newer Linux distributions have a /etc/lsb-release 8.37 +// file that also contains the OS version string. Some have more than one 8.38 +// /etc/XXX-release file (e.g. Mandrake has both /etc/mandrake-release and 8.39 +// /etc/redhat-release.), so the order is important. 8.40 +// Any Linux that is based on Redhat (i.e. Oracle, Mandrake, Sun JDS...) have 8.41 +// their own specific XXX-release file as well as a redhat-release file. 8.42 +// Because of this the XXX-release file needs to be searched for before the 8.43 +// redhat-release file. 8.44 +// Since Red Hat has a lsb-release file that is not very descriptive the 8.45 +// search for redhat-release needs to be before lsb-release. 8.46 +// Since the lsb-release file is the new standard it needs to be searched 8.47 +// before the older style release files. 8.48 +// Searching system-release (Red Hat) and os-release (other Linuxes) are a 8.49 +// next to last resort. The os-release file is a new standard that contains 8.50 +// distribution information and the system-release file seems to be an old 8.51 +// standard that has been replaced by the lsb-release and os-release files. 8.52 +// Searching for the debian_version file is the last resort. It contains 8.53 +// an informative string like "6.0.6" or "wheezy/sid". Because of this 8.54 +// "Debian " is printed before the contents of the debian_version file. 8.55 void os::Linux::print_distro_info(outputStream* st) { 8.56 - if (!_print_ascii_file("/etc/mandrake-release", st) && 8.57 - !_print_ascii_file("/etc/sun-release", st) && 8.58 - !_print_ascii_file("/etc/redhat-release", st) && 8.59 - !_print_ascii_file("/etc/SuSE-release", st) && 8.60 - !_print_ascii_file("/etc/turbolinux-release", st) && 8.61 - !_print_ascii_file("/etc/gentoo-release", st) && 8.62 - !_print_ascii_file("/etc/debian_version", st) && 8.63 - !_print_ascii_file("/etc/ltib-release", st) && 8.64 - !_print_ascii_file("/etc/angstrom-version", st)) { 8.65 - st->print("Linux"); 8.66 - } 8.67 - st->cr(); 8.68 + if (!_print_ascii_file("/etc/oracle-release", st) && 8.69 + !_print_ascii_file("/etc/mandriva-release", st) && 8.70 + !_print_ascii_file("/etc/mandrake-release", st) && 8.71 + !_print_ascii_file("/etc/sun-release", st) && 8.72 + !_print_ascii_file("/etc/redhat-release", st) && 8.73 + !_print_ascii_file("/etc/lsb-release", st) && 8.74 + !_print_ascii_file("/etc/SuSE-release", st) && 8.75 + !_print_ascii_file("/etc/turbolinux-release", st) && 8.76 + !_print_ascii_file("/etc/gentoo-release", st) && 8.77 + !_print_ascii_file("/etc/ltib-release", st) && 8.78 + !_print_ascii_file("/etc/angstrom-version", st) && 8.79 + !_print_ascii_file("/etc/system-release", st) && 8.80 + !_print_ascii_file("/etc/os-release", st)) { 8.81 + 8.82 + if (file_exists("/etc/debian_version")) { 8.83 + st->print("Debian "); 8.84 + _print_ascii_file("/etc/debian_version", st); 8.85 + } else { 8.86 + st->print("Linux"); 8.87 + } 8.88 + } 8.89 + st->cr(); 8.90 } 8.91 8.92 void os::Linux::print_libversion_info(outputStream* st) { 8.93 @@ -4709,6 +4739,26 @@ 8.94 8.95 Linux::clock_init(); 8.96 initial_time_count = os::elapsed_counter(); 8.97 + 8.98 + // pthread_condattr initialization for monotonic clock 8.99 + int status; 8.100 + pthread_condattr_t* _condattr = os::Linux::condAttr(); 8.101 + if ((status = pthread_condattr_init(_condattr)) != 0) { 8.102 + fatal(err_msg("pthread_condattr_init: %s", strerror(status))); 8.103 + } 8.104 + // Only set the clock if CLOCK_MONOTONIC is available 8.105 + if (Linux::supports_monotonic_clock()) { 8.106 + if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) { 8.107 + if (status == EINVAL) { 8.108 + warning("Unable to use monotonic clock with relative timed-waits" \ 8.109 + " - changes to the time-of-day clock may have adverse affects"); 8.110 + } else { 8.111 + fatal(err_msg("pthread_condattr_setclock: %s", strerror(status))); 8.112 + } 8.113 + } 8.114 + } 8.115 + // else it defaults to CLOCK_REALTIME 8.116 + 8.117 pthread_mutex_init(&dl_mutex, NULL); 8.118 8.119 // If the pagesize of the VM is greater than 8K determine the appropriate 8.120 @@ -5517,21 +5567,36 @@ 8.121 8.122 static struct timespec* compute_abstime(timespec* abstime, jlong millis) { 8.123 if (millis < 0) millis = 0; 8.124 - struct timeval now; 8.125 - int status = gettimeofday(&now, NULL); 8.126 - assert(status == 0, "gettimeofday"); 8.127 + 8.128 jlong seconds = millis / 1000; 8.129 millis %= 1000; 8.130 if (seconds > 50000000) { // see man cond_timedwait(3T) 8.131 seconds = 50000000; 8.132 } 8.133 - abstime->tv_sec = now.tv_sec + seconds; 8.134 - long usec = now.tv_usec + millis * 1000; 8.135 - if (usec >= 1000000) { 8.136 - abstime->tv_sec += 1; 8.137 - usec -= 1000000; 8.138 - } 8.139 - abstime->tv_nsec = usec * 1000; 8.140 + 8.141 + if (os::Linux::supports_monotonic_clock()) { 8.142 + struct timespec now; 8.143 + int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now); 8.144 + assert_status(status == 0, status, "clock_gettime"); 8.145 + abstime->tv_sec = now.tv_sec + seconds; 8.146 + long nanos = now.tv_nsec + millis * NANOSECS_PER_MILLISEC; 8.147 + if (nanos >= NANOSECS_PER_SEC) { 8.148 + abstime->tv_sec += 1; 8.149 + nanos -= NANOSECS_PER_SEC; 8.150 + } 8.151 + abstime->tv_nsec = nanos; 8.152 + } else { 8.153 + struct timeval now; 8.154 + int status = gettimeofday(&now, NULL); 8.155 + assert(status == 0, "gettimeofday"); 8.156 + abstime->tv_sec = now.tv_sec + seconds; 8.157 + long usec = now.tv_usec + millis * 1000; 8.158 + if (usec >= 1000000) { 8.159 + abstime->tv_sec += 1; 8.160 + usec -= 1000000; 8.161 + } 8.162 + abstime->tv_nsec = usec * 1000; 8.163 + } 8.164 return abstime; 8.165 } 8.166 8.167 @@ -5623,7 +5688,7 @@ 8.168 status = os::Linux::safe_cond_timedwait(_cond, _mutex, &abst); 8.169 if (status != 0 && WorkAroundNPTLTimedWaitHang) { 8.170 pthread_cond_destroy (_cond); 8.171 - pthread_cond_init (_cond, NULL) ; 8.172 + pthread_cond_init (_cond, os::Linux::condAttr()) ; 8.173 } 8.174 assert_status(status == 0 || status == EINTR || 8.175 status == ETIME || status == ETIMEDOUT, 8.176 @@ -5724,32 +5789,50 @@ 8.177 8.178 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { 8.179 assert (time > 0, "convertTime"); 8.180 - 8.181 - struct timeval now; 8.182 - int status = gettimeofday(&now, NULL); 8.183 - assert(status == 0, "gettimeofday"); 8.184 - 8.185 - time_t max_secs = now.tv_sec + MAX_SECS; 8.186 - 8.187 - if (isAbsolute) { 8.188 - jlong secs = time / 1000; 8.189 - if (secs > max_secs) { 8.190 - absTime->tv_sec = max_secs; 8.191 + time_t max_secs = 0; 8.192 + 8.193 + if (!os::Linux::supports_monotonic_clock() || isAbsolute) { 8.194 + struct timeval now; 8.195 + int status = gettimeofday(&now, NULL); 8.196 + assert(status == 0, "gettimeofday"); 8.197 + 8.198 + max_secs = now.tv_sec + MAX_SECS; 8.199 + 8.200 + if (isAbsolute) { 8.201 + jlong secs = time / 1000; 8.202 + if (secs > max_secs) { 8.203 + absTime->tv_sec = max_secs; 8.204 + } else { 8.205 + absTime->tv_sec = secs; 8.206 + } 8.207 + absTime->tv_nsec = (time % 1000) * NANOSECS_PER_MILLISEC; 8.208 + } else { 8.209 + jlong secs = time / NANOSECS_PER_SEC; 8.210 + if (secs >= MAX_SECS) { 8.211 + absTime->tv_sec = max_secs; 8.212 + absTime->tv_nsec = 0; 8.213 + } else { 8.214 + absTime->tv_sec = now.tv_sec + secs; 8.215 + absTime->tv_nsec = (time % NANOSECS_PER_SEC) + now.tv_usec*1000; 8.216 + if (absTime->tv_nsec >= NANOSECS_PER_SEC) { 8.217 + absTime->tv_nsec -= NANOSECS_PER_SEC; 8.218 + ++absTime->tv_sec; // note: this must be <= max_secs 8.219 + } 8.220 + } 8.221 } 8.222 - else { 8.223 - absTime->tv_sec = secs; 8.224 - } 8.225 - absTime->tv_nsec = (time % 1000) * NANOSECS_PER_MILLISEC; 8.226 - } 8.227 - else { 8.228 + } else { 8.229 + // must be relative using monotonic clock 8.230 + struct timespec now; 8.231 + int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now); 8.232 + assert_status(status == 0, status, "clock_gettime"); 8.233 + max_secs = now.tv_sec + MAX_SECS; 8.234 jlong secs = time / NANOSECS_PER_SEC; 8.235 if (secs >= MAX_SECS) { 8.236 absTime->tv_sec = max_secs; 8.237 absTime->tv_nsec = 0; 8.238 - } 8.239 - else { 8.240 + } else { 8.241 absTime->tv_sec = now.tv_sec + secs; 8.242 - absTime->tv_nsec = (time % NANOSECS_PER_SEC) + now.tv_usec*1000; 8.243 + absTime->tv_nsec = (time % NANOSECS_PER_SEC) + now.tv_nsec; 8.244 if (absTime->tv_nsec >= NANOSECS_PER_SEC) { 8.245 absTime->tv_nsec -= NANOSECS_PER_SEC; 8.246 ++absTime->tv_sec; // note: this must be <= max_secs 8.247 @@ -5829,15 +5912,19 @@ 8.248 jt->set_suspend_equivalent(); 8.249 // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() 8.250 8.251 + assert(_cur_index == -1, "invariant"); 8.252 if (time == 0) { 8.253 - status = pthread_cond_wait (_cond, _mutex) ; 8.254 + _cur_index = REL_INDEX; // arbitrary choice when not timed 8.255 + status = pthread_cond_wait (&_cond[_cur_index], _mutex) ; 8.256 } else { 8.257 - status = os::Linux::safe_cond_timedwait (_cond, _mutex, &absTime) ; 8.258 + _cur_index = isAbsolute ? ABS_INDEX : REL_INDEX; 8.259 + status = os::Linux::safe_cond_timedwait (&_cond[_cur_index], _mutex, &absTime) ; 8.260 if (status != 0 && WorkAroundNPTLTimedWaitHang) { 8.261 - pthread_cond_destroy (_cond) ; 8.262 - pthread_cond_init (_cond, NULL); 8.263 + pthread_cond_destroy (&_cond[_cur_index]) ; 8.264 + pthread_cond_init (&_cond[_cur_index], isAbsolute ? NULL : os::Linux::condAttr()); 8.265 } 8.266 } 8.267 + _cur_index = -1; 8.268 assert_status(status == 0 || status == EINTR || 8.269 status == ETIME || status == ETIMEDOUT, 8.270 status, "cond_timedwait"); 8.271 @@ -5866,17 +5953,24 @@ 8.272 s = _counter; 8.273 _counter = 1; 8.274 if (s < 1) { 8.275 - if (WorkAroundNPTLTimedWaitHang) { 8.276 - status = pthread_cond_signal (_cond) ; 8.277 - assert (status == 0, "invariant") ; 8.278 + // thread might be parked 8.279 + if (_cur_index != -1) { 8.280 + // thread is definitely parked 8.281 + if (WorkAroundNPTLTimedWaitHang) { 8.282 + status = pthread_cond_signal (&_cond[_cur_index]); 8.283 + assert (status == 0, "invariant"); 8.284 status = pthread_mutex_unlock(_mutex); 8.285 - assert (status == 0, "invariant") ; 8.286 - } else { 8.287 + assert (status == 0, "invariant"); 8.288 + } else { 8.289 status = pthread_mutex_unlock(_mutex); 8.290 - assert (status == 0, "invariant") ; 8.291 - status = pthread_cond_signal (_cond) ; 8.292 - assert (status == 0, "invariant") ; 8.293 - } 8.294 + assert (status == 0, "invariant"); 8.295 + status = pthread_cond_signal (&_cond[_cur_index]); 8.296 + assert (status == 0, "invariant"); 8.297 + } 8.298 + } else { 8.299 + pthread_mutex_unlock(_mutex); 8.300 + assert (status == 0, "invariant") ; 8.301 + } 8.302 } else { 8.303 pthread_mutex_unlock(_mutex); 8.304 assert (status == 0, "invariant") ;
9.1 --- a/src/os/linux/vm/os_linux.hpp Sat Sep 21 10:09:42 2013 +0200 9.2 +++ b/src/os/linux/vm/os_linux.hpp Tue Sep 24 10:14:02 2013 +0200 9.3 @@ -221,6 +221,13 @@ 9.4 9.5 static jlong fast_thread_cpu_time(clockid_t clockid); 9.6 9.7 + // pthread_cond clock suppport 9.8 + private: 9.9 + static pthread_condattr_t _condattr[1]; 9.10 + 9.11 + public: 9.12 + static pthread_condattr_t* condAttr() { return _condattr; } 9.13 + 9.14 // Stack repair handling 9.15 9.16 // none present 9.17 @@ -295,7 +302,7 @@ 9.18 public: 9.19 PlatformEvent() { 9.20 int status; 9.21 - status = pthread_cond_init (_cond, NULL); 9.22 + status = pthread_cond_init (_cond, os::Linux::condAttr()); 9.23 assert_status(status == 0, status, "cond_init"); 9.24 status = pthread_mutex_init (_mutex, NULL); 9.25 assert_status(status == 0, status, "mutex_init"); 9.26 @@ -310,14 +317,19 @@ 9.27 void park () ; 9.28 void unpark () ; 9.29 int TryPark () ; 9.30 - int park (jlong millis) ; 9.31 + int park (jlong millis) ; // relative timed-wait only 9.32 void SetAssociation (Thread * a) { _Assoc = a ; } 9.33 } ; 9.34 9.35 class PlatformParker : public CHeapObj<mtInternal> { 9.36 protected: 9.37 + enum { 9.38 + REL_INDEX = 0, 9.39 + ABS_INDEX = 1 9.40 + }; 9.41 + int _cur_index; // which cond is in use: -1, 0, 1 9.42 pthread_mutex_t _mutex [1] ; 9.43 - pthread_cond_t _cond [1] ; 9.44 + pthread_cond_t _cond [2] ; // one for relative times and one for abs. 9.45 9.46 public: // TODO-FIXME: make dtor private 9.47 ~PlatformParker() { guarantee (0, "invariant") ; } 9.48 @@ -325,10 +337,13 @@ 9.49 public: 9.50 PlatformParker() { 9.51 int status; 9.52 - status = pthread_cond_init (_cond, NULL); 9.53 - assert_status(status == 0, status, "cond_init"); 9.54 + status = pthread_cond_init (&_cond[REL_INDEX], os::Linux::condAttr()); 9.55 + assert_status(status == 0, status, "cond_init rel"); 9.56 + status = pthread_cond_init (&_cond[ABS_INDEX], NULL); 9.57 + assert_status(status == 0, status, "cond_init abs"); 9.58 status = pthread_mutex_init (_mutex, NULL); 9.59 assert_status(status == 0, status, "mutex_init"); 9.60 + _cur_index = -1; // mark as unused 9.61 } 9.62 }; 9.63
10.1 --- a/src/os/windows/vm/decoder_windows.cpp Sat Sep 21 10:09:42 2013 +0200 10.2 +++ b/src/os/windows/vm/decoder_windows.cpp Tue Sep 24 10:14:02 2013 +0200 10.3 @@ -32,7 +32,11 @@ 10.4 _can_decode_in_vm = false; 10.5 _pfnSymGetSymFromAddr64 = NULL; 10.6 _pfnUndecorateSymbolName = NULL; 10.7 - 10.8 +#ifdef AMD64 10.9 + _pfnStackWalk64 = NULL; 10.10 + _pfnSymFunctionTableAccess64 = NULL; 10.11 + _pfnSymGetModuleBase64 = NULL; 10.12 +#endif 10.13 _decoder_status = no_error; 10.14 initialize(); 10.15 } 10.16 @@ -53,14 +57,24 @@ 10.17 _pfnUndecorateSymbolName = (pfn_UndecorateSymbolName)::GetProcAddress(handle, "UnDecorateSymbolName"); 10.18 10.19 if (_pfnSymSetOptions == NULL || _pfnSymInitialize == NULL || _pfnSymGetSymFromAddr64 == NULL) { 10.20 - _pfnSymGetSymFromAddr64 = NULL; 10.21 - _pfnUndecorateSymbolName = NULL; 10.22 - ::FreeLibrary(handle); 10.23 - _dbghelp_handle = NULL; 10.24 + uninitialize(); 10.25 _decoder_status = helper_func_error; 10.26 return; 10.27 } 10.28 10.29 +#ifdef AMD64 10.30 + _pfnStackWalk64 = (pfn_StackWalk64)::GetProcAddress(handle, "StackWalk64"); 10.31 + _pfnSymFunctionTableAccess64 = (pfn_SymFunctionTableAccess64)::GetProcAddress(handle, "SymFunctionTableAccess64"); 10.32 + _pfnSymGetModuleBase64 = (pfn_SymGetModuleBase64)::GetProcAddress(handle, "SymGetModuleBase64"); 10.33 + if (_pfnStackWalk64 == NULL || _pfnSymFunctionTableAccess64 == NULL || _pfnSymGetModuleBase64 == NULL) { 10.34 + // We can't call StackWalk64 to walk the stack, but we are still 10.35 + // able to decode the symbols. Let's limp on. 10.36 + _pfnStackWalk64 = NULL; 10.37 + _pfnSymFunctionTableAccess64 = NULL; 10.38 + _pfnSymGetModuleBase64 = NULL; 10.39 + } 10.40 +#endif 10.41 + 10.42 HANDLE hProcess = ::GetCurrentProcess(); 10.43 _pfnSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_EXACT_SYMBOLS); 10.44 if (!_pfnSymInitialize(hProcess, NULL, TRUE)) { 10.45 @@ -156,6 +170,11 @@ 10.46 void WindowsDecoder::uninitialize() { 10.47 _pfnSymGetSymFromAddr64 = NULL; 10.48 _pfnUndecorateSymbolName = NULL; 10.49 +#ifdef AMD64 10.50 + _pfnStackWalk64 = NULL; 10.51 + _pfnSymFunctionTableAccess64 = NULL; 10.52 + _pfnSymGetModuleBase64 = NULL; 10.53 +#endif 10.54 if (_dbghelp_handle != NULL) { 10.55 ::FreeLibrary(_dbghelp_handle); 10.56 } 10.57 @@ -195,3 +214,65 @@ 10.58 _pfnUndecorateSymbolName(symbol, buf, buflen, UNDNAME_COMPLETE); 10.59 } 10.60 10.61 +#ifdef AMD64 10.62 +BOOL WindowsDbgHelp::StackWalk64(DWORD MachineType, 10.63 + HANDLE hProcess, 10.64 + HANDLE hThread, 10.65 + LPSTACKFRAME64 StackFrame, 10.66 + PVOID ContextRecord, 10.67 + PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, 10.68 + PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, 10.69 + PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, 10.70 + PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress) { 10.71 + DecoderLocker locker; 10.72 + WindowsDecoder* wd = (WindowsDecoder*)locker.decoder(); 10.73 + 10.74 + if (!wd->has_error() && wd->_pfnStackWalk64) { 10.75 + return wd->_pfnStackWalk64(MachineType, 10.76 + hProcess, 10.77 + hThread, 10.78 + StackFrame, 10.79 + ContextRecord, 10.80 + ReadMemoryRoutine, 10.81 + FunctionTableAccessRoutine, 10.82 + GetModuleBaseRoutine, 10.83 + TranslateAddress); 10.84 + } else { 10.85 + return false; 10.86 + } 10.87 +} 10.88 + 10.89 +PVOID WindowsDbgHelp::SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase) { 10.90 + DecoderLocker locker; 10.91 + WindowsDecoder* wd = (WindowsDecoder*)locker.decoder(); 10.92 + 10.93 + if (!wd->has_error() && wd->_pfnSymFunctionTableAccess64) { 10.94 + return wd->_pfnSymFunctionTableAccess64(hProcess, AddrBase); 10.95 + } else { 10.96 + return NULL; 10.97 + } 10.98 +} 10.99 + 10.100 +pfn_SymFunctionTableAccess64 WindowsDbgHelp::pfnSymFunctionTableAccess64() { 10.101 + DecoderLocker locker; 10.102 + WindowsDecoder* wd = (WindowsDecoder*)locker.decoder(); 10.103 + 10.104 + if (!wd->has_error()) { 10.105 + return wd->_pfnSymFunctionTableAccess64; 10.106 + } else { 10.107 + return NULL; 10.108 + } 10.109 +} 10.110 + 10.111 +pfn_SymGetModuleBase64 WindowsDbgHelp::pfnSymGetModuleBase64() { 10.112 + DecoderLocker locker; 10.113 + WindowsDecoder* wd = (WindowsDecoder*)locker.decoder(); 10.114 + 10.115 + if (!wd->has_error()) { 10.116 + return wd->_pfnSymGetModuleBase64; 10.117 + } else { 10.118 + return NULL; 10.119 + } 10.120 +} 10.121 + 10.122 +#endif // AMD64
11.1 --- a/src/os/windows/vm/decoder_windows.hpp Sat Sep 21 10:09:42 2013 +0200 11.2 +++ b/src/os/windows/vm/decoder_windows.hpp Tue Sep 24 10:14:02 2013 +0200 11.3 @@ -38,6 +38,20 @@ 11.4 typedef BOOL (WINAPI *pfn_SymSetSearchPath)(HANDLE, PCTSTR); 11.5 typedef BOOL (WINAPI *pfn_SymGetSearchPath)(HANDLE, PTSTR, int); 11.6 11.7 +#ifdef AMD64 11.8 +typedef BOOL (WINAPI *pfn_StackWalk64)(DWORD MachineType, 11.9 + HANDLE hProcess, 11.10 + HANDLE hThread, 11.11 + LPSTACKFRAME64 StackFrame, 11.12 + PVOID ContextRecord, 11.13 + PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, 11.14 + PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, 11.15 + PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, 11.16 + PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); 11.17 +typedef PVOID (WINAPI *pfn_SymFunctionTableAccess64)(HANDLE hProcess, DWORD64 AddrBase); 11.18 +typedef DWORD64 (WINAPI *pfn_SymGetModuleBase64)(HANDLE hProcess, DWORD64 dwAddr); 11.19 +#endif 11.20 + 11.21 class WindowsDecoder : public AbstractDecoder { 11.22 11.23 public: 11.24 @@ -61,7 +75,34 @@ 11.25 bool _can_decode_in_vm; 11.26 pfn_SymGetSymFromAddr64 _pfnSymGetSymFromAddr64; 11.27 pfn_UndecorateSymbolName _pfnUndecorateSymbolName; 11.28 +#ifdef AMD64 11.29 + pfn_StackWalk64 _pfnStackWalk64; 11.30 + pfn_SymFunctionTableAccess64 _pfnSymFunctionTableAccess64; 11.31 + pfn_SymGetModuleBase64 _pfnSymGetModuleBase64; 11.32 + 11.33 + friend class WindowsDbgHelp; 11.34 +#endif 11.35 }; 11.36 11.37 +#ifdef AMD64 11.38 +// TODO: refactor and move the handling of dbghelp.dll outside of Decoder 11.39 +class WindowsDbgHelp : public Decoder { 11.40 +public: 11.41 + static BOOL StackWalk64(DWORD MachineType, 11.42 + HANDLE hProcess, 11.43 + HANDLE hThread, 11.44 + LPSTACKFRAME64 StackFrame, 11.45 + PVOID ContextRecord, 11.46 + PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, 11.47 + PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, 11.48 + PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, 11.49 + PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); 11.50 + static PVOID SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase); 11.51 + 11.52 + static pfn_SymFunctionTableAccess64 pfnSymFunctionTableAccess64(); 11.53 + static pfn_SymGetModuleBase64 pfnSymGetModuleBase64(); 11.54 +}; 11.55 +#endif 11.56 + 11.57 #endif // OS_WINDOWS_VM_DECODER_WINDOWS_HPP 11.58
12.1 --- a/src/os/windows/vm/os_windows.cpp Sat Sep 21 10:09:42 2013 +0200 12.2 +++ b/src/os/windows/vm/os_windows.cpp Tue Sep 24 10:14:02 2013 +0200 12.3 @@ -5430,7 +5430,7 @@ 12.4 if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { 12.5 lib_name = ++start; 12.6 } else { 12.7 - // Need to check for C: 12.8 + // Need to check for drive prefix 12.9 if ((start = strchr(lib_name, ':')) != NULL) { 12.10 lib_name = ++start; 12.11 }
13.1 --- a/src/os_cpu/windows_x86/vm/os_windows_x86.cpp Sat Sep 21 10:09:42 2013 +0200 13.2 +++ b/src/os_cpu/windows_x86/vm/os_windows_x86.cpp Tue Sep 24 10:14:02 2013 +0200 13.3 @@ -29,6 +29,7 @@ 13.4 #include "classfile/vmSymbols.hpp" 13.5 #include "code/icBuffer.hpp" 13.6 #include "code/vtableStubs.hpp" 13.7 +#include "decoder_windows.hpp" 13.8 #include "interpreter/interpreter.hpp" 13.9 #include "jvm_windows.h" 13.10 #include "memory/allocation.inline.hpp" 13.11 @@ -327,6 +328,94 @@ 13.12 13.13 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; 13.14 13.15 +#ifdef AMD64 13.16 +/* 13.17 + * Windows/x64 does not use stack frames the way expected by Java: 13.18 + * [1] in most cases, there is no frame pointer. All locals are addressed via RSP 13.19 + * [2] in rare cases, when alloca() is used, a frame pointer is used, but this may 13.20 + * not be RBP. 13.21 + * See http://msdn.microsoft.com/en-us/library/ew5tede7.aspx 13.22 + * 13.23 + * So it's not possible to print the native stack using the 13.24 + * while (...) {... fr = os::get_sender_for_C_frame(&fr); } 13.25 + * loop in vmError.cpp. We need to roll our own loop. 13.26 + */ 13.27 +bool os::platform_print_native_stack(outputStream* st, void* context, 13.28 + char *buf, int buf_size) 13.29 +{ 13.30 + CONTEXT ctx; 13.31 + if (context != NULL) { 13.32 + memcpy(&ctx, context, sizeof(ctx)); 13.33 + } else { 13.34 + RtlCaptureContext(&ctx); 13.35 + } 13.36 + 13.37 + st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)"); 13.38 + 13.39 + STACKFRAME stk; 13.40 + memset(&stk, 0, sizeof(stk)); 13.41 + stk.AddrStack.Offset = ctx.Rsp; 13.42 + stk.AddrStack.Mode = AddrModeFlat; 13.43 + stk.AddrFrame.Offset = ctx.Rbp; 13.44 + stk.AddrFrame.Mode = AddrModeFlat; 13.45 + stk.AddrPC.Offset = ctx.Rip; 13.46 + stk.AddrPC.Mode = AddrModeFlat; 13.47 + 13.48 + int count = 0; 13.49 + address lastpc = 0; 13.50 + while (count++ < StackPrintLimit) { 13.51 + intptr_t* sp = (intptr_t*)stk.AddrStack.Offset; 13.52 + intptr_t* fp = (intptr_t*)stk.AddrFrame.Offset; // NOT necessarily the same as ctx.Rbp! 13.53 + address pc = (address)stk.AddrPC.Offset; 13.54 + 13.55 + if (pc != NULL && sp != NULL && fp != NULL) { 13.56 + if (count == 2 && lastpc == pc) { 13.57 + // Skip it -- StackWalk64() may return the same PC 13.58 + // (but different SP) on the first try. 13.59 + } else { 13.60 + // Don't try to create a frame(sp, fp, pc) -- on WinX64, stk.AddrFrame 13.61 + // may not contain what Java expects, and may cause the frame() constructor 13.62 + // to crash. Let's just print out the symbolic address. 13.63 + frame::print_C_frame(st, buf, buf_size, pc); 13.64 + st->cr(); 13.65 + } 13.66 + lastpc = pc; 13.67 + } else { 13.68 + break; 13.69 + } 13.70 + 13.71 + PVOID p = WindowsDbgHelp::SymFunctionTableAccess64(GetCurrentProcess(), stk.AddrPC.Offset); 13.72 + if (!p) { 13.73 + // StackWalk64() can't handle this PC. Calling StackWalk64 again may cause crash. 13.74 + break; 13.75 + } 13.76 + 13.77 + BOOL result = WindowsDbgHelp::StackWalk64( 13.78 + IMAGE_FILE_MACHINE_AMD64, // __in DWORD MachineType, 13.79 + GetCurrentProcess(), // __in HANDLE hProcess, 13.80 + GetCurrentThread(), // __in HANDLE hThread, 13.81 + &stk, // __inout LP STACKFRAME64 StackFrame, 13.82 + &ctx, // __inout PVOID ContextRecord, 13.83 + NULL, // __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, 13.84 + WindowsDbgHelp::pfnSymFunctionTableAccess64(), 13.85 + // __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, 13.86 + WindowsDbgHelp::pfnSymGetModuleBase64(), 13.87 + // __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, 13.88 + NULL); // __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress 13.89 + 13.90 + if (!result) { 13.91 + break; 13.92 + } 13.93 + } 13.94 + if (count > StackPrintLimit) { 13.95 + st->print_cr("...<more frames>..."); 13.96 + } 13.97 + st->cr(); 13.98 + 13.99 + return true; 13.100 +} 13.101 +#endif // AMD64 13.102 + 13.103 ExtendedPC os::fetch_frame_from_context(void* ucVoid, 13.104 intptr_t** ret_sp, intptr_t** ret_fp) { 13.105 13.106 @@ -401,6 +490,9 @@ 13.107 StubRoutines::x86::get_previous_fp_entry()); 13.108 if (func == NULL) return frame(); 13.109 intptr_t* fp = (*func)(); 13.110 + if (fp == NULL) { 13.111 + return frame(); 13.112 + } 13.113 #else 13.114 intptr_t* fp = _get_previous_fp(); 13.115 #endif // AMD64
14.1 --- a/src/os_cpu/windows_x86/vm/os_windows_x86.hpp Sat Sep 21 10:09:42 2013 +0200 14.2 +++ b/src/os_cpu/windows_x86/vm/os_windows_x86.hpp Tue Sep 24 10:14:02 2013 +0200 14.3 @@ -62,4 +62,10 @@ 14.4 14.5 static bool register_code_area(char *low, char *high); 14.6 14.7 +#ifdef AMD64 14.8 +#define PLATFORM_PRINT_NATIVE_STACK 1 14.9 +static bool platform_print_native_stack(outputStream* st, void* context, 14.10 + char *buf, int buf_size); 14.11 +#endif 14.12 + 14.13 #endif // OS_CPU_WINDOWS_X86_VM_OS_WINDOWS_X86_HPP
15.1 --- a/src/share/tools/LogCompilation/README Sat Sep 21 10:09:42 2013 +0200 15.2 +++ b/src/share/tools/LogCompilation/README Tue Sep 24 10:14:02 2013 +0200 15.3 @@ -4,14 +4,14 @@ 15.4 requires a 1.5 JDK to build and simply typing make should build it. 15.5 15.6 It produces a jar file, logc.jar, that can be run on the 15.7 -hotspot.log from LogCompilation output like this: 15.8 +HotSpot log (by default, hotspot_pid{pid}.log) from LogCompilation output like this: 15.9 15.10 - java -jar logc.jar hotspot.log 15.11 + java -jar logc.jar hotspot_pid1234.log 15.12 15.13 This will produce something like the normal PrintCompilation output. 15.14 Adding the -i option with also report inlining like PrintInlining. 15.15 15.16 -More information about the LogCompilation output can be found at 15.17 +More information about the LogCompilation output can be found at 15.18 15.19 https://wikis.oracle.com/display/HotSpotInternals/LogCompilation+overview 15.20 https://wikis.oracle.com/display/HotSpotInternals/PrintCompilation
16.1 --- a/src/share/vm/c1/c1_Runtime1.cpp Sat Sep 21 10:09:42 2013 +0200 16.2 +++ b/src/share/vm/c1/c1_Runtime1.cpp Tue Sep 24 10:14:02 2013 +0200 16.3 @@ -709,10 +709,10 @@ 16.4 Bytecodes::Code code = field_access.code(); 16.5 16.6 // We must load class, initialize class and resolvethe field 16.7 - FieldAccessInfo result; // initialize class if needed 16.8 + fieldDescriptor result; // initialize class if needed 16.9 constantPoolHandle constants(THREAD, caller->constants()); 16.10 - LinkResolver::resolve_field(result, constants, field_access.index(), Bytecodes::java_code(code), false, CHECK_NULL); 16.11 - return result.klass()(); 16.12 + LinkResolver::resolve_field_access(result, constants, field_access.index(), Bytecodes::java_code(code), CHECK_NULL); 16.13 + return result.field_holder(); 16.14 } 16.15 16.16 16.17 @@ -826,11 +826,11 @@ 16.18 if (stub_id == Runtime1::access_field_patching_id) { 16.19 16.20 Bytecode_field field_access(caller_method, bci); 16.21 - FieldAccessInfo result; // initialize class if needed 16.22 + fieldDescriptor result; // initialize class if needed 16.23 Bytecodes::Code code = field_access.code(); 16.24 constantPoolHandle constants(THREAD, caller_method->constants()); 16.25 - LinkResolver::resolve_field(result, constants, field_access.index(), Bytecodes::java_code(code), false, CHECK); 16.26 - patch_field_offset = result.field_offset(); 16.27 + LinkResolver::resolve_field_access(result, constants, field_access.index(), Bytecodes::java_code(code), CHECK); 16.28 + patch_field_offset = result.offset(); 16.29 16.30 // If we're patching a field which is volatile then at compile it 16.31 // must not have been know to be volatile, so the generated code
17.1 --- a/src/share/vm/ci/ciField.cpp Sat Sep 21 10:09:42 2013 +0200 17.2 +++ b/src/share/vm/ci/ciField.cpp Tue Sep 24 10:14:02 2013 +0200 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 17.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -75,7 +75,6 @@ 17.11 17.12 assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool"); 17.13 17.14 - _cp_index = index; 17.15 constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants()); 17.16 17.17 // Get the field's name, signature, and type. 17.18 @@ -116,7 +115,7 @@ 17.19 // The declared holder of this field may not have been loaded. 17.20 // Bail out with partial field information. 17.21 if (!holder_is_accessible) { 17.22 - // _cp_index and _type have already been set. 17.23 + // _type has already been set. 17.24 // The default values for _flags and _constant_value will suffice. 17.25 // We need values for _holder, _offset, and _is_constant, 17.26 _holder = declared_holder; 17.27 @@ -146,8 +145,6 @@ 17.28 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { 17.29 ASSERT_IN_VM; 17.30 17.31 - _cp_index = -1; 17.32 - 17.33 // Get the field's name, signature, and type. 17.34 ciEnv* env = CURRENT_ENV; 17.35 _name = env->get_symbol(fd->name()); 17.36 @@ -351,12 +348,11 @@ 17.37 } 17.38 } 17.39 17.40 - FieldAccessInfo result; 17.41 - constantPoolHandle c_pool(THREAD, 17.42 - accessing_klass->get_instanceKlass()->constants()); 17.43 - LinkResolver::resolve_field(result, c_pool, _cp_index, 17.44 - Bytecodes::java_code(bc), 17.45 - true, false, KILL_COMPILE_ON_FATAL_(false)); 17.46 + fieldDescriptor result; 17.47 + LinkResolver::resolve_field(result, _holder->get_instanceKlass(), 17.48 + _name->get_symbol(), _signature->get_symbol(), 17.49 + accessing_klass->get_Klass(), bc, true, false, 17.50 + KILL_COMPILE_ON_FATAL_(false)); 17.51 17.52 // update the hit-cache, unless there is a problem with memory scoping: 17.53 if (accessing_klass->is_shared() || !is_shared()) {
18.1 --- a/src/share/vm/ci/ciField.hpp Sat Sep 21 10:09:42 2013 +0200 18.2 +++ b/src/share/vm/ci/ciField.hpp Tue Sep 24 10:14:02 2013 +0200 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -53,9 +53,6 @@ 18.11 ciInstanceKlass* _known_to_link_with_get; 18.12 ciConstant _constant_value; 18.13 18.14 - // Used for will_link 18.15 - int _cp_index; 18.16 - 18.17 ciType* compute_type(); 18.18 ciType* compute_type_impl(); 18.19
19.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp Sat Sep 21 10:09:42 2013 +0200 19.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp Tue Sep 24 10:14:02 2013 +0200 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -522,8 +522,7 @@ 19.11 19.12 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { 19.13 if (fs.access_flags().is_static()) continue; 19.14 - fieldDescriptor fd; 19.15 - fd.initialize(k, fs.index()); 19.16 + fieldDescriptor& fd = fs.field_descriptor(); 19.17 ciField* field = new (arena) ciField(&fd); 19.18 fields->append(field); 19.19 }
20.1 --- a/src/share/vm/ci/ciMethod.cpp Sat Sep 21 10:09:42 2013 +0200 20.2 +++ b/src/share/vm/ci/ciMethod.cpp Tue Sep 24 10:14:02 2013 +0200 20.3 @@ -286,7 +286,10 @@ 20.4 check_is_loaded(); 20.5 assert(holder()->is_linked(), "must be linked"); 20.6 VM_ENTRY_MARK; 20.7 - return klassItable::compute_itable_index(get_Method()); 20.8 + Method* m = get_Method(); 20.9 + if (!m->has_itable_index()) 20.10 + return Method::nonvirtual_vtable_index; 20.11 + return m->itable_index(); 20.12 } 20.13 #endif // SHARK 20.14 20.15 @@ -1137,6 +1140,10 @@ 20.16 // ------------------------------------------------------------------ 20.17 // ciMethod::check_call 20.18 bool ciMethod::check_call(int refinfo_index, bool is_static) const { 20.19 + // This method is used only in C2 from InlineTree::ok_to_inline, 20.20 + // and is only used under -Xcomp or -XX:CompileTheWorld. 20.21 + // It appears to fail when applied to an invokeinterface call site. 20.22 + // FIXME: Remove this method and resolve_method_statically; refactor to use the other LinkResolver entry points. 20.23 VM_ENTRY_MARK; 20.24 { 20.25 EXCEPTION_MARK;
21.1 --- a/src/share/vm/ci/ciSymbol.hpp Sat Sep 21 10:09:42 2013 +0200 21.2 +++ b/src/share/vm/ci/ciSymbol.hpp Tue Sep 24 10:14:02 2013 +0200 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -44,6 +44,7 @@ 21.11 friend class ciInstanceKlass; 21.12 friend class ciSignature; 21.13 friend class ciMethod; 21.14 + friend class ciField; 21.15 friend class ciObjArrayKlass; 21.16 21.17 private:
22.1 --- a/src/share/vm/classfile/classFileParser.cpp Sat Sep 21 10:09:42 2013 +0200 22.2 +++ b/src/share/vm/classfile/classFileParser.cpp Tue Sep 24 10:14:02 2013 +0200 22.3 @@ -888,6 +888,7 @@ 22.4 int runtime_visible_type_annotations_length = 0; 22.5 u1* runtime_invisible_type_annotations = NULL; 22.6 int runtime_invisible_type_annotations_length = 0; 22.7 + bool runtime_invisible_type_annotations_exists = false; 22.8 while (attributes_count--) { 22.9 cfs->guarantee_more(6, CHECK); // attribute_name_index, attribute_length 22.10 u2 attribute_name_index = cfs->get_u2_fast(); 22.11 @@ -946,15 +947,27 @@ 22.12 assert(runtime_invisible_annotations != NULL, "null invisible annotations"); 22.13 cfs->skip_u1(runtime_invisible_annotations_length, CHECK); 22.14 } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { 22.15 + if (runtime_visible_type_annotations != NULL) { 22.16 + classfile_parse_error( 22.17 + "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", CHECK); 22.18 + } 22.19 runtime_visible_type_annotations_length = attribute_length; 22.20 runtime_visible_type_annotations = cfs->get_u1_buffer(); 22.21 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 22.22 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); 22.23 - } else if (PreserveAllAnnotations && attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.24 - runtime_invisible_type_annotations_length = attribute_length; 22.25 - runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.26 - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.27 - cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK); 22.28 + } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.29 + if (runtime_invisible_type_annotations_exists) { 22.30 + classfile_parse_error( 22.31 + "Multiple RuntimeInvisibleTypeAnnotations attributes for field in class file %s", CHECK); 22.32 + } else { 22.33 + runtime_invisible_type_annotations_exists = true; 22.34 + } 22.35 + if (PreserveAllAnnotations) { 22.36 + runtime_invisible_type_annotations_length = attribute_length; 22.37 + runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.38 + assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.39 + } 22.40 + cfs->skip_u1(attribute_length, CHECK); 22.41 } else { 22.42 cfs->skip_u1(attribute_length, CHECK); // Skip unknown attributes 22.43 } 22.44 @@ -2066,6 +2079,7 @@ 22.45 int runtime_visible_type_annotations_length = 0; 22.46 u1* runtime_invisible_type_annotations = NULL; 22.47 int runtime_invisible_type_annotations_length = 0; 22.48 + bool runtime_invisible_type_annotations_exists = false; 22.49 u1* annotation_default = NULL; 22.50 int annotation_default_length = 0; 22.51 22.52 @@ -2322,16 +2336,30 @@ 22.53 assert(annotation_default != NULL, "null annotation default"); 22.54 cfs->skip_u1(annotation_default_length, CHECK_(nullHandle)); 22.55 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { 22.56 + if (runtime_visible_type_annotations != NULL) { 22.57 + classfile_parse_error( 22.58 + "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s", 22.59 + CHECK_(nullHandle)); 22.60 + } 22.61 runtime_visible_type_annotations_length = method_attribute_length; 22.62 runtime_visible_type_annotations = cfs->get_u1_buffer(); 22.63 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 22.64 // No need for the VM to parse Type annotations 22.65 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_(nullHandle)); 22.66 - } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.67 - runtime_invisible_type_annotations_length = method_attribute_length; 22.68 - runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.69 - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.70 - cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK_(nullHandle)); 22.71 + } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.72 + if (runtime_invisible_type_annotations_exists) { 22.73 + classfile_parse_error( 22.74 + "Multiple RuntimeInvisibleTypeAnnotations attributes for method in class file %s", 22.75 + CHECK_(nullHandle)); 22.76 + } else { 22.77 + runtime_invisible_type_annotations_exists = true; 22.78 + } 22.79 + if (PreserveAllAnnotations) { 22.80 + runtime_invisible_type_annotations_length = method_attribute_length; 22.81 + runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.82 + assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.83 + } 22.84 + cfs->skip_u1(method_attribute_length, CHECK_(nullHandle)); 22.85 } else { 22.86 // Skip unknown attributes 22.87 cfs->skip_u1(method_attribute_length, CHECK_(nullHandle)); 22.88 @@ -2824,6 +2852,7 @@ 22.89 int runtime_visible_type_annotations_length = 0; 22.90 u1* runtime_invisible_type_annotations = NULL; 22.91 int runtime_invisible_type_annotations_length = 0; 22.92 + bool runtime_invisible_type_annotations_exists = false; 22.93 u1* inner_classes_attribute_start = NULL; 22.94 u4 inner_classes_attribute_length = 0; 22.95 u2 enclosing_method_class_index = 0; 22.96 @@ -2927,16 +2956,28 @@ 22.97 parsed_bootstrap_methods_attribute = true; 22.98 parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK); 22.99 } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) { 22.100 + if (runtime_visible_type_annotations != NULL) { 22.101 + classfile_parse_error( 22.102 + "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", CHECK); 22.103 + } 22.104 runtime_visible_type_annotations_length = attribute_length; 22.105 runtime_visible_type_annotations = cfs->get_u1_buffer(); 22.106 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 22.107 // No need for the VM to parse Type annotations 22.108 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); 22.109 - } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.110 - runtime_invisible_type_annotations_length = attribute_length; 22.111 - runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.112 - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.113 - cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK); 22.114 + } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) { 22.115 + if (runtime_invisible_type_annotations_exists) { 22.116 + classfile_parse_error( 22.117 + "Multiple RuntimeInvisibleTypeAnnotations attributes in class file %s", CHECK); 22.118 + } else { 22.119 + runtime_invisible_type_annotations_exists = true; 22.120 + } 22.121 + if (PreserveAllAnnotations) { 22.122 + runtime_invisible_type_annotations_length = attribute_length; 22.123 + runtime_invisible_type_annotations = cfs->get_u1_buffer(); 22.124 + assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 22.125 + } 22.126 + cfs->skip_u1(attribute_length, CHECK); 22.127 } else { 22.128 // Unknown attribute 22.129 cfs->skip_u1(attribute_length, CHECK); 22.130 @@ -3954,9 +3995,8 @@ 22.131 this_klass->set_has_final_method(); 22.132 } 22.133 this_klass->copy_method_ordering(method_ordering, CHECK_NULL); 22.134 - // The InstanceKlass::_methods_jmethod_ids cache and the 22.135 - // InstanceKlass::_methods_cached_itable_indices cache are 22.136 - // both managed on the assumption that the initial cache 22.137 + // The InstanceKlass::_methods_jmethod_ids cache 22.138 + // is managed on the assumption that the initial cache 22.139 // size is equal to the number of methods in the class. If 22.140 // that changes, then InstanceKlass::idnum_can_increment() 22.141 // has to be changed accordingly.
23.1 --- a/src/share/vm/classfile/classLoader.cpp Sat Sep 21 10:09:42 2013 +0200 23.2 +++ b/src/share/vm/classfile/classLoader.cpp Tue Sep 24 10:14:02 2013 +0200 23.3 @@ -1319,6 +1319,25 @@ 23.4 // The CHECK at the caller will propagate the exception out 23.5 } 23.6 23.7 +/** 23.8 + * Returns if the given method should be compiled when doing compile-the-world. 23.9 + * 23.10 + * TODO: This should be a private method in a CompileTheWorld class. 23.11 + */ 23.12 +static bool can_be_compiled(methodHandle m, int comp_level) { 23.13 + assert(CompileTheWorld, "must be"); 23.14 + 23.15 + // It's not valid to compile a native wrapper for MethodHandle methods 23.16 + // that take a MemberName appendix since the bytecode signature is not 23.17 + // correct. 23.18 + vmIntrinsics::ID iid = m->intrinsic_id(); 23.19 + if (MethodHandles::is_signature_polymorphic(iid) && MethodHandles::has_member_arg(iid)) { 23.20 + return false; 23.21 + } 23.22 + 23.23 + return CompilationPolicy::can_be_compiled(m, comp_level); 23.24 +} 23.25 + 23.26 void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { 23.27 int len = (int)strlen(name); 23.28 if (len > 6 && strcmp(".class", name + len - 6) == 0) { 23.29 @@ -1362,8 +1381,7 @@ 23.30 int comp_level = CompilationPolicy::policy()->initial_compile_level(); 23.31 for (int n = 0; n < k->methods()->length(); n++) { 23.32 methodHandle m (THREAD, k->methods()->at(n)); 23.33 - if (CompilationPolicy::can_be_compiled(m, comp_level)) { 23.34 - 23.35 + if (can_be_compiled(m, comp_level)) { 23.36 if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) { 23.37 // Give sweeper a chance to keep up with CTW 23.38 VM_ForceSafepoint op; 23.39 @@ -1375,7 +1393,7 @@ 23.40 methodHandle(), 0, "CTW", THREAD); 23.41 if (HAS_PENDING_EXCEPTION) { 23.42 clear_pending_exception_if_not_oom(CHECK); 23.43 - tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name()->as_C_string()); 23.44 + tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); 23.45 } else { 23.46 _compile_the_world_method_counter++; 23.47 } 23.48 @@ -1391,11 +1409,13 @@ 23.49 methodHandle(), 0, "CTW", THREAD); 23.50 if (HAS_PENDING_EXCEPTION) { 23.51 clear_pending_exception_if_not_oom(CHECK); 23.52 - tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name()->as_C_string()); 23.53 + tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); 23.54 } else { 23.55 _compile_the_world_method_counter++; 23.56 } 23.57 } 23.58 + } else { 23.59 + tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); 23.60 } 23.61 23.62 nmethod* nm = m->code();
24.1 --- a/src/share/vm/classfile/defaultMethods.cpp Sat Sep 21 10:09:42 2013 +0200 24.2 +++ b/src/share/vm/classfile/defaultMethods.cpp Tue Sep 24 10:14:02 2013 +0200 24.3 @@ -450,6 +450,10 @@ 24.4 streamIndentor si(str, indent * 2); 24.5 str->indent().print("Selected method: "); 24.6 print_method(str, _selected_target); 24.7 + Klass* method_holder = _selected_target->method_holder(); 24.8 + if (!method_holder->is_interface()) { 24.9 + tty->print(" : in superclass"); 24.10 + } 24.11 str->print_cr(""); 24.12 } 24.13 24.14 @@ -1141,19 +1145,23 @@ 24.15 #endif // ndef PRODUCT 24.16 if (method->has_target()) { 24.17 Method* selected = method->get_selected_target(); 24.18 - max_stack = assemble_redirect( 24.19 + if (selected->method_holder()->is_interface()) { 24.20 + max_stack = assemble_redirect( 24.21 &bpool, &buffer, slot->signature(), selected, CHECK); 24.22 + } 24.23 } else if (method->throws_exception()) { 24.24 max_stack = assemble_abstract_method_error( 24.25 &bpool, &buffer, method->get_exception_message(), CHECK); 24.26 } 24.27 - AccessFlags flags = accessFlags_from( 24.28 + if (max_stack != 0) { 24.29 + AccessFlags flags = accessFlags_from( 24.30 JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE); 24.31 - Method* m = new_method(&bpool, &buffer, slot->name(), slot->signature(), 24.32 + Method* m = new_method(&bpool, &buffer, slot->name(), slot->signature(), 24.33 flags, max_stack, slot->size_of_parameters(), 24.34 ConstMethod::OVERPASS, CHECK); 24.35 - if (m != NULL) { 24.36 - overpasses.push(m); 24.37 + if (m != NULL) { 24.38 + overpasses.push(m); 24.39 + } 24.40 } 24.41 } 24.42 }
25.1 --- a/src/share/vm/code/compiledIC.cpp Sat Sep 21 10:09:42 2013 +0200 25.2 +++ b/src/share/vm/code/compiledIC.cpp Tue Sep 24 10:14:02 2013 +0200 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -161,31 +161,36 @@ 25.11 25.12 25.13 void CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { 25.14 - methodHandle method = call_info->selected_method(); 25.15 - bool is_invoke_interface = (bytecode == Bytecodes::_invokeinterface && !call_info->has_vtable_index()); 25.16 assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), ""); 25.17 assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic"); 25.18 assert(is_call_to_compiled() || is_call_to_interpreted(), "going directly to megamorphic?"); 25.19 25.20 address entry; 25.21 - if (is_invoke_interface) { 25.22 - int index = klassItable::compute_itable_index(call_info->resolved_method()()); 25.23 - entry = VtableStubs::create_stub(false, index, method()); 25.24 + if (call_info->call_kind() == CallInfo::itable_call) { 25.25 + assert(bytecode == Bytecodes::_invokeinterface, ""); 25.26 + int itable_index = call_info->itable_index(); 25.27 + entry = VtableStubs::find_itable_stub(itable_index); 25.28 +#ifdef ASSERT 25.29 assert(entry != NULL, "entry not computed"); 25.30 + int index = call_info->resolved_method()->itable_index(); 25.31 + assert(index == itable_index, "CallInfo pre-computes this"); 25.32 +#endif //ASSERT 25.33 InstanceKlass* k = call_info->resolved_method()->method_holder(); 25.34 - assert(k->is_interface(), "sanity check"); 25.35 + assert(k->verify_itable_index(itable_index), "sanity check"); 25.36 InlineCacheBuffer::create_transition_stub(this, k, entry); 25.37 } else { 25.38 - // Can be different than method->vtable_index(), due to package-private etc. 25.39 + assert(call_info->call_kind() == CallInfo::vtable_call, "either itable or vtable"); 25.40 + // Can be different than selected_method->vtable_index(), due to package-private etc. 25.41 int vtable_index = call_info->vtable_index(); 25.42 - entry = VtableStubs::create_stub(true, vtable_index, method()); 25.43 - InlineCacheBuffer::create_transition_stub(this, method(), entry); 25.44 + assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check"); 25.45 + entry = VtableStubs::find_vtable_stub(vtable_index); 25.46 + InlineCacheBuffer::create_transition_stub(this, NULL, entry); 25.47 } 25.48 25.49 if (TraceICs) { 25.50 ResourceMark rm; 25.51 tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, 25.52 - instruction_address(), method->print_value_string(), entry); 25.53 + instruction_address(), call_info->selected_method()->print_value_string(), entry); 25.54 } 25.55 25.56 // We can't check this anymore. With lazy deopt we could have already
26.1 --- a/src/share/vm/code/vtableStubs.cpp Sat Sep 21 10:09:42 2013 +0200 26.2 +++ b/src/share/vm/code/vtableStubs.cpp Tue Sep 24 10:14:02 2013 +0200 26.3 @@ -111,7 +111,7 @@ 26.4 } 26.5 26.6 26.7 -address VtableStubs::create_stub(bool is_vtable_stub, int vtable_index, Method* method) { 26.8 +address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { 26.9 assert(vtable_index >= 0, "must be positive"); 26.10 26.11 VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
27.1 --- a/src/share/vm/code/vtableStubs.hpp Sat Sep 21 10:09:42 2013 +0200 27.2 +++ b/src/share/vm/code/vtableStubs.hpp Tue Sep 24 10:14:02 2013 +0200 27.3 @@ -121,9 +121,11 @@ 27.4 static VtableStub* lookup (bool is_vtable_stub, int vtable_index); 27.5 static void enter (bool is_vtable_stub, int vtable_index, VtableStub* s); 27.6 static inline uint hash (bool is_vtable_stub, int vtable_index); 27.7 + static address find_stub (bool is_vtable_stub, int vtable_index); 27.8 27.9 public: 27.10 - static address create_stub(bool is_vtable_stub, int vtable_index, Method* method); // return the entry point of a stub for this call 27.11 + static address find_vtable_stub(int vtable_index) { return find_stub(true, vtable_index); } 27.12 + static address find_itable_stub(int itable_index) { return find_stub(false, itable_index); } 27.13 static bool is_entry_point(address pc); // is pc a vtable stub entry point? 27.14 static bool contains(address pc); // is pc within any stub? 27.15 static VtableStub* stub_containing(address pc); // stub containing pc or NULL
28.1 --- a/src/share/vm/gc_implementation/g1/ptrQueue.hpp Sat Sep 21 10:09:42 2013 +0200 28.2 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.hpp Tue Sep 24 10:14:02 2013 +0200 28.3 @@ -38,6 +38,7 @@ 28.4 28.5 class PtrQueueSet; 28.6 class PtrQueue VALUE_OBJ_CLASS_SPEC { 28.7 + friend class VMStructs; 28.8 28.9 protected: 28.10 // The ptr queue set to which this queue belongs.
29.1 --- a/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp Sat Sep 21 10:09:42 2013 +0200 29.2 +++ b/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp Tue Sep 24 10:14:02 2013 +0200 29.3 @@ -31,7 +31,8 @@ 29.4 29.5 #define VM_STRUCTS_G1(nonstatic_field, static_field) \ 29.6 \ 29.7 - static_field(HeapRegion, GrainBytes, size_t) \ 29.8 + static_field(HeapRegion, GrainBytes, size_t) \ 29.9 + static_field(HeapRegion, LogOfHRGrainBytes, int) \ 29.10 \ 29.11 nonstatic_field(HeapRegionSeq, _regions, HeapRegion**) \ 29.12 nonstatic_field(HeapRegionSeq, _length, uint) \
30.1 --- a/src/share/vm/gc_implementation/shared/allocationStats.hpp Sat Sep 21 10:09:42 2013 +0200 30.2 +++ b/src/share/vm/gc_implementation/shared/allocationStats.hpp Tue Sep 24 10:14:02 2013 +0200 30.3 @@ -1,5 +1,5 @@ 30.4 /* 30.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 30.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 * 30.9 * This code is free software; you can redistribute it and/or modify it 30.10 @@ -26,11 +26,9 @@ 30.11 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP 30.12 30.13 #include "utilities/macros.hpp" 30.14 -#if INCLUDE_ALL_GCS 30.15 -#include "gc_implementation/shared/gcUtil.hpp" 30.16 #include "memory/allocation.hpp" 30.17 #include "utilities/globalDefinitions.hpp" 30.18 -#endif // INCLUDE_ALL_GCS 30.19 +#include "gc_implementation/shared/gcUtil.hpp" 30.20 30.21 class AllocationStats VALUE_OBJ_CLASS_SPEC { 30.22 // A duration threshold (in ms) used to filter
31.1 --- a/src/share/vm/gc_implementation/shared/hSpaceCounters.hpp Sat Sep 21 10:09:42 2013 +0200 31.2 +++ b/src/share/vm/gc_implementation/shared/hSpaceCounters.hpp Tue Sep 24 10:14:02 2013 +0200 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -26,11 +26,9 @@ 31.11 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_HSPACECOUNTERS_HPP 31.12 31.13 #include "utilities/macros.hpp" 31.14 -#if INCLUDE_ALL_GCS 31.15 #include "gc_implementation/shared/generationCounters.hpp" 31.16 #include "memory/generation.hpp" 31.17 #include "runtime/perfData.hpp" 31.18 -#endif // INCLUDE_ALL_GCS 31.19 31.20 // A HSpaceCounter is a holder class for performance counters 31.21 // that track a collections (logical spaces) in a heap;
32.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp Sat Sep 21 10:09:42 2013 +0200 32.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp Tue Sep 24 10:14:02 2013 +0200 32.3 @@ -496,15 +496,15 @@ 32.4 32.5 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode)) 32.6 // resolve field 32.7 - FieldAccessInfo info; 32.8 + fieldDescriptor info; 32.9 constantPoolHandle pool(thread, method(thread)->constants()); 32.10 bool is_put = (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_putstatic); 32.11 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); 32.12 32.13 { 32.14 JvmtiHideSingleStepping jhss(thread); 32.15 - LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode), 32.16 - bytecode, false, CHECK); 32.17 + LinkResolver::resolve_field_access(info, pool, get_index_u2_cpcache(thread, bytecode), 32.18 + bytecode, CHECK); 32.19 } // end JvmtiHideSingleStepping 32.20 32.21 // check if link resolution caused cpCache to be updated 32.22 @@ -524,7 +524,7 @@ 32.23 // class is intitialized. This is required so that access to the static 32.24 // field will call the initialization function every time until the class 32.25 // is completely initialized ala. in 2.17.5 in JVM Specification. 32.26 - InstanceKlass *klass = InstanceKlass::cast(info.klass()()); 32.27 + InstanceKlass* klass = InstanceKlass::cast(info.field_holder()); 32.28 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) && 32.29 !klass->is_initialized()); 32.30 Bytecodes::Code get_code = (Bytecodes::Code)0; 32.31 @@ -539,9 +539,9 @@ 32.32 cache_entry(thread)->set_field( 32.33 get_code, 32.34 put_code, 32.35 - info.klass(), 32.36 - info.field_index(), 32.37 - info.field_offset(), 32.38 + info.field_holder(), 32.39 + info.index(), 32.40 + info.offset(), 32.41 state, 32.42 info.access_flags().is_final(), 32.43 info.access_flags().is_volatile(), 32.44 @@ -686,29 +686,55 @@ 32.45 if (already_resolved(thread)) return; 32.46 32.47 if (bytecode == Bytecodes::_invokeinterface) { 32.48 - 32.49 if (TraceItables && Verbose) { 32.50 ResourceMark rm(thread); 32.51 tty->print_cr("Resolving: klass: %s to method: %s", info.resolved_klass()->name()->as_C_string(), info.resolved_method()->name()->as_C_string()); 32.52 } 32.53 + } 32.54 +#ifdef ASSERT 32.55 + if (bytecode == Bytecodes::_invokeinterface) { 32.56 if (info.resolved_method()->method_holder() == 32.57 SystemDictionary::Object_klass()) { 32.58 // NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec 32.59 - // (see also cpCacheOop.cpp for details) 32.60 + // (see also CallInfo::set_interface for details) 32.61 + assert(info.call_kind() == CallInfo::vtable_call || 32.62 + info.call_kind() == CallInfo::direct_call, ""); 32.63 methodHandle rm = info.resolved_method(); 32.64 assert(rm->is_final() || info.has_vtable_index(), 32.65 "should have been set already"); 32.66 - cache_entry(thread)->set_method(bytecode, rm, info.vtable_index()); 32.67 + } else if (!info.resolved_method()->has_itable_index()) { 32.68 + // Resolved something like CharSequence.toString. Use vtable not itable. 32.69 + assert(info.call_kind() != CallInfo::itable_call, ""); 32.70 } else { 32.71 // Setup itable entry 32.72 - int index = klassItable::compute_itable_index(info.resolved_method()()); 32.73 - cache_entry(thread)->set_interface_call(info.resolved_method(), index); 32.74 + assert(info.call_kind() == CallInfo::itable_call, ""); 32.75 + int index = info.resolved_method()->itable_index(); 32.76 + assert(info.itable_index() == index, ""); 32.77 } 32.78 } else { 32.79 - cache_entry(thread)->set_method( 32.80 + assert(info.call_kind() == CallInfo::direct_call || 32.81 + info.call_kind() == CallInfo::vtable_call, ""); 32.82 + } 32.83 +#endif 32.84 + switch (info.call_kind()) { 32.85 + case CallInfo::direct_call: 32.86 + cache_entry(thread)->set_direct_call( 32.87 + bytecode, 32.88 + info.resolved_method()); 32.89 + break; 32.90 + case CallInfo::vtable_call: 32.91 + cache_entry(thread)->set_vtable_call( 32.92 bytecode, 32.93 info.resolved_method(), 32.94 info.vtable_index()); 32.95 + break; 32.96 + case CallInfo::itable_call: 32.97 + cache_entry(thread)->set_itable_call( 32.98 + bytecode, 32.99 + info.resolved_method(), 32.100 + info.itable_index()); 32.101 + break; 32.102 + default: ShouldNotReachHere(); 32.103 } 32.104 } 32.105 IRT_END
33.1 --- a/src/share/vm/interpreter/linkResolver.cpp Sat Sep 21 10:09:42 2013 +0200 33.2 +++ b/src/share/vm/interpreter/linkResolver.cpp Tue Sep 24 10:14:02 2013 +0200 33.3 @@ -46,19 +46,6 @@ 33.4 #include "runtime/thread.inline.hpp" 33.5 #include "runtime/vmThread.hpp" 33.6 33.7 -//------------------------------------------------------------------------------------------------------------------------ 33.8 -// Implementation of FieldAccessInfo 33.9 - 33.10 -void FieldAccessInfo::set(KlassHandle klass, Symbol* name, int field_index, int field_offset, 33.11 -BasicType field_type, AccessFlags access_flags) { 33.12 - _klass = klass; 33.13 - _name = name; 33.14 - _field_index = field_index; 33.15 - _field_offset = field_offset; 33.16 - _field_type = field_type; 33.17 - _access_flags = access_flags; 33.18 -} 33.19 - 33.20 33.21 //------------------------------------------------------------------------------------------------------------------------ 33.22 // Implementation of CallInfo 33.23 @@ -66,26 +53,25 @@ 33.24 33.25 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) { 33.26 int vtable_index = Method::nonvirtual_vtable_index; 33.27 - set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); 33.28 + set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); 33.29 } 33.30 33.31 33.32 -void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, TRAPS) { 33.33 +void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int itable_index, TRAPS) { 33.34 // This is only called for interface methods. If the resolved_method 33.35 // comes from java/lang/Object, it can be the subject of a virtual call, so 33.36 // we should pick the vtable index from the resolved method. 33.37 - // Other than that case, there is no valid vtable index to specify. 33.38 - int vtable_index = Method::invalid_vtable_index; 33.39 - if (resolved_method->method_holder() == SystemDictionary::Object_klass()) { 33.40 - assert(resolved_method->vtable_index() == selected_method->vtable_index(), "sanity check"); 33.41 - vtable_index = resolved_method->vtable_index(); 33.42 - } 33.43 - set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); 33.44 + // In that case, the caller must call set_virtual instead of set_interface. 33.45 + assert(resolved_method->method_holder()->is_interface(), ""); 33.46 + assert(itable_index == resolved_method()->itable_index(), ""); 33.47 + set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); 33.48 } 33.49 33.50 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { 33.51 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); 33.52 - set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK); 33.53 + assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), ""); 33.54 + CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call); 33.55 + set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); 33.56 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); 33.57 } 33.58 33.59 @@ -98,20 +84,29 @@ 33.60 resolved_method->is_compiled_lambda_form(), 33.61 "linkMethod must return one of these"); 33.62 int vtable_index = Method::nonvirtual_vtable_index; 33.63 - assert(resolved_method->vtable_index() == vtable_index, ""); 33.64 - set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK); 33.65 + assert(!resolved_method->has_vtable_index(), ""); 33.66 + set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); 33.67 _resolved_appendix = resolved_appendix; 33.68 _resolved_method_type = resolved_method_type; 33.69 } 33.70 33.71 -void CallInfo::set_common(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { 33.72 +void CallInfo::set_common(KlassHandle resolved_klass, 33.73 + KlassHandle selected_klass, 33.74 + methodHandle resolved_method, 33.75 + methodHandle selected_method, 33.76 + CallKind kind, 33.77 + int index, 33.78 + TRAPS) { 33.79 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); 33.80 _resolved_klass = resolved_klass; 33.81 _selected_klass = selected_klass; 33.82 _resolved_method = resolved_method; 33.83 _selected_method = selected_method; 33.84 - _vtable_index = vtable_index; 33.85 + _call_kind = kind; 33.86 + _call_index = index; 33.87 _resolved_appendix = Handle(); 33.88 + DEBUG_ONLY(verify()); // verify before making side effects 33.89 + 33.90 if (CompilationPolicy::must_be_compiled(selected_method)) { 33.91 // This path is unusual, mostly used by the '-Xcomp' stress test mode. 33.92 33.93 @@ -138,6 +133,65 @@ 33.94 } 33.95 } 33.96 33.97 +// utility query for unreflecting a method 33.98 +CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) { 33.99 + Klass* resolved_method_holder = resolved_method->method_holder(); 33.100 + if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st 33.101 + resolved_klass = resolved_method_holder; 33.102 + } 33.103 + _resolved_klass = resolved_klass; 33.104 + _selected_klass = resolved_klass; 33.105 + _resolved_method = resolved_method; 33.106 + _selected_method = resolved_method; 33.107 + // classify: 33.108 + CallKind kind = CallInfo::unknown_kind; 33.109 + int index = resolved_method->vtable_index(); 33.110 + if (resolved_method->can_be_statically_bound()) { 33.111 + kind = CallInfo::direct_call; 33.112 + } else if (!resolved_method_holder->is_interface()) { 33.113 + // Could be an Object method inherited into an interface, but still a vtable call. 33.114 + kind = CallInfo::vtable_call; 33.115 + } else if (!resolved_klass->is_interface()) { 33.116 + // A miranda method. Compute the vtable index. 33.117 + ResourceMark rm; 33.118 + klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable(); 33.119 + index = vt->index_of_miranda(resolved_method->name(), 33.120 + resolved_method->signature()); 33.121 + kind = CallInfo::vtable_call; 33.122 + } else { 33.123 + // A regular interface call. 33.124 + kind = CallInfo::itable_call; 33.125 + index = resolved_method->itable_index(); 33.126 + } 33.127 + assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index)); 33.128 + _call_kind = kind; 33.129 + _call_index = index; 33.130 + _resolved_appendix = Handle(); 33.131 + DEBUG_ONLY(verify()); 33.132 +} 33.133 + 33.134 +#ifdef ASSERT 33.135 +void CallInfo::verify() { 33.136 + switch (call_kind()) { // the meaning and allowed value of index depends on kind 33.137 + case CallInfo::direct_call: 33.138 + if (_call_index == Method::nonvirtual_vtable_index) break; 33.139 + // else fall through to check vtable index: 33.140 + case CallInfo::vtable_call: 33.141 + assert(resolved_klass()->verify_vtable_index(_call_index), ""); 33.142 + break; 33.143 + case CallInfo::itable_call: 33.144 + assert(resolved_method()->method_holder()->verify_itable_index(_call_index), ""); 33.145 + break; 33.146 + case CallInfo::unknown_kind: 33.147 + assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set"); 33.148 + break; 33.149 + default: 33.150 + fatal(err_msg_res("Unexpected call kind %d", call_kind())); 33.151 + } 33.152 +} 33.153 +#endif //ASSERT 33.154 + 33.155 + 33.156 33.157 //------------------------------------------------------------------------------------------------------------------------ 33.158 // Klass resolution 33.159 @@ -163,13 +217,6 @@ 33.160 result = KlassHandle(THREAD, result_oop); 33.161 } 33.162 33.163 -void LinkResolver::resolve_klass_no_update(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) { 33.164 - Klass* result_oop = 33.165 - ConstantPool::klass_ref_at_if_loaded_check(pool, index, CHECK); 33.166 - result = KlassHandle(THREAD, result_oop); 33.167 -} 33.168 - 33.169 - 33.170 //------------------------------------------------------------------------------------------------------------------------ 33.171 // Method resolution 33.172 // 33.173 @@ -360,7 +407,12 @@ 33.174 33.175 void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass, 33.176 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) { 33.177 - 33.178 + // This method is used only 33.179 + // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call), 33.180 + // and 33.181 + // (2) in Bytecode_invoke::static_target 33.182 + // It appears to fail when applied to an invokeinterface call site. 33.183 + // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. 33.184 // resolve klass 33.185 if (code == Bytecodes::_invokedynamic) { 33.186 resolved_klass = SystemDictionary::MethodHandle_klass(); 33.187 @@ -580,45 +632,49 @@ 33.188 } 33.189 } 33.190 33.191 -void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, TRAPS) { 33.192 - resolve_field(result, pool, index, byte, check_only, true, CHECK); 33.193 +void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { 33.194 + // Load these early in case the resolve of the containing klass fails 33.195 + Symbol* field = pool->name_ref_at(index); 33.196 + Symbol* sig = pool->signature_ref_at(index); 33.197 + 33.198 + // resolve specified klass 33.199 + KlassHandle resolved_klass; 33.200 + resolve_klass(resolved_klass, pool, index, CHECK); 33.201 + 33.202 + KlassHandle current_klass(THREAD, pool->pool_holder()); 33.203 + resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK); 33.204 } 33.205 33.206 -void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, bool update_pool, TRAPS) { 33.207 +void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig, 33.208 + KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class, 33.209 + TRAPS) { 33.210 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || 33.211 - byte == Bytecodes::_getfield || byte == Bytecodes::_putfield, "bad bytecode"); 33.212 + byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || 33.213 + (byte == Bytecodes::_nop && !check_access), "bad field access bytecode"); 33.214 33.215 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); 33.216 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic); 33.217 33.218 - // resolve specified klass 33.219 - KlassHandle resolved_klass; 33.220 - if (update_pool) { 33.221 - resolve_klass(resolved_klass, pool, index, CHECK); 33.222 - } else { 33.223 - resolve_klass_no_update(resolved_klass, pool, index, CHECK); 33.224 - } 33.225 - // Load these early in case the resolve of the containing klass fails 33.226 - Symbol* field = pool->name_ref_at(index); 33.227 - Symbol* sig = pool->signature_ref_at(index); 33.228 // Check if there's a resolved klass containing the field 33.229 - if( resolved_klass.is_null() ) { 33.230 + if (resolved_klass.is_null()) { 33.231 ResourceMark rm(THREAD); 33.232 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 33.233 } 33.234 33.235 // Resolve instance field 33.236 - fieldDescriptor fd; // find_field initializes fd if found 33.237 KlassHandle sel_klass(THREAD, InstanceKlass::cast(resolved_klass())->find_field(field, sig, &fd)); 33.238 // check if field exists; i.e., if a klass containing the field def has been selected 33.239 - if (sel_klass.is_null()){ 33.240 + if (sel_klass.is_null()) { 33.241 ResourceMark rm(THREAD); 33.242 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 33.243 } 33.244 33.245 + if (!check_access) 33.246 + // Access checking may be turned off when calling from within the VM. 33.247 + return; 33.248 + 33.249 // check access 33.250 - KlassHandle ref_klass(THREAD, pool->pool_holder()); 33.251 - check_field_accessability(ref_klass, resolved_klass, sel_klass, fd, CHECK); 33.252 + check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); 33.253 33.254 // check for errors 33.255 if (is_static != fd.is_static()) { 33.256 @@ -629,7 +685,7 @@ 33.257 } 33.258 33.259 // Final fields can only be accessed from its own class. 33.260 - if (is_put && fd.access_flags().is_final() && sel_klass() != pool->pool_holder()) { 33.261 + if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) { 33.262 THROW(vmSymbols::java_lang_IllegalAccessError()); 33.263 } 33.264 33.265 @@ -639,19 +695,18 @@ 33.266 // 33.267 // note 2: we don't want to force initialization if we are just checking 33.268 // if the field access is legal; e.g., during compilation 33.269 - if (is_static && !check_only) { 33.270 + if (is_static && initialize_class) { 33.271 sel_klass->initialize(CHECK); 33.272 } 33.273 33.274 - { 33.275 + if (sel_klass() != current_klass()) { 33.276 HandleMark hm(THREAD); 33.277 - Handle ref_loader (THREAD, InstanceKlass::cast(ref_klass())->class_loader()); 33.278 + Handle ref_loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); 33.279 Handle sel_loader (THREAD, InstanceKlass::cast(sel_klass())->class_loader()); 33.280 - Symbol* signature_ref = pool->signature_ref_at(index); 33.281 { 33.282 ResourceMark rm(THREAD); 33.283 Symbol* failed_type_symbol = 33.284 - SystemDictionary::check_signature_loaders(signature_ref, 33.285 + SystemDictionary::check_signature_loaders(sig, 33.286 ref_loader, sel_loader, 33.287 false, 33.288 CHECK); 33.289 @@ -677,9 +732,6 @@ 33.290 33.291 // return information. note that the klass is set to the actual klass containing the 33.292 // field, otherwise access of static fields in superclasses will not work. 33.293 - KlassHandle holder (THREAD, fd.field_holder()); 33.294 - Symbol* name = fd.name(); 33.295 - result.set(holder, name, fd.index(), fd.offset(), fd.field_type(), fd.access_flags()); 33.296 } 33.297 33.298 33.299 @@ -907,10 +959,6 @@ 33.300 } 33.301 33.302 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s 33.303 - // has not been rewritten, and the vtable initialized. 33.304 - assert(resolved_method->method_holder()->is_linked(), "must be linked"); 33.305 - 33.306 - // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s 33.307 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since 33.308 // a missing receiver might result in a bogus lookup. 33.309 assert(resolved_method->method_holder()->is_linked(), "must be linked"); 33.310 @@ -920,6 +968,7 @@ 33.311 vtable_index = vtable_index_of_miranda_method(resolved_klass, 33.312 resolved_method->name(), 33.313 resolved_method->signature(), CHECK); 33.314 + 33.315 assert(vtable_index >= 0 , "we should have valid vtable index at this point"); 33.316 33.317 InstanceKlass* inst = InstanceKlass::cast(recv_klass()); 33.318 @@ -927,6 +976,7 @@ 33.319 } else { 33.320 // at this point we are sure that resolved_method is virtual and not 33.321 // a miranda method; therefore, it must have a valid vtable index. 33.322 + assert(!resolved_method->has_itable_index(), ""); 33.323 vtable_index = resolved_method->vtable_index(); 33.324 // We could get a negative vtable_index for final methods, 33.325 // because as an optimization they are they are never put in the vtable, 33.326 @@ -1006,6 +1056,12 @@ 33.327 lookup_instance_method_in_klasses(sel_method, recv_klass, 33.328 resolved_method->name(), 33.329 resolved_method->signature(), CHECK); 33.330 + if (sel_method.is_null() && !check_null_and_abstract) { 33.331 + // In theory this is a harmless placeholder value, but 33.332 + // in practice leaving in null affects the nsk default method tests. 33.333 + // This needs further study. 33.334 + sel_method = resolved_method; 33.335 + } 33.336 // check if method exists 33.337 if (sel_method.is_null()) { 33.338 ResourceMark rm(THREAD); 33.339 @@ -1046,7 +1102,14 @@ 33.340 sel_method->signature())); 33.341 } 33.342 // setup result 33.343 - result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, CHECK); 33.344 + if (!resolved_method->has_itable_index()) { 33.345 + int vtable_index = resolved_method->vtable_index(); 33.346 + assert(vtable_index == sel_method->vtable_index(), "sanity check"); 33.347 + result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); 33.348 + return; 33.349 + } 33.350 + int itable_index = resolved_method()->itable_index(); 33.351 + result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); 33.352 } 33.353 33.354 33.355 @@ -1293,7 +1356,8 @@ 33.356 } 33.357 33.358 if (TraceMethodHandles) { 33.359 - tty->print_cr("resolve_invokedynamic #%d %s %s", 33.360 + ResourceMark rm(THREAD); 33.361 + tty->print_cr("resolve_invokedynamic #%d %s %s", 33.362 ConstantPool::decode_invokedynamic_index(index), 33.363 method_name->as_C_string(), method_signature->as_C_string()); 33.364 tty->print(" BSM info: "); bootstrap_specifier->print(); 33.365 @@ -1342,9 +1406,16 @@ 33.366 //------------------------------------------------------------------------------------------------------------------------ 33.367 #ifndef PRODUCT 33.368 33.369 -void FieldAccessInfo::print() { 33.370 +void CallInfo::print() { 33.371 ResourceMark rm; 33.372 - tty->print_cr("Field %s@%d", name()->as_C_string(), field_offset()); 33.373 + const char* kindstr = "unknown"; 33.374 + switch (_call_kind) { 33.375 + case direct_call: kindstr = "direct"; break; 33.376 + case vtable_call: kindstr = "vtable"; break; 33.377 + case itable_call: kindstr = "itable"; break; 33.378 + } 33.379 + tty->print_cr("Call %s@%d %s", kindstr, _call_index, 33.380 + _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); 33.381 } 33.382 33.383 #endif
34.1 --- a/src/share/vm/interpreter/linkResolver.hpp Sat Sep 21 10:09:42 2013 +0200 34.2 +++ b/src/share/vm/interpreter/linkResolver.hpp Tue Sep 24 10:14:02 2013 +0200 34.3 @@ -1,5 +1,5 @@ 34.4 /* 34.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 34.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.8 * 34.9 * This code is free software; you can redistribute it and/or modify it 34.10 @@ -30,63 +30,54 @@ 34.11 34.12 // All the necessary definitions for run-time link resolution. 34.13 34.14 -// LinkInfo & its subclasses provide all the information gathered 34.15 -// for a particular link after resolving it. A link is any reference 34.16 +// CallInfo provides all the information gathered for a particular 34.17 +// linked call site after resolving it. A link is any reference 34.18 // made from within the bytecodes of a method to an object outside of 34.19 // that method. If the info is invalid, the link has not been resolved 34.20 // successfully. 34.21 34.22 -class LinkInfo VALUE_OBJ_CLASS_SPEC { 34.23 -}; 34.24 - 34.25 - 34.26 -// Link information for getfield/putfield & getstatic/putstatic bytecodes. 34.27 - 34.28 -class FieldAccessInfo: public LinkInfo { 34.29 - protected: 34.30 - KlassHandle _klass; 34.31 - Symbol* _name; 34.32 - AccessFlags _access_flags; 34.33 - int _field_index; // original index in the klass 34.34 - int _field_offset; 34.35 - BasicType _field_type; 34.36 - 34.37 +class CallInfo VALUE_OBJ_CLASS_SPEC { 34.38 public: 34.39 - void set(KlassHandle klass, Symbol* name, int field_index, int field_offset, 34.40 - BasicType field_type, AccessFlags access_flags); 34.41 - KlassHandle klass() const { return _klass; } 34.42 - Symbol* name() const { return _name; } 34.43 - int field_index() const { return _field_index; } 34.44 - int field_offset() const { return _field_offset; } 34.45 - BasicType field_type() const { return _field_type; } 34.46 - AccessFlags access_flags() const { return _access_flags; } 34.47 - 34.48 - // debugging 34.49 - void print() PRODUCT_RETURN; 34.50 -}; 34.51 - 34.52 - 34.53 -// Link information for all calls. 34.54 - 34.55 -class CallInfo: public LinkInfo { 34.56 + // Ways that a method call might be selected (or not) based on receiver type. 34.57 + // Note that an invokevirtual instruction might be linked with no_dispatch, 34.58 + // and an invokeinterface instruction might be linked with any of the three options 34.59 + enum CallKind { 34.60 + direct_call, // jump into resolved_method (must be concrete) 34.61 + vtable_call, // select recv.klass.method_at_vtable(index) 34.62 + itable_call, // select recv.klass.method_at_itable(resolved_method.holder, index) 34.63 + unknown_kind = -1 34.64 + }; 34.65 private: 34.66 - KlassHandle _resolved_klass; // static receiver klass 34.67 + KlassHandle _resolved_klass; // static receiver klass, resolved from a symbolic reference 34.68 KlassHandle _selected_klass; // dynamic receiver class (same as static, or subklass) 34.69 methodHandle _resolved_method; // static target method 34.70 methodHandle _selected_method; // dynamic (actual) target method 34.71 - int _vtable_index; // vtable index of selected method 34.72 + CallKind _call_kind; // kind of call (static(=bytecode static/special + 34.73 + // others inferred), vtable, itable) 34.74 + int _call_index; // vtable or itable index of selected class method (if any) 34.75 Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) 34.76 Handle _resolved_method_type; // MethodType (for invokedynamic and invokehandle call sites) 34.77 34.78 void set_static( KlassHandle resolved_klass, methodHandle resolved_method , TRAPS); 34.79 - void set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method , TRAPS); 34.80 + void set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int itable_index , TRAPS); 34.81 void set_virtual( KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index , TRAPS); 34.82 void set_handle( methodHandle resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS); 34.83 - void set_common( KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index , TRAPS); 34.84 + void set_common( KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, CallKind kind, int index, TRAPS); 34.85 34.86 friend class LinkResolver; 34.87 34.88 public: 34.89 + CallInfo() { 34.90 +#ifndef PRODUCT 34.91 + _call_kind = CallInfo::unknown_kind; 34.92 + _call_index = Method::garbage_vtable_index; 34.93 +#endif //PRODUCT 34.94 + } 34.95 + 34.96 + // utility to extract an effective CallInfo from a method and an optional receiver limit 34.97 + // does not queue the method for compilation 34.98 + CallInfo(Method* resolved_method, Klass* resolved_klass = NULL); 34.99 + 34.100 KlassHandle resolved_klass() const { return _resolved_klass; } 34.101 KlassHandle selected_klass() const { return _selected_klass; } 34.102 methodHandle resolved_method() const { return _resolved_method; } 34.103 @@ -95,21 +86,43 @@ 34.104 Handle resolved_method_type() const { return _resolved_method_type; } 34.105 34.106 BasicType result_type() const { return selected_method()->result_type(); } 34.107 - bool has_vtable_index() const { return _vtable_index >= 0; } 34.108 - bool is_statically_bound() const { return _vtable_index == Method::nonvirtual_vtable_index; } 34.109 + CallKind call_kind() const { return _call_kind; } 34.110 + int call_index() const { return _call_index; } 34.111 int vtable_index() const { 34.112 // Even for interface calls the vtable index could be non-negative. 34.113 // See CallInfo::set_interface. 34.114 assert(has_vtable_index() || is_statically_bound(), ""); 34.115 - return _vtable_index; 34.116 + assert(call_kind() == vtable_call || call_kind() == direct_call, ""); 34.117 + // The returned value is < 0 if the call is statically bound. 34.118 + // But, the returned value may be >= 0 even if the kind is direct_call. 34.119 + // It is up to the caller to decide which way to go. 34.120 + return _call_index; 34.121 } 34.122 + int itable_index() const { 34.123 + assert(call_kind() == itable_call, ""); 34.124 + // The returned value is always >= 0, a valid itable index. 34.125 + return _call_index; 34.126 + } 34.127 + 34.128 + // debugging 34.129 +#ifdef ASSERT 34.130 + bool has_vtable_index() const { return _call_index >= 0 && _call_kind != CallInfo::itable_call; } 34.131 + bool is_statically_bound() const { return _call_index == Method::nonvirtual_vtable_index; } 34.132 +#endif //ASSERT 34.133 + void verify() PRODUCT_RETURN; 34.134 + void print() PRODUCT_RETURN; 34.135 }; 34.136 34.137 +// Link information for getfield/putfield & getstatic/putstatic bytecodes 34.138 +// is represented using a fieldDescriptor. 34.139 34.140 // The LinkResolver is used to resolve constant-pool references at run-time. 34.141 // It does all necessary link-time checks & throws exceptions if necessary. 34.142 34.143 class LinkResolver: AllStatic { 34.144 + friend class klassVtable; 34.145 + friend class klassItable; 34.146 + 34.147 private: 34.148 static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); 34.149 static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); 34.150 @@ -120,7 +133,6 @@ 34.151 static int vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); 34.152 34.153 static void resolve_klass (KlassHandle& result, constantPoolHandle pool, int index, TRAPS); 34.154 - static void resolve_klass_no_update (KlassHandle& result, constantPoolHandle pool, int index, TRAPS); // no update of constantPool entry 34.155 34.156 static void resolve_pool (KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS); 34.157 34.158 @@ -148,9 +160,16 @@ 34.159 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS); 34.160 34.161 // runtime/static resolving for fields 34.162 - static void resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, TRAPS); 34.163 - // takes an extra bool argument "update_pool" to decide whether to update the constantPool during klass resolution. 34.164 - static void resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, bool update_pool, TRAPS); 34.165 + static void resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS); 34.166 + static void resolve_field(fieldDescriptor& result, KlassHandle resolved_klass, Symbol* field_name, Symbol* field_signature, 34.167 + KlassHandle current_klass, Bytecodes::Code access_kind, bool check_access, bool initialize_class, TRAPS); 34.168 + 34.169 + // source of access_kind codes: 34.170 + static Bytecodes::Code field_access_kind(bool is_static, bool is_put) { 34.171 + return (is_static 34.172 + ? (is_put ? Bytecodes::_putstatic : Bytecodes::_getstatic) 34.173 + : (is_put ? Bytecodes::_putfield : Bytecodes::_getfield )); 34.174 + } 34.175 34.176 // runtime resolving: 34.177 // resolved_klass = specified class (i.e., static receiver class)
35.1 --- a/src/share/vm/memory/binaryTreeDictionary.cpp Sat Sep 21 10:09:42 2013 +0200 35.2 +++ b/src/share/vm/memory/binaryTreeDictionary.cpp Tue Sep 24 10:14:02 2013 +0200 35.3 @@ -1,5 +1,5 @@ 35.4 /* 35.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 35.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 35.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.8 * 35.9 * This code is free software; you can redistribute it and/or modify it 35.10 @@ -33,10 +33,10 @@ 35.11 #include "runtime/globals.hpp" 35.12 #include "utilities/ostream.hpp" 35.13 #include "utilities/macros.hpp" 35.14 +#include "gc_implementation/shared/spaceDecorator.hpp" 35.15 #if INCLUDE_ALL_GCS 35.16 #include "gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp" 35.17 #include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" 35.18 -#include "gc_implementation/shared/spaceDecorator.hpp" 35.19 #include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" 35.20 #endif // INCLUDE_ALL_GCS 35.21
36.1 --- a/src/share/vm/memory/universe.cpp Sat Sep 21 10:09:42 2013 +0200 36.2 +++ b/src/share/vm/memory/universe.cpp Tue Sep 24 10:14:02 2013 +0200 36.3 @@ -602,7 +602,7 @@ 36.4 } 36.5 } 36.6 36.7 -static intptr_t non_oop_bits = 0; 36.8 +intptr_t Universe::_non_oop_bits = 0; 36.9 36.10 void* Universe::non_oop_word() { 36.11 // Neither the high bits nor the low bits of this value is allowed 36.12 @@ -616,11 +616,11 @@ 36.13 // Using the OS-supplied non-memory-address word (usually 0 or -1) 36.14 // will take care of the high bits, however many there are. 36.15 36.16 - if (non_oop_bits == 0) { 36.17 - non_oop_bits = (intptr_t)os::non_memory_address_word() | 1; 36.18 + if (_non_oop_bits == 0) { 36.19 + _non_oop_bits = (intptr_t)os::non_memory_address_word() | 1; 36.20 } 36.21 36.22 - return (void*)non_oop_bits; 36.23 + return (void*)_non_oop_bits; 36.24 } 36.25 36.26 jint universe_init() {
37.1 --- a/src/share/vm/memory/universe.hpp Sat Sep 21 10:09:42 2013 +0200 37.2 +++ b/src/share/vm/memory/universe.hpp Tue Sep 24 10:14:02 2013 +0200 37.3 @@ -179,6 +179,8 @@ 37.4 // The particular choice of collected heap. 37.5 static CollectedHeap* _collectedHeap; 37.6 37.7 + static intptr_t _non_oop_bits; 37.8 + 37.9 // For UseCompressedOops. 37.10 static struct NarrowPtrStruct _narrow_oop; 37.11 // For UseCompressedClassPointers.
38.1 --- a/src/share/vm/oops/constantPool.cpp Sat Sep 21 10:09:42 2013 +0200 38.2 +++ b/src/share/vm/oops/constantPool.cpp Tue Sep 24 10:14:02 2013 +0200 38.3 @@ -396,32 +396,6 @@ 38.4 } 38.5 38.6 38.7 -// This is an interface for the compiler that allows accessing non-resolved entries 38.8 -// in the constant pool - but still performs the validations tests. Must be used 38.9 -// in a pre-parse of the compiler - to determine what it can do and not do. 38.10 -// Note: We cannot update the ConstantPool from the vm_thread. 38.11 -Klass* ConstantPool::klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int index, TRAPS) { 38.12 - int which = this_oop->klass_ref_index_at(index); 38.13 - CPSlot entry = this_oop->slot_at(which); 38.14 - if (entry.is_resolved()) { 38.15 - assert(entry.get_klass()->is_klass(), "must be"); 38.16 - return entry.get_klass(); 38.17 - } else { 38.18 - assert(entry.is_unresolved(), "must be either symbol or klass"); 38.19 - Symbol* name = entry.get_symbol(); 38.20 - oop loader = this_oop->pool_holder()->class_loader(); 38.21 - oop protection_domain = this_oop->pool_holder()->protection_domain(); 38.22 - Handle h_loader(THREAD, loader); 38.23 - Handle h_prot (THREAD, protection_domain); 38.24 - KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD)); 38.25 - 38.26 - // Do access check for klasses 38.27 - if( k.not_null() ) verify_constant_pool_resolve(this_oop, k, CHECK_NULL); 38.28 - return k(); 38.29 - } 38.30 -} 38.31 - 38.32 - 38.33 Method* ConstantPool::method_at_if_loaded(constantPoolHandle cpool, 38.34 int which) { 38.35 if (cpool->cache() == NULL) return NULL; // nothing to load yet
39.1 --- a/src/share/vm/oops/constantPool.hpp Sat Sep 21 10:09:42 2013 +0200 39.2 +++ b/src/share/vm/oops/constantPool.hpp Tue Sep 24 10:14:02 2013 +0200 39.3 @@ -730,8 +730,6 @@ 39.4 static oop method_type_at_if_loaded (constantPoolHandle this_oop, int which); 39.5 static Klass* klass_at_if_loaded (constantPoolHandle this_oop, int which); 39.6 static Klass* klass_ref_at_if_loaded (constantPoolHandle this_oop, int which); 39.7 - // Same as above - but does LinkResolving. 39.8 - static Klass* klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int which, TRAPS); 39.9 39.10 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the 39.11 // future by other Java code. These take constant pool indices rather than
40.1 --- a/src/share/vm/oops/cpCache.cpp Sat Sep 21 10:09:42 2013 +0200 40.2 +++ b/src/share/vm/oops/cpCache.cpp Tue Sep 24 10:14:02 2013 +0200 40.3 @@ -140,9 +140,10 @@ 40.4 err_msg("size must not change: parameter_size=%d, value=%d", parameter_size(), value)); 40.5 } 40.6 40.7 -void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code, 40.8 - methodHandle method, 40.9 - int vtable_index) { 40.10 +void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_code, 40.11 + methodHandle method, 40.12 + int vtable_index) { 40.13 + bool is_vtable_call = (vtable_index >= 0); // FIXME: split this method on this boolean 40.14 assert(method->interpreter_entry() != NULL, "should have been set at this point"); 40.15 assert(!method->is_obsolete(), "attempt to write obsolete method to cpCache"); 40.16 40.17 @@ -160,7 +161,8 @@ 40.18 // ...and fall through as if we were handling invokevirtual: 40.19 case Bytecodes::_invokevirtual: 40.20 { 40.21 - if (method->can_be_statically_bound()) { 40.22 + if (!is_vtable_call) { 40.23 + assert(method->can_be_statically_bound(), ""); 40.24 // set_f2_as_vfinal_method checks if is_vfinal flag is true. 40.25 set_method_flags(as_TosState(method->result_type()), 40.26 ( 1 << is_vfinal_shift) | 40.27 @@ -169,6 +171,7 @@ 40.28 method()->size_of_parameters()); 40.29 set_f2_as_vfinal_method(method()); 40.30 } else { 40.31 + assert(!method->can_be_statically_bound(), ""); 40.32 assert(vtable_index >= 0, "valid index"); 40.33 assert(!method->is_final_method(), "sanity"); 40.34 set_method_flags(as_TosState(method->result_type()), 40.35 @@ -182,6 +185,7 @@ 40.36 40.37 case Bytecodes::_invokespecial: 40.38 case Bytecodes::_invokestatic: 40.39 + assert(!is_vtable_call, ""); 40.40 // Note: Read and preserve the value of the is_vfinal flag on any 40.41 // invokevirtual bytecode shared with this constant pool cache entry. 40.42 // It is cheap and safe to consult is_vfinal() at all times. 40.43 @@ -232,8 +236,22 @@ 40.44 NOT_PRODUCT(verify(tty)); 40.45 } 40.46 40.47 +void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method) { 40.48 + int index = Method::nonvirtual_vtable_index; 40.49 + // index < 0; FIXME: inline and customize set_direct_or_vtable_call 40.50 + set_direct_or_vtable_call(invoke_code, method, index); 40.51 +} 40.52 40.53 -void ConstantPoolCacheEntry::set_interface_call(methodHandle method, int index) { 40.54 +void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, methodHandle method, int index) { 40.55 + // either the method is a miranda or its holder should accept the given index 40.56 + assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), ""); 40.57 + // index >= 0; FIXME: inline and customize set_direct_or_vtable_call 40.58 + set_direct_or_vtable_call(invoke_code, method, index); 40.59 +} 40.60 + 40.61 +void ConstantPoolCacheEntry::set_itable_call(Bytecodes::Code invoke_code, methodHandle method, int index) { 40.62 + assert(method->method_holder()->verify_itable_index(index), ""); 40.63 + assert(invoke_code == Bytecodes::_invokeinterface, ""); 40.64 InstanceKlass* interf = method->method_holder(); 40.65 assert(interf->is_interface(), "must be an interface"); 40.66 assert(!method->is_final_method(), "interfaces do not have final methods; cannot link to one here");
41.1 --- a/src/share/vm/oops/cpCache.hpp Sat Sep 21 10:09:42 2013 +0200 41.2 +++ b/src/share/vm/oops/cpCache.hpp Tue Sep 24 10:14:02 2013 +0200 41.3 @@ -219,15 +219,29 @@ 41.4 Klass* root_klass // needed by the GC to dirty the klass 41.5 ); 41.6 41.7 - void set_method( // sets entry to resolved method entry 41.8 + private: 41.9 + void set_direct_or_vtable_call( 41.10 Bytecodes::Code invoke_code, // the bytecode used for invoking the method 41.11 methodHandle method, // the method/prototype if any (NULL, otherwise) 41.12 int vtable_index // the vtable index if any, else negative 41.13 ); 41.14 41.15 - void set_interface_call( 41.16 - methodHandle method, // Resolved method 41.17 - int index // Method index into interface 41.18 + public: 41.19 + void set_direct_call( // sets entry to exact concrete method entry 41.20 + Bytecodes::Code invoke_code, // the bytecode used for invoking the method 41.21 + methodHandle method // the method to call 41.22 + ); 41.23 + 41.24 + void set_vtable_call( // sets entry to vtable index 41.25 + Bytecodes::Code invoke_code, // the bytecode used for invoking the method 41.26 + methodHandle method, // resolved method which declares the vtable index 41.27 + int vtable_index // the vtable index 41.28 + ); 41.29 + 41.30 + void set_itable_call( 41.31 + Bytecodes::Code invoke_code, // the bytecode used; must be invokeinterface 41.32 + methodHandle method, // the resolved interface method 41.33 + int itable_index // index into itable for the method 41.34 ); 41.35 41.36 void set_method_handle(
42.1 --- a/src/share/vm/oops/fieldStreams.hpp Sat Sep 21 10:09:42 2013 +0200 42.2 +++ b/src/share/vm/oops/fieldStreams.hpp Tue Sep 24 10:14:02 2013 +0200 42.3 @@ -1,5 +1,5 @@ 42.4 /* 42.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 42.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 42.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.8 * 42.9 * This code is free software; you can redistribute it and/or modify it 42.10 @@ -27,6 +27,7 @@ 42.11 42.12 #include "oops/instanceKlass.hpp" 42.13 #include "oops/fieldInfo.hpp" 42.14 +#include "runtime/fieldDescriptor.hpp" 42.15 42.16 // The is the base class for iteration over the fields array 42.17 // describing the declared fields in the class. Several subclasses 42.18 @@ -43,8 +44,10 @@ 42.19 int _index; 42.20 int _limit; 42.21 int _generic_signature_slot; 42.22 + fieldDescriptor _fd_buf; 42.23 42.24 FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); } 42.25 + InstanceKlass* field_holder() const { return _constants->pool_holder(); } 42.26 42.27 int init_generic_signature_start_slot() { 42.28 int length = _fields->length(); 42.29 @@ -102,6 +105,7 @@ 42.30 _index = 0; 42.31 _limit = klass->java_fields_count(); 42.32 init_generic_signature_start_slot(); 42.33 + assert(klass == field_holder(), ""); 42.34 } 42.35 FieldStreamBase(instanceKlassHandle klass) { 42.36 _fields = klass->fields(); 42.37 @@ -109,6 +113,7 @@ 42.38 _index = 0; 42.39 _limit = klass->java_fields_count(); 42.40 init_generic_signature_start_slot(); 42.41 + assert(klass == field_holder(), ""); 42.42 } 42.43 42.44 // accessors 42.45 @@ -180,6 +185,12 @@ 42.46 return field()->contended_group(); 42.47 } 42.48 42.49 + // bridge to a heavier API: 42.50 + fieldDescriptor& field_descriptor() const { 42.51 + fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf); 42.52 + field.reinitialize(field_holder(), _index); 42.53 + return field; 42.54 + } 42.55 }; 42.56 42.57 // Iterate over only the internal fields
43.1 --- a/src/share/vm/oops/instanceKlass.cpp Sat Sep 21 10:09:42 2013 +0200 43.2 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Sep 24 10:14:02 2013 +0200 43.3 @@ -286,7 +286,6 @@ 43.4 init_previous_versions(); 43.5 set_generic_signature_index(0); 43.6 release_set_methods_jmethod_ids(NULL); 43.7 - release_set_methods_cached_itable_indices(NULL); 43.8 set_annotations(NULL); 43.9 set_jvmti_cached_class_field_map(NULL); 43.10 set_initial_method_idnum(0); 43.11 @@ -1149,7 +1148,7 @@ 43.12 Symbol* f_name = fs.name(); 43.13 Symbol* f_sig = fs.signature(); 43.14 if (f_name == name && f_sig == sig) { 43.15 - fd->initialize(const_cast<InstanceKlass*>(this), fs.index()); 43.16 + fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index()); 43.17 return true; 43.18 } 43.19 } 43.20 @@ -1218,7 +1217,7 @@ 43.21 bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 43.22 for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 43.23 if (fs.offset() == offset) { 43.24 - fd->initialize(const_cast<InstanceKlass*>(this), fs.index()); 43.25 + fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index()); 43.26 if (fd->is_static() == is_static) return true; 43.27 } 43.28 } 43.29 @@ -1251,8 +1250,7 @@ 43.30 void InstanceKlass::do_local_static_fields(FieldClosure* cl) { 43.31 for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 43.32 if (fs.access_flags().is_static()) { 43.33 - fieldDescriptor fd; 43.34 - fd.initialize(this, fs.index()); 43.35 + fieldDescriptor& fd = fs.field_descriptor(); 43.36 cl->do_field(&fd); 43.37 } 43.38 } 43.39 @@ -1268,8 +1266,7 @@ 43.40 void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { 43.41 for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) { 43.42 if (fs.access_flags().is_static()) { 43.43 - fieldDescriptor fd; 43.44 - fd.initialize(this_oop(), fs.index()); 43.45 + fieldDescriptor& fd = fs.field_descriptor(); 43.46 f(&fd, CHECK); 43.47 } 43.48 } 43.49 @@ -1291,7 +1288,7 @@ 43.50 int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass); 43.51 int j = 0; 43.52 for (int i = 0; i < length; i += 1) { 43.53 - fd.initialize(this, i); 43.54 + fd.reinitialize(this, i); 43.55 if (!fd.is_static()) { 43.56 fields_sorted[j + 0] = fd.offset(); 43.57 fields_sorted[j + 1] = i; 43.58 @@ -1303,7 +1300,7 @@ 43.59 // _sort_Fn is defined in growableArray.hpp. 43.60 qsort(fields_sorted, length/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset); 43.61 for (int i = 0; i < length; i += 2) { 43.62 - fd.initialize(this, fields_sorted[i + 1]); 43.63 + fd.reinitialize(this, fields_sorted[i + 1]); 43.64 assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields"); 43.65 cl->do_field(&fd); 43.66 } 43.67 @@ -1686,87 +1683,6 @@ 43.68 } 43.69 43.70 43.71 -// Cache an itable index 43.72 -void InstanceKlass::set_cached_itable_index(size_t idnum, int index) { 43.73 - int* indices = methods_cached_itable_indices_acquire(); 43.74 - int* to_dealloc_indices = NULL; 43.75 - 43.76 - // We use a double-check locking idiom here because this cache is 43.77 - // performance sensitive. In the normal system, this cache only 43.78 - // transitions from NULL to non-NULL which is safe because we use 43.79 - // release_set_methods_cached_itable_indices() to advertise the 43.80 - // new cache. A partially constructed cache should never be seen 43.81 - // by a racing thread. Cache reads and writes proceed without a 43.82 - // lock, but creation of the cache itself requires no leaks so a 43.83 - // lock is generally acquired in that case. 43.84 - // 43.85 - // If the RedefineClasses() API has been used, then this cache can 43.86 - // grow and we'll have transitions from non-NULL to bigger non-NULL. 43.87 - // Cache creation requires no leaks and we require safety between all 43.88 - // cache accesses and freeing of the old cache so a lock is generally 43.89 - // acquired when the RedefineClasses() API has been used. 43.90 - 43.91 - if (indices == NULL || idnum_can_increment()) { 43.92 - // we need a cache or the cache can grow 43.93 - MutexLocker ml(JNICachedItableIndex_lock); 43.94 - // reacquire the cache to see if another thread already did the work 43.95 - indices = methods_cached_itable_indices_acquire(); 43.96 - size_t length = 0; 43.97 - // cache size is stored in element[0], other elements offset by one 43.98 - if (indices == NULL || (length = (size_t)indices[0]) <= idnum) { 43.99 - size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count()); 43.100 - int* new_indices = NEW_C_HEAP_ARRAY(int, size+1, mtClass); 43.101 - new_indices[0] = (int)size; 43.102 - // copy any existing entries 43.103 - size_t i; 43.104 - for (i = 0; i < length; i++) { 43.105 - new_indices[i+1] = indices[i+1]; 43.106 - } 43.107 - // Set all the rest to -1 43.108 - for (i = length; i < size; i++) { 43.109 - new_indices[i+1] = -1; 43.110 - } 43.111 - if (indices != NULL) { 43.112 - // We have an old cache to delete so save it for after we 43.113 - // drop the lock. 43.114 - to_dealloc_indices = indices; 43.115 - } 43.116 - release_set_methods_cached_itable_indices(indices = new_indices); 43.117 - } 43.118 - 43.119 - if (idnum_can_increment()) { 43.120 - // this cache can grow so we have to write to it safely 43.121 - indices[idnum+1] = index; 43.122 - } 43.123 - } else { 43.124 - CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 43.125 - } 43.126 - 43.127 - if (!idnum_can_increment()) { 43.128 - // The cache cannot grow and this JNI itable index value does not 43.129 - // have to be unique like a jmethodID. If there is a race to set it, 43.130 - // it doesn't matter. 43.131 - indices[idnum+1] = index; 43.132 - } 43.133 - 43.134 - if (to_dealloc_indices != NULL) { 43.135 - // we allocated a new cache so free the old one 43.136 - FreeHeap(to_dealloc_indices); 43.137 - } 43.138 -} 43.139 - 43.140 - 43.141 -// Retrieve a cached itable index 43.142 -int InstanceKlass::cached_itable_index(size_t idnum) { 43.143 - int* indices = methods_cached_itable_indices_acquire(); 43.144 - if (indices != NULL && ((size_t)indices[0]) > idnum) { 43.145 - // indices exist and are long enough, retrieve possible cached 43.146 - return indices[idnum+1]; 43.147 - } 43.148 - return -1; 43.149 -} 43.150 - 43.151 - 43.152 // 43.153 // Walk the list of dependent nmethods searching for nmethods which 43.154 // are dependent on the changes that were passed in and mark them for 43.155 @@ -2326,12 +2242,6 @@ 43.156 } 43.157 } 43.158 43.159 - int* indices = methods_cached_itable_indices_acquire(); 43.160 - if (indices != (int*)NULL) { 43.161 - release_set_methods_cached_itable_indices(NULL); 43.162 - FreeHeap(indices); 43.163 - } 43.164 - 43.165 // release dependencies 43.166 nmethodBucket* b = _dependencies; 43.167 _dependencies = NULL; 43.168 @@ -2782,6 +2692,18 @@ 43.169 "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error" 43.170 }; 43.171 43.172 +static void print_vtable(intptr_t* start, int len, outputStream* st) { 43.173 + for (int i = 0; i < len; i++) { 43.174 + intptr_t e = start[i]; 43.175 + st->print("%d : " INTPTR_FORMAT, i, e); 43.176 + if (e != 0 && ((Metadata*)e)->is_metaspace_object()) { 43.177 + st->print(" "); 43.178 + ((Metadata*)e)->print_value_on(st); 43.179 + } 43.180 + st->cr(); 43.181 + } 43.182 +} 43.183 + 43.184 void InstanceKlass::print_on(outputStream* st) const { 43.185 assert(is_klass(), "must be klass"); 43.186 Klass::print_on(st); 43.187 @@ -2816,7 +2738,7 @@ 43.188 43.189 st->print(BULLET"arrays: "); array_klasses()->print_value_on_maybe_null(st); st->cr(); 43.190 st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr(); 43.191 - if (Verbose) { 43.192 + if (Verbose || WizardMode) { 43.193 Array<Method*>* method_array = methods(); 43.194 for(int i = 0; i < method_array->length(); i++) { 43.195 st->print("%d : ", i); method_array->at(i)->print_value(); st->cr(); 43.196 @@ -2874,7 +2796,9 @@ 43.197 st->print(BULLET"inner classes: "); inner_classes()->print_value_on(st); st->cr(); 43.198 st->print(BULLET"java mirror: "); java_mirror()->print_value_on(st); st->cr(); 43.199 st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", vtable_length(), start_of_vtable()); st->cr(); 43.200 + if (vtable_length() > 0 && (Verbose || WizardMode)) print_vtable(start_of_vtable(), vtable_length(), st); 43.201 st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", itable_length(), start_of_itable()); st->cr(); 43.202 + if (itable_length() > 0 && (Verbose || WizardMode)) print_vtable(start_of_itable(), itable_length(), st); 43.203 st->print_cr(BULLET"---- static fields (%d words):", static_field_size()); 43.204 FieldPrinter print_static_field(st); 43.205 ((InstanceKlass*)this)->do_local_static_fields(&print_static_field); 43.206 @@ -2896,6 +2820,7 @@ 43.207 43.208 void InstanceKlass::print_value_on(outputStream* st) const { 43.209 assert(is_klass(), "must be klass"); 43.210 + if (Verbose || WizardMode) access_flags().print_on(st); 43.211 name()->print_value_on(st); 43.212 } 43.213
44.1 --- a/src/share/vm/oops/instanceKlass.hpp Sat Sep 21 10:09:42 2013 +0200 44.2 +++ b/src/share/vm/oops/instanceKlass.hpp Tue Sep 24 10:14:02 2013 +0200 44.3 @@ -245,7 +245,6 @@ 44.4 MemberNameTable* _member_names; // Member names 44.5 JNIid* _jni_ids; // First JNI identifier for static fields in this class 44.6 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none 44.7 - int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL 44.8 nmethodBucket* _dependencies; // list of dependent nmethods 44.9 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class 44.10 BreakpointInfo* _breakpoints; // bpt lists, managed by Method* 44.11 @@ -690,10 +689,6 @@ 44.12 size_t *length_p, jmethodID* id_p); 44.13 jmethodID jmethod_id_or_null(Method* method); 44.14 44.15 - // cached itable index support 44.16 - void set_cached_itable_index(size_t idnum, int index); 44.17 - int cached_itable_index(size_t idnum); 44.18 - 44.19 // annotations support 44.20 Annotations* annotations() const { return _annotations; } 44.21 void set_annotations(Annotations* anno) { _annotations = anno; } 44.22 @@ -994,11 +989,6 @@ 44.23 void release_set_methods_jmethod_ids(jmethodID* jmeths) 44.24 { OrderAccess::release_store_ptr(&_methods_jmethod_ids, jmeths); } 44.25 44.26 - int* methods_cached_itable_indices_acquire() const 44.27 - { return (int*)OrderAccess::load_ptr_acquire(&_methods_cached_itable_indices); } 44.28 - void release_set_methods_cached_itable_indices(int* indices) 44.29 - { OrderAccess::release_store_ptr(&_methods_cached_itable_indices, indices); } 44.30 - 44.31 // Lock during initialization 44.32 public: 44.33 // Lock for (1) initialization; (2) access to the ConstantPool of this class.
45.1 --- a/src/share/vm/oops/klass.cpp Sat Sep 21 10:09:42 2013 +0200 45.2 +++ b/src/share/vm/oops/klass.cpp Tue Sep 24 10:14:02 2013 +0200 45.3 @@ -674,13 +674,23 @@ 45.4 45.5 #ifndef PRODUCT 45.6 45.7 -void Klass::verify_vtable_index(int i) { 45.8 +bool Klass::verify_vtable_index(int i) { 45.9 if (oop_is_instance()) { 45.10 - assert(i>=0 && i<((InstanceKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds"); 45.11 + int limit = ((InstanceKlass*)this)->vtable_length()/vtableEntry::size(); 45.12 + assert(i >= 0 && i < limit, err_msg("index %d out of bounds %d", i, limit)); 45.13 } else { 45.14 assert(oop_is_array(), "Must be"); 45.15 - assert(i>=0 && i<((ArrayKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds"); 45.16 + int limit = ((ArrayKlass*)this)->vtable_length()/vtableEntry::size(); 45.17 + assert(i >= 0 && i < limit, err_msg("index %d out of bounds %d", i, limit)); 45.18 } 45.19 + return true; 45.20 +} 45.21 + 45.22 +bool Klass::verify_itable_index(int i) { 45.23 + assert(oop_is_instance(), ""); 45.24 + int method_count = klassItable::method_count_for_interface(this); 45.25 + assert(i >= 0 && i < method_count, "index out of bounds"); 45.26 + return true; 45.27 } 45.28 45.29 #endif
46.1 --- a/src/share/vm/oops/klass.hpp Sat Sep 21 10:09:42 2013 +0200 46.2 +++ b/src/share/vm/oops/klass.hpp Tue Sep 24 10:14:02 2013 +0200 46.3 @@ -699,7 +699,8 @@ 46.4 void verify(bool check_dictionary = true) { verify_on(tty, check_dictionary); } 46.5 46.6 #ifndef PRODUCT 46.7 - void verify_vtable_index(int index); 46.8 + bool verify_vtable_index(int index); 46.9 + bool verify_itable_index(int index); 46.10 #endif 46.11 46.12 virtual void oop_verify_on(oop obj, outputStream* st);
47.1 --- a/src/share/vm/oops/klassVtable.cpp Sat Sep 21 10:09:42 2013 +0200 47.2 +++ b/src/share/vm/oops/klassVtable.cpp Tue Sep 24 10:14:02 2013 +0200 47.3 @@ -47,11 +47,12 @@ 47.4 47.5 47.6 // this function computes the vtable size (including the size needed for miranda 47.7 -// methods) and the number of miranda methods in this class 47.8 +// methods) and the number of miranda methods in this class. 47.9 // Note on Miranda methods: Let's say there is a class C that implements 47.10 -// interface I. Let's say there is a method m in I that neither C nor any 47.11 -// of its super classes implement (i.e there is no method of any access, with 47.12 -// the same name and signature as m), then m is a Miranda method which is 47.13 +// interface I, and none of C's superclasses implements I. 47.14 +// Let's say there is an abstract method m in I that neither C 47.15 +// nor any of its super classes implement (i.e there is no method of any access, 47.16 +// with the same name and signature as m), then m is a Miranda method which is 47.17 // entered as a public abstract method in C's vtable. From then on it should 47.18 // treated as any other public method in C for method over-ride purposes. 47.19 void klassVtable::compute_vtable_size_and_num_mirandas( 47.20 @@ -111,10 +112,13 @@ 47.21 } 47.22 47.23 int klassVtable::index_of(Method* m, int len) const { 47.24 - assert(m->vtable_index() >= 0, "do not ask this of non-vtable methods"); 47.25 + assert(m->has_vtable_index(), "do not ask this of non-vtable methods"); 47.26 return m->vtable_index(); 47.27 } 47.28 47.29 +// Copy super class's vtable to the first part (prefix) of this class's vtable, 47.30 +// and return the number of entries copied. Expects that 'super' is the Java 47.31 +// super class (arrays can have "array" super classes that must be skipped). 47.32 int klassVtable::initialize_from_super(KlassHandle super) { 47.33 if (super.is_null()) { 47.34 return 0; 47.35 @@ -139,14 +143,14 @@ 47.36 } 47.37 } 47.38 47.39 -// Revised lookup semantics introduced 1.3 (Kestral beta) 47.40 +// 47.41 +// Revised lookup semantics introduced 1.3 (Kestrel beta) 47.42 void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) { 47.43 47.44 // Note: Arrays can have intermediate array supers. Use java_super to skip them. 47.45 KlassHandle super (THREAD, klass()->java_super()); 47.46 int nofNewEntries = 0; 47.47 47.48 - 47.49 if (PrintVtables && !klass()->oop_is_array()) { 47.50 ResourceMark rm(THREAD); 47.51 tty->print_cr("Initializing: %s", _klass->name()->as_C_string()); 47.52 @@ -174,8 +178,10 @@ 47.53 int len = methods->length(); 47.54 int initialized = super_vtable_len; 47.55 47.56 - // update_inherited_vtable can stop for gc - ensure using handles 47.57 + // Check each of this class's methods against super; 47.58 + // if override, replace in copy of super vtable, otherwise append to end 47.59 for (int i = 0; i < len; i++) { 47.60 + // update_inherited_vtable can stop for gc - ensure using handles 47.61 HandleMark hm(THREAD); 47.62 assert(methods->at(i)->is_method(), "must be a Method*"); 47.63 methodHandle mh(THREAD, methods->at(i)); 47.64 @@ -189,11 +195,11 @@ 47.65 } 47.66 } 47.67 47.68 - // add miranda methods; it will also update the value of initialized 47.69 - fill_in_mirandas(&initialized); 47.70 + // add miranda methods to end of vtable. 47.71 + initialized = fill_in_mirandas(initialized); 47.72 47.73 // In class hierarchies where the accessibility is not increasing (i.e., going from private -> 47.74 - // package_private -> publicprotected), the vtable might actually be smaller than our initial 47.75 + // package_private -> public/protected), the vtable might actually be smaller than our initial 47.76 // calculation. 47.77 assert(initialized <= _length, "vtable initialization failed"); 47.78 for(;initialized < _length; initialized++) { 47.79 @@ -248,14 +254,8 @@ 47.80 return superk; 47.81 } 47.82 47.83 -// Methods that are "effectively" final don't need vtable entries. 47.84 -bool method_is_effectively_final( 47.85 - AccessFlags klass_flags, methodHandle target) { 47.86 - return target->is_final() || klass_flags.is_final() && !target->is_overpass(); 47.87 -} 47.88 - 47.89 // Update child's copy of super vtable for overrides 47.90 -// OR return true if a new vtable entry is required 47.91 +// OR return true if a new vtable entry is required. 47.92 // Only called for InstanceKlass's, i.e. not for arrays 47.93 // If that changed, could not use _klass as handle for klass 47.94 bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method, int super_vtable_len, 47.95 @@ -263,6 +263,7 @@ 47.96 ResourceMark rm; 47.97 bool allocate_new = true; 47.98 assert(klass->oop_is_instance(), "must be InstanceKlass"); 47.99 + assert(klass == target_method()->method_holder(), "caller resp."); 47.100 47.101 // Initialize the method's vtable index to "nonvirtual". 47.102 // If we allocate a vtable entry, we will update it to a non-negative number. 47.103 @@ -273,11 +274,17 @@ 47.104 return false; 47.105 } 47.106 47.107 - if (method_is_effectively_final(klass->access_flags(), target_method)) { 47.108 + if (target_method->is_final_method(klass->access_flags())) { 47.109 // a final method never needs a new entry; final methods can be statically 47.110 // resolved and they have to be present in the vtable only if they override 47.111 // a super's method, in which case they re-use its entry 47.112 allocate_new = false; 47.113 + } else if (klass->is_interface()) { 47.114 + allocate_new = false; // see note below in needs_new_vtable_entry 47.115 + // An interface never allocates new vtable slots, only inherits old ones. 47.116 + // This method will either be assigned its own itable index later, 47.117 + // or be assigned an inherited vtable index in the loop below. 47.118 + target_method()->set_vtable_index(Method::pending_itable_index); 47.119 } 47.120 47.121 // we need a new entry if there is no superclass 47.122 @@ -411,8 +418,14 @@ 47.123 Symbol* classname, 47.124 AccessFlags class_flags, 47.125 TRAPS) { 47.126 + if (class_flags.is_interface()) { 47.127 + // Interfaces do not use vtables, so there is no point to assigning 47.128 + // a vtable index to any of their methods. If we refrain from doing this, 47.129 + // we can use Method::_vtable_index to hold the itable index 47.130 + return false; 47.131 + } 47.132 47.133 - if (method_is_effectively_final(class_flags, target_method) || 47.134 + if (target_method->is_final_method(class_flags) || 47.135 // a final method never needs a new entry; final methods can be statically 47.136 // resolved and they have to be present in the vtable only if they override 47.137 // a super's method, in which case they re-use its entry 47.138 @@ -500,7 +513,8 @@ 47.139 return Method::invalid_vtable_index; 47.140 } 47.141 47.142 -// check if an entry is miranda 47.143 +// check if an entry at an index is miranda 47.144 +// requires that method m at entry be declared ("held") by an interface. 47.145 bool klassVtable::is_miranda_entry_at(int i) { 47.146 Method* m = method_at(i); 47.147 Klass* method_holder = m->method_holder(); 47.148 @@ -516,7 +530,9 @@ 47.149 return false; 47.150 } 47.151 47.152 -// check if a method is a miranda method, given a class's methods table and it's super 47.153 +// check if a method is a miranda method, given a class's methods table and its super 47.154 +// "miranda" means not static, not defined by this class, and not defined 47.155 +// in super unless it is private and therefore inaccessible to this class. 47.156 // the caller must make sure that the method belongs to an interface implemented by the class 47.157 bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods, Klass* super) { 47.158 if (m->is_static()) { 47.159 @@ -541,6 +557,14 @@ 47.160 return false; 47.161 } 47.162 47.163 +// Scans current_interface_methods for miranda methods that do not 47.164 +// already appear in new_mirandas and are also not defined-and-non-private 47.165 +// in super (superclass). These mirandas are added to all_mirandas if it is 47.166 +// not null; in addition, those that are not duplicates of miranda methods 47.167 +// inherited by super from its interfaces are added to new_mirandas. 47.168 +// Thus, new_mirandas will be the set of mirandas that this class introduces, 47.169 +// all_mirandas will be the set of all mirandas applicable to this class 47.170 +// including all defined in superclasses. 47.171 void klassVtable::add_new_mirandas_to_lists( 47.172 GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas, 47.173 Array<Method*>* current_interface_methods, Array<Method*>* class_methods, 47.174 @@ -599,17 +623,22 @@ 47.175 } 47.176 } 47.177 47.178 -// fill in mirandas 47.179 -void klassVtable::fill_in_mirandas(int* initialized) { 47.180 +// Discover miranda methods ("miranda" = "interface abstract, no binding"), 47.181 +// and append them into the vtable starting at index initialized, 47.182 +// return the new value of initialized. 47.183 +int klassVtable::fill_in_mirandas(int initialized) { 47.184 GrowableArray<Method*> mirandas(20); 47.185 get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(), 47.186 ik()->local_interfaces()); 47.187 for (int i = 0; i < mirandas.length(); i++) { 47.188 - put_method_at(mirandas.at(i), *initialized); 47.189 - ++(*initialized); 47.190 + put_method_at(mirandas.at(i), initialized); 47.191 + ++initialized; 47.192 } 47.193 + return initialized; 47.194 } 47.195 47.196 +// Copy this class's vtable to the vtable beginning at start. 47.197 +// Used to copy superclass vtable to prefix of subclass's vtable. 47.198 void klassVtable::copy_vtable_to(vtableEntry* start) { 47.199 Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size()); 47.200 } 47.201 @@ -723,6 +752,12 @@ 47.202 47.203 // Initialization 47.204 void klassItable::initialize_itable(bool checkconstraints, TRAPS) { 47.205 + if (_klass->is_interface()) { 47.206 + // This needs to go after vtable indexes are assigned but 47.207 + // before implementors need to know the number of itable indexes. 47.208 + assign_itable_indexes_for_interface(_klass()); 47.209 + } 47.210 + 47.211 // Cannot be setup doing bootstrapping, interfaces don't have 47.212 // itables, and klass with only ones entry have empty itables 47.213 if (Universe::is_bootstrapping() || 47.214 @@ -754,45 +789,89 @@ 47.215 } 47.216 47.217 47.218 +inline bool interface_method_needs_itable_index(Method* m) { 47.219 + if (m->is_static()) return false; // e.g., Stream.empty 47.220 + if (m->is_initializer()) return false; // <init> or <clinit> 47.221 + // If an interface redeclares a method from java.lang.Object, 47.222 + // it should already have a vtable index, don't touch it. 47.223 + // e.g., CharSequence.toString (from initialize_vtable) 47.224 + // if (m->has_vtable_index()) return false; // NO! 47.225 + return true; 47.226 +} 47.227 + 47.228 +int klassItable::assign_itable_indexes_for_interface(Klass* klass) { 47.229 + // an interface does not have an itable, but its methods need to be numbered 47.230 + if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count, 47.231 + klass->name()->as_C_string()); 47.232 + Array<Method*>* methods = InstanceKlass::cast(klass)->methods(); 47.233 + int nof_methods = methods->length(); 47.234 + int ime_num = 0; 47.235 + for (int i = 0; i < nof_methods; i++) { 47.236 + Method* m = methods->at(i); 47.237 + if (interface_method_needs_itable_index(m)) { 47.238 + assert(!m->is_final_method(), "no final interface methods"); 47.239 + // If m is already assigned a vtable index, do not disturb it. 47.240 + if (!m->has_vtable_index()) { 47.241 + assert(m->vtable_index() == Method::pending_itable_index, "set by initialize_vtable"); 47.242 + m->set_itable_index(ime_num); 47.243 + // Progress to next itable entry 47.244 + ime_num++; 47.245 + } 47.246 + } 47.247 + } 47.248 + assert(ime_num == method_count_for_interface(klass), "proper sizing"); 47.249 + return ime_num; 47.250 +} 47.251 + 47.252 +int klassItable::method_count_for_interface(Klass* interf) { 47.253 + assert(interf->oop_is_instance(), "must be"); 47.254 + assert(interf->is_interface(), "must be"); 47.255 + Array<Method*>* methods = InstanceKlass::cast(interf)->methods(); 47.256 + int nof_methods = methods->length(); 47.257 + while (nof_methods > 0) { 47.258 + Method* m = methods->at(nof_methods-1); 47.259 + if (m->has_itable_index()) { 47.260 + int length = m->itable_index() + 1; 47.261 +#ifdef ASSERT 47.262 + while (nof_methods = 0) { 47.263 + m = methods->at(--nof_methods); 47.264 + assert(!m->has_itable_index() || m->itable_index() < length, ""); 47.265 + } 47.266 +#endif //ASSERT 47.267 + return length; // return the rightmost itable index, plus one 47.268 + } 47.269 + nof_methods -= 1; 47.270 + } 47.271 + // no methods have itable indexes 47.272 + return 0; 47.273 +} 47.274 + 47.275 + 47.276 void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) { 47.277 Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods(); 47.278 int nof_methods = methods->length(); 47.279 HandleMark hm; 47.280 - KlassHandle klass = _klass; 47.281 assert(nof_methods > 0, "at least one method must exist for interface to be in vtable"); 47.282 Handle interface_loader (THREAD, InstanceKlass::cast(interf_h())->class_loader()); 47.283 - int ime_num = 0; 47.284 47.285 - // Skip first Method* if it is a class initializer 47.286 - int i = methods->at(0)->is_static_initializer() ? 1 : 0; 47.287 - 47.288 - // m, method_name, method_signature, klass reset each loop so they 47.289 - // don't need preserving across check_signature_loaders call 47.290 - // methods needs a handle in case of gc from check_signature_loaders 47.291 - for(; i < nof_methods; i++) { 47.292 + int ime_count = method_count_for_interface(interf_h()); 47.293 + for (int i = 0; i < nof_methods; i++) { 47.294 Method* m = methods->at(i); 47.295 - Symbol* method_name = m->name(); 47.296 - Symbol* method_signature = m->signature(); 47.297 - 47.298 - // This is same code as in Linkresolver::lookup_instance_method_in_klasses 47.299 - Method* target = klass->uncached_lookup_method(method_name, method_signature); 47.300 - while (target != NULL && target->is_static()) { 47.301 - // continue with recursive lookup through the superclass 47.302 - Klass* super = target->method_holder()->super(); 47.303 - target = (super == NULL) ? (Method*)NULL : super->uncached_lookup_method(method_name, method_signature); 47.304 + methodHandle target; 47.305 + if (m->has_itable_index()) { 47.306 + LinkResolver::lookup_instance_method_in_klasses(target, _klass, m->name(), m->signature(), CHECK); 47.307 } 47.308 if (target == NULL || !target->is_public() || target->is_abstract()) { 47.309 // Entry do not resolve. Leave it empty 47.310 } else { 47.311 // Entry did resolve, check loader constraints before initializing 47.312 // if checkconstraints requested 47.313 - methodHandle target_h (THREAD, target); // preserve across gc 47.314 if (checkconstraints) { 47.315 Handle method_holder_loader (THREAD, target->method_holder()->class_loader()); 47.316 if (method_holder_loader() != interface_loader()) { 47.317 ResourceMark rm(THREAD); 47.318 Symbol* failed_type_symbol = 47.319 - SystemDictionary::check_signature_loaders(method_signature, 47.320 + SystemDictionary::check_signature_loaders(m->signature(), 47.321 method_holder_loader, 47.322 interface_loader, 47.323 true, CHECK); 47.324 @@ -803,9 +882,9 @@ 47.325 "and the class loader (instance of %s) for interface " 47.326 "%s have different Class objects for the type %s " 47.327 "used in the signature"; 47.328 - char* sig = target_h()->name_and_sig_as_C_string(); 47.329 + char* sig = target()->name_and_sig_as_C_string(); 47.330 const char* loader1 = SystemDictionary::loader_name(method_holder_loader()); 47.331 - char* current = klass->name()->as_C_string(); 47.332 + char* current = _klass->name()->as_C_string(); 47.333 const char* loader2 = SystemDictionary::loader_name(interface_loader()); 47.334 char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); 47.335 char* failed_type_name = failed_type_symbol->as_C_string(); 47.336 @@ -821,10 +900,10 @@ 47.337 } 47.338 47.339 // ime may have moved during GC so recalculate address 47.340 - itableOffsetEntry::method_entry(_klass(), method_table_offset)[ime_num].initialize(target_h()); 47.341 + int ime_num = m->itable_index(); 47.342 + assert(ime_num < ime_count, "oob"); 47.343 + itableOffsetEntry::method_entry(_klass(), method_table_offset)[ime_num].initialize(target()); 47.344 } 47.345 - // Progress to next entry 47.346 - ime_num++; 47.347 } 47.348 } 47.349 47.350 @@ -913,20 +992,22 @@ 47.351 virtual void doit(Klass* intf, int method_count) = 0; 47.352 }; 47.353 47.354 -// Visit all interfaces with at-least one method (excluding <clinit>) 47.355 +// Visit all interfaces with at least one itable method 47.356 void visit_all_interfaces(Array<Klass*>* transitive_intf, InterfaceVisiterClosure *blk) { 47.357 // Handle array argument 47.358 for(int i = 0; i < transitive_intf->length(); i++) { 47.359 Klass* intf = transitive_intf->at(i); 47.360 assert(intf->is_interface(), "sanity check"); 47.361 47.362 - // Find no. of methods excluding a <clinit> 47.363 - int method_count = InstanceKlass::cast(intf)->methods()->length(); 47.364 - if (method_count > 0) { 47.365 - Method* m = InstanceKlass::cast(intf)->methods()->at(0); 47.366 - assert(m != NULL && m->is_method(), "sanity check"); 47.367 - if (m->name() == vmSymbols::object_initializer_name()) { 47.368 - method_count--; 47.369 + // Find no. of itable methods 47.370 + int method_count = 0; 47.371 + // method_count = klassItable::method_count_for_interface(intf); 47.372 + Array<Method*>* methods = InstanceKlass::cast(intf)->methods(); 47.373 + if (methods->length() > 0) { 47.374 + for (int i = methods->length(); --i >= 0; ) { 47.375 + if (interface_method_needs_itable_index(methods->at(i))) { 47.376 + method_count++; 47.377 + } 47.378 } 47.379 } 47.380 47.381 @@ -1024,40 +1105,26 @@ 47.382 } 47.383 47.384 47.385 -// m must be a method in an interface 47.386 -int klassItable::compute_itable_index(Method* m) { 47.387 - InstanceKlass* intf = m->method_holder(); 47.388 - assert(intf->is_interface(), "sanity check"); 47.389 - Array<Method*>* methods = intf->methods(); 47.390 - int index = 0; 47.391 - while(methods->at(index) != m) { 47.392 - index++; 47.393 - assert(index < methods->length(), "should find index for resolve_invoke"); 47.394 - } 47.395 - // Adjust for <clinit>, which is left out of table if first method 47.396 - if (methods->length() > 0 && methods->at(0)->is_static_initializer()) { 47.397 - index--; 47.398 - } 47.399 - return index; 47.400 -} 47.401 - 47.402 - 47.403 -// inverse to compute_itable_index 47.404 +// inverse to itable_index 47.405 Method* klassItable::method_for_itable_index(Klass* intf, int itable_index) { 47.406 assert(InstanceKlass::cast(intf)->is_interface(), "sanity check"); 47.407 + assert(intf->verify_itable_index(itable_index), ""); 47.408 Array<Method*>* methods = InstanceKlass::cast(intf)->methods(); 47.409 47.410 - int index = itable_index; 47.411 - // Adjust for <clinit>, which is left out of table if first method 47.412 - if (methods->length() > 0 && methods->at(0)->is_static_initializer()) { 47.413 - index++; 47.414 - } 47.415 - 47.416 - if (itable_index < 0 || index >= methods->length()) 47.417 + if (itable_index < 0 || itable_index >= method_count_for_interface(intf)) 47.418 return NULL; // help caller defend against bad indexes 47.419 47.420 + int index = itable_index; 47.421 Method* m = methods->at(index); 47.422 - assert(compute_itable_index(m) == itable_index, "correct inverse"); 47.423 + int index2 = -1; 47.424 + while (!m->has_itable_index() || 47.425 + (index2 = m->itable_index()) != itable_index) { 47.426 + assert(index2 < itable_index, "monotonic"); 47.427 + if (++index == methods->length()) 47.428 + return NULL; 47.429 + m = methods->at(index); 47.430 + } 47.431 + assert(m->itable_index() == itable_index, "correct inverse"); 47.432 47.433 return m; 47.434 }
48.1 --- a/src/share/vm/oops/klassVtable.hpp Sat Sep 21 10:09:42 2013 +0200 48.2 +++ b/src/share/vm/oops/klassVtable.hpp Tue Sep 24 10:14:02 2013 +0200 48.3 @@ -124,7 +124,7 @@ 48.4 48.5 // support for miranda methods 48.6 bool is_miranda_entry_at(int i); 48.7 - void fill_in_mirandas(int* initialized); 48.8 + int fill_in_mirandas(int initialized); 48.9 static bool is_miranda(Method* m, Array<Method*>* class_methods, Klass* super); 48.10 static void add_new_mirandas_to_lists( 48.11 GrowableArray<Method*>* new_mirandas, 48.12 @@ -150,6 +150,8 @@ 48.13 // from_compiled_code_entry_point -> nmethod entry point 48.14 // from_interpreter_entry_point -> i2cadapter 48.15 class vtableEntry VALUE_OBJ_CLASS_SPEC { 48.16 + friend class VMStructs; 48.17 + 48.18 public: 48.19 // size in words 48.20 static int size() { 48.21 @@ -288,12 +290,12 @@ 48.22 #endif // INCLUDE_JVMTI 48.23 48.24 // Setup of itable 48.25 + static int assign_itable_indexes_for_interface(Klass* klass); 48.26 + static int method_count_for_interface(Klass* klass); 48.27 static int compute_itable_size(Array<Klass*>* transitive_interfaces); 48.28 static void setup_itable_offset_table(instanceKlassHandle klass); 48.29 48.30 // Resolving of method to index 48.31 - static int compute_itable_index(Method* m); 48.32 - // ...and back again: 48.33 static Method* method_for_itable_index(Klass* klass, int itable_index); 48.34 48.35 // Debugging/Statistics
49.1 --- a/src/share/vm/oops/method.cpp Sat Sep 21 10:09:42 2013 +0200 49.2 +++ b/src/share/vm/oops/method.cpp Tue Sep 24 10:14:02 2013 +0200 49.3 @@ -509,24 +509,31 @@ 49.4 return _access_flags.has_loops(); 49.5 } 49.6 49.7 +bool Method::is_final_method(AccessFlags class_access_flags) const { 49.8 + // or "does_not_require_vtable_entry" 49.9 + // overpass can occur, is not final (reuses vtable entry) 49.10 + // private methods get vtable entries for backward class compatibility. 49.11 + if (is_overpass()) return false; 49.12 + return is_final() || class_access_flags.is_final(); 49.13 +} 49.14 49.15 bool Method::is_final_method() const { 49.16 - // %%% Should return true for private methods also, 49.17 - // since there is no way to override them. 49.18 - return is_final() || method_holder()->is_final(); 49.19 + return is_final_method(method_holder()->access_flags()); 49.20 } 49.21 49.22 - 49.23 -bool Method::is_strict_method() const { 49.24 - return is_strict(); 49.25 -} 49.26 - 49.27 - 49.28 -bool Method::can_be_statically_bound() const { 49.29 - if (is_final_method()) return true; 49.30 +bool Method::can_be_statically_bound(AccessFlags class_access_flags) const { 49.31 + if (is_final_method(class_access_flags)) return true; 49.32 +#ifdef ASSERT 49.33 + bool is_nonv = (vtable_index() == nonvirtual_vtable_index); 49.34 + if (class_access_flags.is_interface()) assert(is_nonv == is_static(), err_msg("is_nonv=%s", is_nonv)); 49.35 +#endif 49.36 + assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question"); 49.37 return vtable_index() == nonvirtual_vtable_index; 49.38 } 49.39 49.40 +bool Method::can_be_statically_bound() const { 49.41 + return can_be_statically_bound(method_holder()->access_flags()); 49.42 +} 49.43 49.44 bool Method::is_accessor() const { 49.45 if (code_size() != 5) return false; 49.46 @@ -967,7 +974,7 @@ 49.47 49.48 assert(ik->is_subclass_of(method_holder()), "should be subklass"); 49.49 assert(ik->vtable() != NULL, "vtable should exist"); 49.50 - if (vtable_index() == nonvirtual_vtable_index) { 49.51 + if (!has_vtable_index()) { 49.52 return false; 49.53 } else { 49.54 Method* vt_m = ik->method_at_vtable(vtable_index()); 49.55 @@ -1959,7 +1966,7 @@ 49.56 49.57 void Method::print_value_on(outputStream* st) const { 49.58 assert(is_method(), "must be method"); 49.59 - st->print_cr(internal_name()); 49.60 + st->print(internal_name()); 49.61 print_address_on(st); 49.62 st->print(" "); 49.63 name()->print_value_on(st); 49.64 @@ -1967,6 +1974,7 @@ 49.65 signature()->print_value_on(st); 49.66 st->print(" in "); 49.67 method_holder()->print_value_on(st); 49.68 + if (WizardMode) st->print("#%d", _vtable_index); 49.69 if (WizardMode) st->print("[%d,%d]", size_of_parameters(), max_locals()); 49.70 if (WizardMode && code() != NULL) st->print(" ((nmethod*)%p)", code()); 49.71 }
50.1 --- a/src/share/vm/oops/method.hpp Sat Sep 21 10:09:42 2013 +0200 50.2 +++ b/src/share/vm/oops/method.hpp Tue Sep 24 10:14:02 2013 +0200 50.3 @@ -448,16 +448,22 @@ 50.4 enum VtableIndexFlag { 50.5 // Valid vtable indexes are non-negative (>= 0). 50.6 // These few negative values are used as sentinels. 50.7 - highest_unused_vtable_index_value = -5, 50.8 + itable_index_max = -10, // first itable index, growing downward 50.9 + pending_itable_index = -9, // itable index will be assigned 50.10 invalid_vtable_index = -4, // distinct from any valid vtable index 50.11 garbage_vtable_index = -3, // not yet linked; no vtable layout yet 50.12 nonvirtual_vtable_index = -2 // there is no need for vtable dispatch 50.13 // 6330203 Note: Do not use -1, which was overloaded with many meanings. 50.14 }; 50.15 DEBUG_ONLY(bool valid_vtable_index() const { return _vtable_index >= nonvirtual_vtable_index; }) 50.16 - int vtable_index() const { assert(valid_vtable_index(), ""); 50.17 - return _vtable_index; } 50.18 + bool has_vtable_index() const { return _vtable_index >= 0; } 50.19 + int vtable_index() const { return _vtable_index; } 50.20 void set_vtable_index(int index) { _vtable_index = index; } 50.21 + DEBUG_ONLY(bool valid_itable_index() const { return _vtable_index <= pending_itable_index; }) 50.22 + bool has_itable_index() const { return _vtable_index <= itable_index_max; } 50.23 + int itable_index() const { assert(valid_itable_index(), ""); 50.24 + return itable_index_max - _vtable_index; } 50.25 + void set_itable_index(int index) { _vtable_index = itable_index_max - index; assert(valid_itable_index(), ""); } 50.26 50.27 // interpreter entry 50.28 address interpreter_entry() const { return _i2i_entry; } 50.29 @@ -560,10 +566,11 @@ 50.30 50.31 // checks method and its method holder 50.32 bool is_final_method() const; 50.33 - bool is_strict_method() const; 50.34 + bool is_final_method(AccessFlags class_access_flags) const; 50.35 50.36 // true if method needs no dynamic dispatch (final and/or no vtable entry) 50.37 bool can_be_statically_bound() const; 50.38 + bool can_be_statically_bound(AccessFlags class_access_flags) const; 50.39 50.40 // returns true if the method has any backward branches. 50.41 bool has_loops() { 50.42 @@ -740,10 +747,6 @@ 50.43 // so handles are not used to avoid deadlock. 50.44 jmethodID find_jmethod_id_or_null() { return method_holder()->jmethod_id_or_null(this); } 50.45 50.46 - // JNI static invoke cached itable index accessors 50.47 - int cached_itable_index() { return method_holder()->cached_itable_index(method_idnum()); } 50.48 - void set_cached_itable_index(int index) { method_holder()->set_cached_itable_index(method_idnum(), index); } 50.49 - 50.50 // Support for inlining of intrinsic methods 50.51 vmIntrinsics::ID intrinsic_id() const { return (vmIntrinsics::ID) _intrinsic_id; } 50.52 void set_intrinsic_id(vmIntrinsics::ID id) { _intrinsic_id = (u1) id; }
51.1 --- a/src/share/vm/oops/methodData.hpp Sat Sep 21 10:09:42 2013 +0200 51.2 +++ b/src/share/vm/oops/methodData.hpp Tue Sep 24 10:14:02 2013 +0200 51.3 @@ -72,6 +72,8 @@ 51.4 // 51.5 // Overlay for generic profiling data. 51.6 class DataLayout VALUE_OBJ_CLASS_SPEC { 51.7 + friend class VMStructs; 51.8 + 51.9 private: 51.10 // Every data layout begins with a header. This header 51.11 // contains a tag, which is used to indicate the size/layout
52.1 --- a/src/share/vm/oops/symbol.hpp Sat Sep 21 10:09:42 2013 +0200 52.2 +++ b/src/share/vm/oops/symbol.hpp Tue Sep 24 10:14:02 2013 +0200 52.3 @@ -45,7 +45,7 @@ 52.4 // in the SymbolTable bucket (the _literal field in HashtableEntry) 52.5 // that points to the Symbol. All other stores of a Symbol* 52.6 // to a field of a persistent variable (e.g., the _name filed in 52.7 -// FieldAccessInfo or _ptr in a CPSlot) is reference counted. 52.8 +// fieldDescriptor or _ptr in a CPSlot) is reference counted. 52.9 // 52.10 // 1) The lookup of a "name" in the SymbolTable either creates a Symbol F for 52.11 // "name" and returns a pointer to F or finds a pre-existing Symbol F for
53.1 --- a/src/share/vm/opto/chaitin.cpp Sat Sep 21 10:09:42 2013 +0200 53.2 +++ b/src/share/vm/opto/chaitin.cpp Tue Sep 24 10:14:02 2013 +0200 53.3 @@ -122,40 +122,23 @@ 53.4 return score; 53.5 } 53.6 53.7 -LRG_List::LRG_List( uint max ) : _cnt(max), _max(max), _lidxs(NEW_RESOURCE_ARRAY(uint,max)) { 53.8 - memset( _lidxs, 0, sizeof(uint)*max ); 53.9 -} 53.10 - 53.11 -void LRG_List::extend( uint nidx, uint lidx ) { 53.12 - _nesting.check(); 53.13 - if( nidx >= _max ) { 53.14 - uint size = 16; 53.15 - while( size <= nidx ) size <<=1; 53.16 - _lidxs = REALLOC_RESOURCE_ARRAY( uint, _lidxs, _max, size ); 53.17 - _max = size; 53.18 - } 53.19 - while( _cnt <= nidx ) 53.20 - _lidxs[_cnt++] = 0; 53.21 - _lidxs[nidx] = lidx; 53.22 -} 53.23 - 53.24 #define NUMBUCKS 3 53.25 53.26 // Straight out of Tarjan's union-find algorithm 53.27 uint LiveRangeMap::find_compress(uint lrg) { 53.28 uint cur = lrg; 53.29 - uint next = _uf_map[cur]; 53.30 + uint next = _uf_map.at(cur); 53.31 while (next != cur) { // Scan chain of equivalences 53.32 assert( next < cur, "always union smaller"); 53.33 cur = next; // until find a fixed-point 53.34 - next = _uf_map[cur]; 53.35 + next = _uf_map.at(cur); 53.36 } 53.37 53.38 // Core of union-find algorithm: update chain of 53.39 // equivalences to be equal to the root. 53.40 while (lrg != next) { 53.41 - uint tmp = _uf_map[lrg]; 53.42 - _uf_map.map(lrg, next); 53.43 + uint tmp = _uf_map.at(lrg); 53.44 + _uf_map.at_put(lrg, next); 53.45 lrg = tmp; 53.46 } 53.47 return lrg; 53.48 @@ -165,10 +148,10 @@ 53.49 void LiveRangeMap::reset_uf_map(uint max_lrg_id) { 53.50 _max_lrg_id= max_lrg_id; 53.51 // Force the Union-Find mapping to be at least this large 53.52 - _uf_map.extend(_max_lrg_id, 0); 53.53 + _uf_map.at_put_grow(_max_lrg_id, 0); 53.54 // Initialize it to be the ID mapping. 53.55 for (uint i = 0; i < _max_lrg_id; ++i) { 53.56 - _uf_map.map(i, i); 53.57 + _uf_map.at_put(i, i); 53.58 } 53.59 } 53.60 53.61 @@ -176,12 +159,12 @@ 53.62 // the Union-Find mapping after this call. 53.63 void LiveRangeMap::compress_uf_map_for_nodes() { 53.64 // For all Nodes, compress mapping 53.65 - uint unique = _names.Size(); 53.66 + uint unique = _names.length(); 53.67 for (uint i = 0; i < unique; ++i) { 53.68 - uint lrg = _names[i]; 53.69 + uint lrg = _names.at(i); 53.70 uint compressed_lrg = find(lrg); 53.71 if (lrg != compressed_lrg) { 53.72 - _names.map(i, compressed_lrg); 53.73 + _names.at_put(i, compressed_lrg); 53.74 } 53.75 } 53.76 } 53.77 @@ -198,11 +181,11 @@ 53.78 return lrg; 53.79 } 53.80 53.81 - uint next = _uf_map[lrg]; 53.82 + uint next = _uf_map.at(lrg); 53.83 while (next != lrg) { // Scan chain of equivalences 53.84 assert(next < lrg, "always union smaller"); 53.85 lrg = next; // until find a fixed-point 53.86 - next = _uf_map[lrg]; 53.87 + next = _uf_map.at(lrg); 53.88 } 53.89 return next; 53.90 } 53.91 @@ -215,7 +198,7 @@ 53.92 NULL 53.93 #endif 53.94 ) 53.95 - , _lrg_map(unique) 53.96 + , _lrg_map(Thread::current()->resource_area(), unique) 53.97 , _live(0) 53.98 , _spilled_once(Thread::current()->resource_area()) 53.99 , _spilled_twice(Thread::current()->resource_area()) 53.100 @@ -692,6 +675,7 @@ 53.101 _lrg_map.map(n->_idx, rm.is_NotEmpty() ? lr_counter++ : 0); 53.102 } 53.103 } 53.104 + 53.105 // Reset the Union-Find mapping to be identity 53.106 _lrg_map.reset_uf_map(lr_counter); 53.107 }
54.1 --- a/src/share/vm/opto/chaitin.hpp Sat Sep 21 10:09:42 2013 +0200 54.2 +++ b/src/share/vm/opto/chaitin.hpp Tue Sep 24 10:14:02 2013 +0200 54.3 @@ -283,8 +283,8 @@ 54.4 54.5 // Straight out of Tarjan's union-find algorithm 54.6 uint find_compress(const Node *node) { 54.7 - uint lrg_id = find_compress(_names[node->_idx]); 54.8 - _names.map(node->_idx, lrg_id); 54.9 + uint lrg_id = find_compress(_names.at(node->_idx)); 54.10 + _names.at_put(node->_idx, lrg_id); 54.11 return lrg_id; 54.12 } 54.13 54.14 @@ -305,40 +305,40 @@ 54.15 } 54.16 54.17 uint size() const { 54.18 - return _names.Size(); 54.19 + return _names.length(); 54.20 } 54.21 54.22 uint live_range_id(uint idx) const { 54.23 - return _names[idx]; 54.24 + return _names.at(idx); 54.25 } 54.26 54.27 uint live_range_id(const Node *node) const { 54.28 - return _names[node->_idx]; 54.29 + return _names.at(node->_idx); 54.30 } 54.31 54.32 uint uf_live_range_id(uint lrg_id) const { 54.33 - return _uf_map[lrg_id]; 54.34 + return _uf_map.at(lrg_id); 54.35 } 54.36 54.37 void map(uint idx, uint lrg_id) { 54.38 - _names.map(idx, lrg_id); 54.39 + _names.at_put(idx, lrg_id); 54.40 } 54.41 54.42 void uf_map(uint dst_lrg_id, uint src_lrg_id) { 54.43 - _uf_map.map(dst_lrg_id, src_lrg_id); 54.44 + _uf_map.at_put(dst_lrg_id, src_lrg_id); 54.45 } 54.46 54.47 void extend(uint idx, uint lrg_id) { 54.48 - _names.extend(idx, lrg_id); 54.49 + _names.at_put_grow(idx, lrg_id); 54.50 } 54.51 54.52 void uf_extend(uint dst_lrg_id, uint src_lrg_id) { 54.53 - _uf_map.extend(dst_lrg_id, src_lrg_id); 54.54 + _uf_map.at_put_grow(dst_lrg_id, src_lrg_id); 54.55 } 54.56 54.57 - LiveRangeMap(uint unique) 54.58 - : _names(unique) 54.59 - , _uf_map(unique) 54.60 + LiveRangeMap(Arena* arena, uint unique) 54.61 + : _names(arena, unique, unique, 0) 54.62 + , _uf_map(arena, unique, unique, 0) 54.63 , _max_lrg_id(0) {} 54.64 54.65 uint find_id( const Node *n ) { 54.66 @@ -355,14 +355,14 @@ 54.67 void compress_uf_map_for_nodes(); 54.68 54.69 uint find(uint lidx) { 54.70 - uint uf_lidx = _uf_map[lidx]; 54.71 + uint uf_lidx = _uf_map.at(lidx); 54.72 return (uf_lidx == lidx) ? uf_lidx : find_compress(lidx); 54.73 } 54.74 54.75 // Convert a Node into a Live Range Index - a lidx 54.76 uint find(const Node *node) { 54.77 uint lidx = live_range_id(node); 54.78 - uint uf_lidx = _uf_map[lidx]; 54.79 + uint uf_lidx = _uf_map.at(lidx); 54.80 return (uf_lidx == lidx) ? uf_lidx : find_compress(node); 54.81 } 54.82 54.83 @@ -371,10 +371,10 @@ 54.84 54.85 // Like Find above, but no path compress, so bad asymptotic behavior 54.86 uint find_const(const Node *node) const { 54.87 - if(node->_idx >= _names.Size()) { 54.88 + if(node->_idx >= (uint)_names.length()) { 54.89 return 0; // not mapped, usual for debug dump 54.90 } 54.91 - return find_const(_names[node->_idx]); 54.92 + return find_const(_names.at(node->_idx)); 54.93 } 54.94 }; 54.95
55.1 --- a/src/share/vm/opto/coalesce.hpp Sat Sep 21 10:09:42 2013 +0200 55.2 +++ b/src/share/vm/opto/coalesce.hpp Tue Sep 24 10:14:02 2013 +0200 55.3 @@ -29,7 +29,6 @@ 55.4 55.5 class LoopTree; 55.6 class LRG; 55.7 -class LRG_List; 55.8 class Matcher; 55.9 class PhaseIFG; 55.10 class PhaseCFG;
56.1 --- a/src/share/vm/opto/library_call.cpp Sat Sep 21 10:09:42 2013 +0200 56.2 +++ b/src/share/vm/opto/library_call.cpp Tue Sep 24 10:14:02 2013 +0200 56.3 @@ -3734,6 +3734,8 @@ 56.4 RegionNode* slow_region) { 56.5 ciMethod* method = callee(); 56.6 int vtable_index = method->vtable_index(); 56.7 + assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, 56.8 + err_msg_res("bad index %d", vtable_index)); 56.9 // Get the Method* out of the appropriate vtable entry. 56.10 int entry_offset = (InstanceKlass::vtable_start_offset() + 56.11 vtable_index*vtableEntry::size()) * wordSize + 56.12 @@ -3784,6 +3786,8 @@ 56.13 // so the vtable index is fixed. 56.14 // No need to use the linkResolver to get it. 56.15 vtable_index = method->vtable_index(); 56.16 + assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, 56.17 + err_msg_res("bad index %d", vtable_index)); 56.18 } 56.19 slow_call = new(C) CallDynamicJavaNode(tf, 56.20 SharedRuntime::get_resolve_virtual_call_stub(),
57.1 --- a/src/share/vm/opto/live.cpp Sat Sep 21 10:09:42 2013 +0200 57.2 +++ b/src/share/vm/opto/live.cpp Tue Sep 24 10:14:02 2013 +0200 57.3 @@ -91,7 +91,7 @@ 57.4 break; 57.5 } 57.6 57.7 - uint r = _names[n->_idx]; 57.8 + uint r = _names.at(n->_idx); 57.9 assert(!def_outside->member(r), "Use of external LRG overlaps the same LRG defined in this block"); 57.10 def->insert( r ); 57.11 use->remove( r ); 57.12 @@ -100,7 +100,7 @@ 57.13 Node *nk = n->in(k); 57.14 uint nkidx = nk->_idx; 57.15 if (_cfg.get_block_for_node(nk) != block) { 57.16 - uint u = _names[nkidx]; 57.17 + uint u = _names.at(nkidx); 57.18 use->insert(u); 57.19 DEBUG_ONLY(def_outside->insert(u);) 57.20 } 57.21 @@ -112,7 +112,7 @@ 57.22 #endif 57.23 // Remove anything defined by Phis and the block start instruction 57.24 for (uint k = i; k > 0; k--) { 57.25 - uint r = _names[block->get_node(k - 1)->_idx]; 57.26 + uint r = _names.at(block->get_node(k - 1)->_idx); 57.27 def->insert(r); 57.28 use->remove(r); 57.29 } 57.30 @@ -124,7 +124,7 @@ 57.31 57.32 // PhiNode uses go in the live-out set of prior blocks. 57.33 for (uint k = i; k > 0; k--) { 57.34 - add_liveout(p, _names[block->get_node(k-1)->in(l)->_idx], first_pass); 57.35 + add_liveout(p, _names.at(block->get_node(k-1)->in(l)->_idx), first_pass); 57.36 } 57.37 } 57.38 freeset(block); 57.39 @@ -256,7 +256,7 @@ 57.40 tty->print("LiveOut: "); _live[b->_pre_order-1].dump(); 57.41 uint cnt = b->number_of_nodes(); 57.42 for( uint i=0; i<cnt; i++ ) { 57.43 - tty->print("L%d/", _names[b->get_node(i)->_idx] ); 57.44 + tty->print("L%d/", _names.at(b->get_node(i)->_idx)); 57.45 b->get_node(i)->dump(); 57.46 } 57.47 tty->print("\n");
58.1 --- a/src/share/vm/opto/live.hpp Sat Sep 21 10:09:42 2013 +0200 58.2 +++ b/src/share/vm/opto/live.hpp Tue Sep 24 10:14:02 2013 +0200 58.3 @@ -40,27 +40,7 @@ 58.4 //------------------------------LRG_List--------------------------------------- 58.5 // Map Node indices to Live RanGe indices. 58.6 // Array lookup in the optimized case. 58.7 -class LRG_List : public ResourceObj { 58.8 - friend class VMStructs; 58.9 - uint _cnt, _max; 58.10 - uint* _lidxs; 58.11 - ReallocMark _nesting; // assertion check for reallocations 58.12 -public: 58.13 - LRG_List( uint max ); 58.14 - 58.15 - uint lookup( uint nidx ) const { 58.16 - return _lidxs[nidx]; 58.17 - } 58.18 - uint operator[] (uint nidx) const { return lookup(nidx); } 58.19 - 58.20 - void map( uint nidx, uint lidx ) { 58.21 - assert( nidx < _cnt, "oob" ); 58.22 - _lidxs[nidx] = lidx; 58.23 - } 58.24 - void extend( uint nidx, uint lidx ); 58.25 - 58.26 - uint Size() const { return _cnt; } 58.27 -}; 58.28 +typedef GrowableArray<uint> LRG_List; 58.29 58.30 //------------------------------PhaseLive-------------------------------------- 58.31 // Compute live-in/live-out
59.1 --- a/src/share/vm/prims/jni.cpp Sat Sep 21 10:09:42 2013 +0200 59.2 +++ b/src/share/vm/prims/jni.cpp Tue Sep 24 10:14:02 2013 +0200 59.3 @@ -1336,6 +1336,7 @@ 59.4 if (call_type == JNI_VIRTUAL) { 59.5 // jni_GetMethodID makes sure class is linked and initialized 59.6 // so m should have a valid vtable index. 59.7 + assert(!m->has_itable_index(), ""); 59.8 int vtbl_index = m->vtable_index(); 59.9 if (vtbl_index != Method::nonvirtual_vtable_index) { 59.10 Klass* k = h_recv->klass(); 59.11 @@ -1355,12 +1356,7 @@ 59.12 // interface call 59.13 KlassHandle h_holder(THREAD, holder); 59.14 59.15 - int itbl_index = m->cached_itable_index(); 59.16 - if (itbl_index == -1) { 59.17 - itbl_index = klassItable::compute_itable_index(m); 59.18 - m->set_cached_itable_index(itbl_index); 59.19 - // the above may have grabbed a lock, 'm' and anything non-handlized can't be used again 59.20 - } 59.21 + int itbl_index = m->itable_index(); 59.22 Klass* k = h_recv->klass(); 59.23 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); 59.24 } 59.25 @@ -5037,6 +5033,7 @@ 59.26 #include "gc_implementation/g1/heapRegionRemSet.hpp" 59.27 #endif 59.28 #include "utilities/quickSort.hpp" 59.29 +#include "utilities/ostream.hpp" 59.30 #if INCLUDE_VM_STRUCTS 59.31 #include "runtime/vmStructs.hpp" 59.32 #endif 59.33 @@ -5064,6 +5061,7 @@ 59.34 run_unit_test(CollectedHeap::test_is_in()); 59.35 run_unit_test(QuickSort::test_quick_sort()); 59.36 run_unit_test(AltHashing::test_alt_hash()); 59.37 + run_unit_test(test_loggc_filename()); 59.38 #if INCLUDE_VM_STRUCTS 59.39 run_unit_test(VMStructs::test()); 59.40 #endif
60.1 --- a/src/share/vm/prims/jvm.cpp Sat Sep 21 10:09:42 2013 +0200 60.2 +++ b/src/share/vm/prims/jvm.cpp Tue Sep 24 10:14:02 2013 +0200 60.3 @@ -1824,7 +1824,7 @@ 60.4 } 60.5 60.6 if (!publicOnly || fs.access_flags().is_public()) { 60.7 - fd.initialize(k(), fs.index()); 60.8 + fd.reinitialize(k(), fs.index()); 60.9 oop field = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); 60.10 result->obj_at_put(out_idx, field); 60.11 ++out_idx;
61.1 --- a/src/share/vm/prims/jvmti.xml Sat Sep 21 10:09:42 2013 +0200 61.2 +++ b/src/share/vm/prims/jvmti.xml Tue Sep 24 10:14:02 2013 +0200 61.3 @@ -458,8 +458,10 @@ 61.4 the same name from being loaded dynamically. 61.5 <p/> 61.6 The VM will invoke the Agent_OnUnload_L function of the agent, if such 61.7 - a function is exported, at the same point during startup as it would 61.8 - have called the dynamic entry point Agent_OnUnLoad. 61.9 + a function is exported, at the same point during VM execution as it would 61.10 + have called the dynamic entry point Agent_OnUnLoad. A statically loaded 61.11 + agent cannot be unloaded. The Agent_OnUnload_L function will still be 61.12 + called to do any other agent shutdown related tasks. 61.13 If a <i>statically linked</i> agent L exports a function called 61.14 Agent_OnUnLoad_L and a function called Agent_OnUnLoad, the Agent_OnUnLoad 61.15 function will be ignored.
62.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp Sat Sep 21 10:09:42 2013 +0200 62.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp Tue Sep 24 10:14:02 2013 +0200 62.3 @@ -1072,8 +1072,17 @@ 62.4 } 62.5 62.6 res = merge_cp_and_rewrite(the_class, scratch_class, THREAD); 62.7 - if (res != JVMTI_ERROR_NONE) { 62.8 - return res; 62.9 + if (HAS_PENDING_EXCEPTION) { 62.10 + Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); 62.11 + // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark 62.12 + RC_TRACE_WITH_THREAD(0x00000002, THREAD, 62.13 + ("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string())); 62.14 + CLEAR_PENDING_EXCEPTION; 62.15 + if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { 62.16 + return JVMTI_ERROR_OUT_OF_MEMORY; 62.17 + } else { 62.18 + return JVMTI_ERROR_INTERNAL; 62.19 + } 62.20 } 62.21 62.22 if (VerifyMergedCPBytecodes) { 62.23 @@ -1105,6 +1114,9 @@ 62.24 } 62.25 if (HAS_PENDING_EXCEPTION) { 62.26 Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); 62.27 + // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark 62.28 + RC_TRACE_WITH_THREAD(0x00000002, THREAD, 62.29 + ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string())); 62.30 CLEAR_PENDING_EXCEPTION; 62.31 if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { 62.32 return JVMTI_ERROR_OUT_OF_MEMORY; 62.33 @@ -1395,8 +1407,8 @@ 62.34 ClassLoaderData* loader_data = the_class->class_loader_data(); 62.35 ConstantPool* merge_cp_oop = 62.36 ConstantPool::allocate(loader_data, 62.37 - merge_cp_length, 62.38 - THREAD); 62.39 + merge_cp_length, 62.40 + CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); 62.41 MergeCPCleaner cp_cleaner(loader_data, merge_cp_oop); 62.42 62.43 HandleMark hm(THREAD); // make sure handles are cleared before 62.44 @@ -1472,7 +1484,8 @@ 62.45 62.46 // Replace the new constant pool with a shrunken copy of the 62.47 // merged constant pool 62.48 - set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD); 62.49 + set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, 62.50 + CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); 62.51 // The new constant pool replaces scratch_cp so have cleaner clean it up. 62.52 // It can't be cleaned up while there are handles to it. 62.53 cp_cleaner.add_scratch_cp(scratch_cp()); 62.54 @@ -1502,7 +1515,8 @@ 62.55 // merged constant pool so now the rewritten bytecodes have 62.56 // valid references; the previous new constant pool will get 62.57 // GCed. 62.58 - set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD); 62.59 + set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, 62.60 + CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); 62.61 // The new constant pool replaces scratch_cp so have cleaner clean it up. 62.62 // It can't be cleaned up while there are handles to it. 62.63 cp_cleaner.add_scratch_cp(scratch_cp()); 62.64 @@ -1590,11 +1604,23 @@ 62.65 for (int i = methods->length() - 1; i >= 0; i--) { 62.66 methodHandle method(THREAD, methods->at(i)); 62.67 methodHandle new_method; 62.68 - rewrite_cp_refs_in_method(method, &new_method, CHECK_false); 62.69 + rewrite_cp_refs_in_method(method, &new_method, THREAD); 62.70 if (!new_method.is_null()) { 62.71 // the method has been replaced so save the new method version 62.72 + // even in the case of an exception. original method is on the 62.73 + // deallocation list. 62.74 methods->at_put(i, new_method()); 62.75 } 62.76 + if (HAS_PENDING_EXCEPTION) { 62.77 + Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); 62.78 + // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark 62.79 + RC_TRACE_WITH_THREAD(0x00000002, THREAD, 62.80 + ("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string())); 62.81 + // Need to clear pending exception here as the super caller sets 62.82 + // the JVMTI_ERROR_INTERNAL if the returned value is false. 62.83 + CLEAR_PENDING_EXCEPTION; 62.84 + return false; 62.85 + } 62.86 } 62.87 62.88 return true; 62.89 @@ -1674,10 +1700,7 @@ 62.90 Pause_No_Safepoint_Verifier pnsv(&nsv); 62.91 62.92 // ldc is 2 bytes and ldc_w is 3 bytes 62.93 - m = rc.insert_space_at(bci, 3, inst_buffer, THREAD); 62.94 - if (m.is_null() || HAS_PENDING_EXCEPTION) { 62.95 - guarantee(false, "insert_space_at() failed"); 62.96 - } 62.97 + m = rc.insert_space_at(bci, 3, inst_buffer, CHECK); 62.98 } 62.99 62.100 // return the new method so that the caller can update 62.101 @@ -2487,8 +2510,8 @@ 62.102 // scratch_cp is a merged constant pool and has enough space for a 62.103 // worst case merge situation. We want to associate the minimum 62.104 // sized constant pool with the klass to save space. 62.105 - constantPoolHandle smaller_cp(THREAD, 62.106 - ConstantPool::allocate(loader_data, scratch_cp_length, THREAD)); 62.107 + ConstantPool* cp = ConstantPool::allocate(loader_data, scratch_cp_length, CHECK); 62.108 + constantPoolHandle smaller_cp(THREAD, cp); 62.109 62.110 // preserve version() value in the smaller copy 62.111 int version = scratch_cp->version(); 62.112 @@ -2500,6 +2523,11 @@ 62.113 smaller_cp->set_pool_holder(scratch_class()); 62.114 62.115 scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD); 62.116 + if (HAS_PENDING_EXCEPTION) { 62.117 + // Exception is handled in the caller 62.118 + loader_data->add_to_deallocate_list(smaller_cp()); 62.119 + return; 62.120 + } 62.121 scratch_cp = smaller_cp; 62.122 62.123 // attach new constant pool to klass 62.124 @@ -2930,7 +2958,7 @@ 62.125 for (int i = 0; i < _deleted_methods_length; ++i) { 62.126 Method* old_method = _deleted_methods[i]; 62.127 62.128 - assert(old_method->vtable_index() < 0, 62.129 + assert(!old_method->has_vtable_index(), 62.130 "cannot delete methods with vtable entries");; 62.131 62.132 // Mark all deleted methods as old and obsolete
63.1 --- a/src/share/vm/prims/methodHandles.cpp Sat Sep 21 10:09:42 2013 +0200 63.2 +++ b/src/share/vm/prims/methodHandles.cpp Tue Sep 24 10:14:02 2013 +0200 63.3 @@ -127,25 +127,37 @@ 63.4 } 63.5 63.6 oop MethodHandles::init_MemberName(Handle mname, Handle target) { 63.7 + // This method is used from java.lang.invoke.MemberName constructors. 63.8 + // It fills in the new MemberName from a java.lang.reflect.Member. 63.9 Thread* thread = Thread::current(); 63.10 oop target_oop = target(); 63.11 Klass* target_klass = target_oop->klass(); 63.12 if (target_klass == SystemDictionary::reflect_Field_klass()) { 63.13 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() 63.14 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() 63.15 - int mods = java_lang_reflect_Field::modifiers(target_oop); 63.16 - oop type = java_lang_reflect_Field::type(target_oop); 63.17 - oop name = java_lang_reflect_Field::name(target_oop); 63.18 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); 63.19 - intptr_t offset = InstanceKlass::cast(k())->field_offset(slot); 63.20 - return init_field_MemberName(mname, k, accessFlags_from(mods), type, name, offset); 63.21 + if (!k.is_null() && k->oop_is_instance()) { 63.22 + fieldDescriptor fd(InstanceKlass::cast(k()), slot); 63.23 + oop mname2 = init_field_MemberName(mname, fd); 63.24 + if (mname2 != NULL) { 63.25 + // Since we have the reified name and type handy, add them to the result. 63.26 + if (java_lang_invoke_MemberName::name(mname2) == NULL) 63.27 + java_lang_invoke_MemberName::set_name(mname2, java_lang_reflect_Field::name(target_oop)); 63.28 + if (java_lang_invoke_MemberName::type(mname2) == NULL) 63.29 + java_lang_invoke_MemberName::set_type(mname2, java_lang_reflect_Field::type(target_oop)); 63.30 + } 63.31 + return mname2; 63.32 + } 63.33 } else if (target_klass == SystemDictionary::reflect_Method_klass()) { 63.34 oop clazz = java_lang_reflect_Method::clazz(target_oop); 63.35 int slot = java_lang_reflect_Method::slot(target_oop); 63.36 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); 63.37 if (!k.is_null() && k->oop_is_instance()) { 63.38 Method* m = InstanceKlass::cast(k())->method_with_idnum(slot); 63.39 - return init_method_MemberName(mname, m, true, k); 63.40 + if (m == NULL || is_signature_polymorphic(m->intrinsic_id())) 63.41 + return NULL; // do not resolve unless there is a concrete signature 63.42 + CallInfo info(m, k()); 63.43 + return init_method_MemberName(mname, info); 63.44 } 63.45 } else if (target_klass == SystemDictionary::reflect_Constructor_klass()) { 63.46 oop clazz = java_lang_reflect_Constructor::clazz(target_oop); 63.47 @@ -153,65 +165,50 @@ 63.48 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); 63.49 if (!k.is_null() && k->oop_is_instance()) { 63.50 Method* m = InstanceKlass::cast(k())->method_with_idnum(slot); 63.51 - return init_method_MemberName(mname, m, false, k); 63.52 - } 63.53 - } else if (target_klass == SystemDictionary::MemberName_klass()) { 63.54 - // Note: This only works if the MemberName has already been resolved. 63.55 - oop clazz = java_lang_invoke_MemberName::clazz(target_oop); 63.56 - int flags = java_lang_invoke_MemberName::flags(target_oop); 63.57 - Metadata* vmtarget=java_lang_invoke_MemberName::vmtarget(target_oop); 63.58 - intptr_t vmindex = java_lang_invoke_MemberName::vmindex(target_oop); 63.59 - KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); 63.60 - int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK; 63.61 - if (vmtarget == NULL) return NULL; // not resolved 63.62 - if ((flags & IS_FIELD) != 0) { 63.63 - assert(vmtarget->is_klass(), "field vmtarget is Klass*"); 63.64 - int basic_mods = (ref_kind_is_static(ref_kind) ? JVM_ACC_STATIC : 0); 63.65 - // FIXME: how does k (receiver_limit) contribute? 63.66 - KlassHandle k_vmtarget(thread, (Klass*)vmtarget); 63.67 - return init_field_MemberName(mname, k_vmtarget, accessFlags_from(basic_mods), NULL, NULL, vmindex); 63.68 - } else if ((flags & (IS_METHOD | IS_CONSTRUCTOR)) != 0) { 63.69 - assert(vmtarget->is_method(), "method or constructor vmtarget is Method*"); 63.70 - return init_method_MemberName(mname, (Method*)vmtarget, ref_kind_does_dispatch(ref_kind), k); 63.71 - } else { 63.72 - return NULL; 63.73 + if (m == NULL) return NULL; 63.74 + CallInfo info(m, k()); 63.75 + return init_method_MemberName(mname, info); 63.76 } 63.77 } 63.78 return NULL; 63.79 } 63.80 63.81 -oop MethodHandles::init_method_MemberName(Handle mname, Method* m, bool do_dispatch, 63.82 - KlassHandle receiver_limit_h) { 63.83 - Klass* receiver_limit = receiver_limit_h(); 63.84 - AccessFlags mods = m->access_flags(); 63.85 - int flags = (jushort)( mods.as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); 63.86 - int vmindex = Method::nonvirtual_vtable_index; // implies never any dispatch 63.87 - Klass* mklass = m->method_holder(); 63.88 - if (receiver_limit == NULL) 63.89 - receiver_limit = mklass; 63.90 - if (m->is_initializer()) { 63.91 - flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); 63.92 - } else if (mods.is_static()) { 63.93 - flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); 63.94 - } else if (receiver_limit != mklass && 63.95 - !receiver_limit->is_subtype_of(mklass)) { 63.96 - return NULL; // bad receiver limit 63.97 - } else if (do_dispatch && receiver_limit->is_interface() && 63.98 - mklass->is_interface()) { 63.99 +oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { 63.100 + assert(info.resolved_appendix().is_null(), "only normal methods here"); 63.101 + KlassHandle receiver_limit = info.resolved_klass(); 63.102 + methodHandle m = info.resolved_method(); 63.103 + int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); 63.104 + int vmindex = Method::invalid_vtable_index; 63.105 + 63.106 + switch (info.call_kind()) { 63.107 + case CallInfo::itable_call: 63.108 + vmindex = info.itable_index(); 63.109 + // More importantly, the itable index only works with the method holder. 63.110 + receiver_limit = m->method_holder(); 63.111 + assert(receiver_limit->verify_itable_index(vmindex), ""); 63.112 flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT); 63.113 - receiver_limit = mklass; // ignore passed-in limit; interfaces are interconvertible 63.114 - vmindex = klassItable::compute_itable_index(m); 63.115 - } else if (do_dispatch && mklass != receiver_limit && mklass->is_interface()) { 63.116 + break; 63.117 + 63.118 + case CallInfo::vtable_call: 63.119 + vmindex = info.vtable_index(); 63.120 flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT); 63.121 - // it is a miranda method, so m->vtable_index is not what we want 63.122 - ResourceMark rm; 63.123 - klassVtable* vt = InstanceKlass::cast(receiver_limit)->vtable(); 63.124 - vmindex = vt->index_of_miranda(m->name(), m->signature()); 63.125 - } else if (!do_dispatch || m->can_be_statically_bound()) { 63.126 - flags |= IS_METHOD | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); 63.127 - } else { 63.128 - flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT); 63.129 - vmindex = m->vtable_index(); 63.130 + assert(receiver_limit->is_subtype_of(m->method_holder()), "virtual call must be type-safe"); 63.131 + break; 63.132 + 63.133 + case CallInfo::direct_call: 63.134 + vmindex = Method::nonvirtual_vtable_index; 63.135 + if (m->is_static()) { 63.136 + flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); 63.137 + } else if (m->is_initializer()) { 63.138 + flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); 63.139 + assert(receiver_limit == m->method_holder(), "constructor call must be exactly typed"); 63.140 + } else { 63.141 + flags |= IS_METHOD | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); 63.142 + assert(receiver_limit->is_subtype_of(m->method_holder()), "special call must be type-safe"); 63.143 + } 63.144 + break; 63.145 + 63.146 + default: assert(false, "bad CallInfo"); return NULL; 63.147 } 63.148 63.149 // @CallerSensitive annotation detected 63.150 @@ -221,7 +218,7 @@ 63.151 63.152 oop mname_oop = mname(); 63.153 java_lang_invoke_MemberName::set_flags( mname_oop, flags); 63.154 - java_lang_invoke_MemberName::set_vmtarget(mname_oop, m); 63.155 + java_lang_invoke_MemberName::set_vmtarget(mname_oop, m()); 63.156 java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index 63.157 java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror()); 63.158 // Note: name and type can be lazily computed by resolve_MemberName, 63.159 @@ -237,59 +234,19 @@ 63.160 return mname(); 63.161 } 63.162 63.163 -Handle MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, TRAPS) { 63.164 - Handle empty; 63.165 - if (info.resolved_appendix().not_null()) { 63.166 - // The resolved MemberName must not be accompanied by an appendix argument, 63.167 - // since there is no way to bind this value into the MemberName. 63.168 - // Caller is responsible to prevent this from happening. 63.169 - THROW_MSG_(vmSymbols::java_lang_InternalError(), "appendix", empty); 63.170 - } 63.171 - methodHandle m = info.resolved_method(); 63.172 - KlassHandle defc = info.resolved_klass(); 63.173 - int vmindex = Method::invalid_vtable_index; 63.174 - if (defc->is_interface() && m->method_holder()->is_interface()) { 63.175 - // static interface methods do not reference vtable or itable 63.176 - if (m->is_static()) { 63.177 - vmindex = Method::nonvirtual_vtable_index; 63.178 - } 63.179 - // interface methods invoked via invokespecial also 63.180 - // do not reference vtable or itable. 63.181 - int ref_kind = ((java_lang_invoke_MemberName::flags(mname()) >> 63.182 - REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK); 63.183 - if (ref_kind == JVM_REF_invokeSpecial) { 63.184 - vmindex = Method::nonvirtual_vtable_index; 63.185 - } 63.186 - // If neither m is static nor ref_kind is invokespecial, 63.187 - // set it to itable index. 63.188 - if (vmindex == Method::invalid_vtable_index) { 63.189 - // LinkResolver does not report itable indexes! (fix this?) 63.190 - vmindex = klassItable::compute_itable_index(m()); 63.191 - } 63.192 - } else if (m->can_be_statically_bound()) { 63.193 - // LinkResolver reports vtable index even for final methods! 63.194 - vmindex = Method::nonvirtual_vtable_index; 63.195 - } else { 63.196 - vmindex = info.vtable_index(); 63.197 - } 63.198 - oop res = init_method_MemberName(mname, m(), (vmindex >= 0), defc()); 63.199 - assert(res == NULL || (java_lang_invoke_MemberName::vmindex(res) == vmindex), ""); 63.200 - return Handle(THREAD, res); 63.201 -} 63.202 - 63.203 -oop MethodHandles::init_field_MemberName(Handle mname, KlassHandle field_holder, 63.204 - AccessFlags mods, oop type, oop name, 63.205 - intptr_t offset, bool is_setter) { 63.206 - int flags = (jushort)( mods.as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); 63.207 - flags |= IS_FIELD | ((mods.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); 63.208 +oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { 63.209 + int flags = (jushort)( fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); 63.210 + flags |= IS_FIELD | ((fd.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); 63.211 if (is_setter) flags += ((JVM_REF_putField - JVM_REF_getField) << REFERENCE_KIND_SHIFT); 63.212 - Metadata* vmtarget = field_holder(); 63.213 - int vmindex = offset; // determines the field uniquely when combined with static bit 63.214 + Metadata* vmtarget = fd.field_holder(); 63.215 + int vmindex = fd.offset(); // determines the field uniquely when combined with static bit 63.216 oop mname_oop = mname(); 63.217 java_lang_invoke_MemberName::set_flags(mname_oop, flags); 63.218 java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget); 63.219 java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); 63.220 - java_lang_invoke_MemberName::set_clazz(mname_oop, field_holder->java_mirror()); 63.221 + java_lang_invoke_MemberName::set_clazz(mname_oop, fd.field_holder()->java_mirror()); 63.222 + oop type = field_signature_type_or_null(fd.signature()); 63.223 + oop name = field_name_or_null(fd.name()); 63.224 if (name != NULL) 63.225 java_lang_invoke_MemberName::set_name(mname_oop, name); 63.226 if (type != NULL) 63.227 @@ -305,19 +262,6 @@ 63.228 return mname(); 63.229 } 63.230 63.231 -Handle MethodHandles::init_field_MemberName(Handle mname, FieldAccessInfo& info, TRAPS) { 63.232 - return Handle(); 63.233 -#if 0 // FIXME 63.234 - KlassHandle field_holder = info.klass(); 63.235 - intptr_t field_offset = info.field_offset(); 63.236 - return init_field_MemberName(mname_oop, field_holder(), 63.237 - info.access_flags(), 63.238 - type, name, 63.239 - field_offset, false /*is_setter*/); 63.240 -#endif 63.241 -} 63.242 - 63.243 - 63.244 // JVM 2.9 Special Methods: 63.245 // A method is signature polymorphic if and only if all of the following conditions hold : 63.246 // * It is declared in the java.lang.invoke.MethodHandle class. 63.247 @@ -573,12 +517,12 @@ 63.248 return SystemDictionary::Object_klass()->java_mirror(); 63.249 } 63.250 63.251 -static oop field_name_or_null(Symbol* s) { 63.252 +oop MethodHandles::field_name_or_null(Symbol* s) { 63.253 if (s == NULL) return NULL; 63.254 return StringTable::lookup(s); 63.255 } 63.256 63.257 -static oop field_signature_type_or_null(Symbol* s) { 63.258 +oop MethodHandles::field_signature_type_or_null(Symbol* s) { 63.259 if (s == NULL) return NULL; 63.260 BasicType bt = FieldType::basic_type(s); 63.261 if (is_java_primitive(bt)) { 63.262 @@ -701,7 +645,14 @@ 63.263 return empty; 63.264 } 63.265 } 63.266 - return init_method_MemberName(mname, result, THREAD); 63.267 + if (result.resolved_appendix().not_null()) { 63.268 + // The resolved MemberName must not be accompanied by an appendix argument, 63.269 + // since there is no way to bind this value into the MemberName. 63.270 + // Caller is responsible to prevent this from happening. 63.271 + THROW_MSG_(vmSymbols::java_lang_InternalError(), "appendix", empty); 63.272 + } 63.273 + oop mname2 = init_method_MemberName(mname, result); 63.274 + return Handle(THREAD, mname2); 63.275 } 63.276 case IS_CONSTRUCTOR: 63.277 { 63.278 @@ -719,22 +670,21 @@ 63.279 } 63.280 } 63.281 assert(result.is_statically_bound(), ""); 63.282 - return init_method_MemberName(mname, result, THREAD); 63.283 + oop mname2 = init_method_MemberName(mname, result); 63.284 + return Handle(THREAD, mname2); 63.285 } 63.286 case IS_FIELD: 63.287 { 63.288 - // This is taken from LinkResolver::resolve_field, sans access checks. 63.289 - fieldDescriptor fd; // find_field initializes fd if found 63.290 - KlassHandle sel_klass(THREAD, InstanceKlass::cast(defc())->find_field(name, type, &fd)); 63.291 - // check if field exists; i.e., if a klass containing the field def has been selected 63.292 - if (sel_klass.is_null()) return empty; // should not happen 63.293 - oop type = field_signature_type_or_null(fd.signature()); 63.294 - oop name = field_name_or_null(fd.name()); 63.295 - bool is_setter = (ref_kind_is_valid(ref_kind) && ref_kind_is_setter(ref_kind)); 63.296 - mname = Handle(THREAD, 63.297 - init_field_MemberName(mname, sel_klass, 63.298 - fd.access_flags(), type, name, fd.offset(), is_setter)); 63.299 - return mname; 63.300 + fieldDescriptor result; // find_field initializes fd if found 63.301 + { 63.302 + assert(!HAS_PENDING_EXCEPTION, ""); 63.303 + LinkResolver::resolve_field(result, defc, name, type, KlassHandle(), Bytecodes::_nop, false, false, THREAD); 63.304 + if (HAS_PENDING_EXCEPTION) { 63.305 + return empty; 63.306 + } 63.307 + } 63.308 + oop mname2 = init_field_MemberName(mname, result, ref_kind_is_setter(ref_kind)); 63.309 + return Handle(THREAD, mname2); 63.310 } 63.311 default: 63.312 THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format", empty); 63.313 @@ -793,7 +743,6 @@ 63.314 } 63.315 case IS_FIELD: 63.316 { 63.317 - // This is taken from LinkResolver::resolve_field, sans access checks. 63.318 assert(vmtarget->is_klass(), "field vmtarget is Klass*"); 63.319 if (!((Klass*) vmtarget)->oop_is_instance()) break; 63.320 instanceKlassHandle defc(THREAD, (Klass*) vmtarget); 63.321 @@ -872,11 +821,7 @@ 63.322 Handle result(thread, results->obj_at(rfill++)); 63.323 if (!java_lang_invoke_MemberName::is_instance(result())) 63.324 return -99; // caller bug! 63.325 - oop type = field_signature_type_or_null(st.signature()); 63.326 - oop name = field_name_or_null(st.name()); 63.327 - oop saved = MethodHandles::init_field_MemberName(result, st.klass(), 63.328 - st.access_flags(), type, name, 63.329 - st.offset()); 63.330 + oop saved = MethodHandles::init_field_MemberName(result, st.field_descriptor()); 63.331 if (saved != result()) 63.332 results->obj_at_put(rfill-1, saved); // show saved instance to user 63.333 } else if (++overflow >= overflow_limit) { 63.334 @@ -926,7 +871,8 @@ 63.335 Handle result(thread, results->obj_at(rfill++)); 63.336 if (!java_lang_invoke_MemberName::is_instance(result())) 63.337 return -99; // caller bug! 63.338 - oop saved = MethodHandles::init_method_MemberName(result, m, true, NULL); 63.339 + CallInfo info(m); 63.340 + oop saved = MethodHandles::init_method_MemberName(result, info); 63.341 if (saved != result()) 63.342 results->obj_at_put(rfill-1, saved); // show saved instance to user 63.343 } else if (++overflow >= overflow_limit) { 63.344 @@ -1227,7 +1173,8 @@ 63.345 x = ((Klass*) vmtarget)->java_mirror(); 63.346 } else if (vmtarget->is_method()) { 63.347 Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL); 63.348 - x = MethodHandles::init_method_MemberName(mname2, (Method*)vmtarget, false, NULL); 63.349 + CallInfo info((Method*)vmtarget); 63.350 + x = MethodHandles::init_method_MemberName(mname2, info); 63.351 } 63.352 result->obj_at_put(1, x); 63.353 return JNIHandles::make_local(env, result());
64.1 --- a/src/share/vm/prims/methodHandles.hpp Sat Sep 21 10:09:42 2013 +0200 64.2 +++ b/src/share/vm/prims/methodHandles.hpp Tue Sep 24 10:14:02 2013 +0200 64.3 @@ -49,19 +49,18 @@ 64.4 // Adapters. 64.5 static MethodHandlesAdapterBlob* _adapter_code; 64.6 64.7 + // utility functions for reifying names and types 64.8 + static oop field_name_or_null(Symbol* s); 64.9 + static oop field_signature_type_or_null(Symbol* s); 64.10 + 64.11 public: 64.12 // working with member names 64.13 static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type 64.14 static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing 64.15 static Handle new_MemberName(TRAPS); // must be followed by init_MemberName 64.16 static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target 64.17 - static oop init_method_MemberName(Handle mname_h, Method* m, bool do_dispatch, 64.18 - KlassHandle receiver_limit_h); 64.19 - static oop init_field_MemberName(Handle mname_h, KlassHandle field_holder_h, 64.20 - AccessFlags mods, oop type, oop name, 64.21 - intptr_t offset, bool is_setter = false); 64.22 - static Handle init_method_MemberName(Handle mname_h, CallInfo& info, TRAPS); 64.23 - static Handle init_field_MemberName(Handle mname_h, FieldAccessInfo& info, TRAPS); 64.24 + static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false); 64.25 + static oop init_method_MemberName(Handle mname_h, CallInfo& info); 64.26 static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true); 64.27 static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig, 64.28 int mflags, KlassHandle caller,
65.1 --- a/src/share/vm/runtime/arguments.cpp Sat Sep 21 10:09:42 2013 +0200 65.2 +++ b/src/share/vm/runtime/arguments.cpp Tue Sep 24 10:14:02 2013 +0200 65.3 @@ -1869,7 +1869,7 @@ 65.4 (NumberOfGCLogFiles == 0) || 65.5 (GCLogFileSize == 0)) { 65.6 jio_fprintf(defaultStream::output_stream(), 65.7 - "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>\n" 65.8 + "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n" 65.9 "where num_of_file > 0 and num_of_size > 0\n" 65.10 "GC log rotation is turned off\n"); 65.11 UseGCLogFileRotation = false; 65.12 @@ -1883,6 +1883,51 @@ 65.13 } 65.14 } 65.15 65.16 +// This function is called for -Xloggc:<filename>, it can be used 65.17 +// to check if a given file name(or string) conforms to the following 65.18 +// specification: 65.19 +// A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]" 65.20 +// %p and %t only allowed once. We only limit usage of filename not path 65.21 +bool is_filename_valid(const char *file_name) { 65.22 + const char* p = file_name; 65.23 + char file_sep = os::file_separator()[0]; 65.24 + const char* cp; 65.25 + // skip prefix path 65.26 + for (cp = file_name; *cp != '\0'; cp++) { 65.27 + if (*cp == '/' || *cp == file_sep) { 65.28 + p = cp + 1; 65.29 + } 65.30 + } 65.31 + 65.32 + int count_p = 0; 65.33 + int count_t = 0; 65.34 + while (*p != '\0') { 65.35 + if ((*p >= '0' && *p <= '9') || 65.36 + (*p >= 'A' && *p <= 'Z') || 65.37 + (*p >= 'a' && *p <= 'z') || 65.38 + *p == '-' || 65.39 + *p == '_' || 65.40 + *p == '.') { 65.41 + p++; 65.42 + continue; 65.43 + } 65.44 + if (*p == '%') { 65.45 + if(*(p + 1) == 'p') { 65.46 + p += 2; 65.47 + count_p ++; 65.48 + continue; 65.49 + } 65.50 + if (*(p + 1) == 't') { 65.51 + p += 2; 65.52 + count_t ++; 65.53 + continue; 65.54 + } 65.55 + } 65.56 + return false; 65.57 + } 65.58 + return count_p < 2 && count_t < 2; 65.59 +} 65.60 + 65.61 // Check consistency of GC selection 65.62 bool Arguments::check_gc_consistency() { 65.63 check_gclog_consistency(); 65.64 @@ -2836,6 +2881,13 @@ 65.65 // ostream_init_log(), when called will use this filename 65.66 // to initialize a fileStream. 65.67 _gc_log_filename = strdup(tail); 65.68 + if (!is_filename_valid(_gc_log_filename)) { 65.69 + jio_fprintf(defaultStream::output_stream(), 65.70 + "Invalid file name for use with -Xloggc: Filename can only contain the " 65.71 + "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n" 65.72 + "Note %%p or %%t can only be used once\n", _gc_log_filename); 65.73 + return JNI_EINVAL; 65.74 + } 65.75 FLAG_SET_CMDLINE(bool, PrintGC, true); 65.76 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); 65.77 65.78 @@ -3356,6 +3408,33 @@ 65.79 return shared_archive_path; 65.80 } 65.81 65.82 +#ifndef PRODUCT 65.83 +// Determine whether LogVMOutput should be implicitly turned on. 65.84 +static bool use_vm_log() { 65.85 + if (LogCompilation || !FLAG_IS_DEFAULT(LogFile) || 65.86 + PrintCompilation || PrintInlining || PrintDependencies || PrintNativeNMethods || 65.87 + PrintDebugInfo || PrintRelocations || PrintNMethods || PrintExceptionHandlers || 65.88 + PrintAssembly || TraceDeoptimization || TraceDependencies || 65.89 + (VerifyDependencies && FLAG_IS_CMDLINE(VerifyDependencies))) { 65.90 + return true; 65.91 + } 65.92 + 65.93 +#ifdef COMPILER1 65.94 + if (PrintC1Statistics) { 65.95 + return true; 65.96 + } 65.97 +#endif // COMPILER1 65.98 + 65.99 +#ifdef COMPILER2 65.100 + if (PrintOptoAssembly || PrintOptoStatistics) { 65.101 + return true; 65.102 + } 65.103 +#endif // COMPILER2 65.104 + 65.105 + return false; 65.106 +} 65.107 +#endif // PRODUCT 65.108 + 65.109 // Parse entry point called from JNI_CreateJavaVM 65.110 65.111 jint Arguments::parse(const JavaVMInitArgs* args) { 65.112 @@ -3656,7 +3735,13 @@ 65.113 NmethodSweepFraction = 1; 65.114 } 65.115 } 65.116 -#endif 65.117 + 65.118 + if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) { 65.119 + if (use_vm_log()) { 65.120 + LogVMOutput = true; 65.121 + } 65.122 + } 65.123 +#endif // PRODUCT 65.124 65.125 if (PrintCommandLineFlags) { 65.126 CommandLineFlags::printSetFlags(tty);
66.1 --- a/src/share/vm/runtime/arguments.hpp Sat Sep 21 10:09:42 2013 +0200 66.2 +++ b/src/share/vm/runtime/arguments.hpp Tue Sep 24 10:14:02 2013 +0200 66.3 @@ -144,7 +144,7 @@ 66.4 void set_os_lib(void* os_lib) { _os_lib = os_lib; } 66.5 AgentLibrary* next() const { return _next; } 66.6 bool is_static_lib() const { return _is_static_lib; } 66.7 - void set_static_lib(bool static_lib) { _is_static_lib = static_lib; } 66.8 + void set_static_lib(bool is_static_lib) { _is_static_lib = is_static_lib; } 66.9 bool valid() { return (_state == agent_valid); } 66.10 void set_valid() { _state = agent_valid; } 66.11 void set_invalid() { _state = agent_invalid; }
67.1 --- a/src/share/vm/runtime/deoptimization.cpp Sat Sep 21 10:09:42 2013 +0200 67.2 +++ b/src/share/vm/runtime/deoptimization.cpp Tue Sep 24 10:14:02 2013 +0200 67.3 @@ -1751,7 +1751,7 @@ 67.4 else return trap_state & ~DS_RECOMPILE_BIT; 67.5 } 67.6 //---------------------------format_trap_state--------------------------------- 67.7 -// This is used for debugging and diagnostics, including hotspot.log output. 67.8 +// This is used for debugging and diagnostics, including LogFile output. 67.9 const char* Deoptimization::format_trap_state(char* buf, size_t buflen, 67.10 int trap_state) { 67.11 DeoptReason reason = trap_state_reason(trap_state); 67.12 @@ -1828,7 +1828,7 @@ 67.13 return buf; 67.14 } 67.15 67.16 -// This is used for debugging and diagnostics, including hotspot.log output. 67.17 +// This is used for debugging and diagnostics, including LogFile output. 67.18 const char* Deoptimization::format_trap_request(char* buf, size_t buflen, 67.19 int trap_request) { 67.20 jint unloaded_class_index = trap_request_index(trap_request);
68.1 --- a/src/share/vm/runtime/fieldDescriptor.cpp Sat Sep 21 10:09:42 2013 +0200 68.2 +++ b/src/share/vm/runtime/fieldDescriptor.cpp Tue Sep 24 10:14:02 2013 +0200 68.3 @@ -97,18 +97,32 @@ 68.4 return constants()->uncached_string_at(initial_value_index(), CHECK_0); 68.5 } 68.6 68.7 -void fieldDescriptor::initialize(InstanceKlass* ik, int index) { 68.8 - _cp = ik->constants(); 68.9 +void fieldDescriptor::reinitialize(InstanceKlass* ik, int index) { 68.10 + if (_cp.is_null() || field_holder() != ik) { 68.11 + _cp = constantPoolHandle(Thread::current(), ik->constants()); 68.12 + // _cp should now reference ik's constant pool; i.e., ik is now field_holder. 68.13 + assert(field_holder() == ik, "must be already initialized to this class"); 68.14 + } 68.15 FieldInfo* f = ik->field(index); 68.16 assert(!f->is_internal(), "regular Java fields only"); 68.17 68.18 _access_flags = accessFlags_from(f->access_flags()); 68.19 guarantee(f->name_index() != 0 && f->signature_index() != 0, "bad constant pool index for fieldDescriptor"); 68.20 _index = index; 68.21 + verify(); 68.22 } 68.23 68.24 #ifndef PRODUCT 68.25 68.26 +void fieldDescriptor::verify() const { 68.27 + if (_cp.is_null()) { 68.28 + assert(_index == badInt, "constructor must be called"); // see constructor 68.29 + } else { 68.30 + assert(_index >= 0, "good index"); 68.31 + assert(_index < field_holder()->java_fields_count(), "oob"); 68.32 + } 68.33 +} 68.34 + 68.35 void fieldDescriptor::print_on(outputStream* st) const { 68.36 access_flags().print_on(st); 68.37 name()->print_value_on(st);
69.1 --- a/src/share/vm/runtime/fieldDescriptor.hpp Sat Sep 21 10:09:42 2013 +0200 69.2 +++ b/src/share/vm/runtime/fieldDescriptor.hpp Tue Sep 24 10:14:02 2013 +0200 69.3 @@ -1,5 +1,5 @@ 69.4 /* 69.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 69.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 69.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 69.8 * 69.9 * This code is free software; you can redistribute it and/or modify it 69.10 @@ -53,6 +53,13 @@ 69.11 } 69.12 69.13 public: 69.14 + fieldDescriptor() { 69.15 + DEBUG_ONLY(_index = badInt); 69.16 + } 69.17 + fieldDescriptor(InstanceKlass* ik, int index) { 69.18 + DEBUG_ONLY(_index = badInt); 69.19 + reinitialize(ik, index); 69.20 + } 69.21 Symbol* name() const { 69.22 return field()->name(_cp); 69.23 } 69.24 @@ -112,12 +119,13 @@ 69.25 } 69.26 69.27 // Initialization 69.28 - void initialize(InstanceKlass* ik, int index); 69.29 + void reinitialize(InstanceKlass* ik, int index); 69.30 69.31 // Print 69.32 void print() { print_on(tty); } 69.33 void print_on(outputStream* st) const PRODUCT_RETURN; 69.34 void print_on_for(outputStream* st, oop obj) PRODUCT_RETURN; 69.35 + void verify() const PRODUCT_RETURN; 69.36 }; 69.37 69.38 #endif // SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP
70.1 --- a/src/share/vm/runtime/frame.cpp Sat Sep 21 10:09:42 2013 +0200 70.2 +++ b/src/share/vm/runtime/frame.cpp Tue Sep 24 10:14:02 2013 +0200 70.3 @@ -652,7 +652,7 @@ 70.4 // Return whether the frame is in the VM or os indicating a Hotspot problem. 70.5 // Otherwise, it's likely a bug in the native library that the Java code calls, 70.6 // hopefully indicating where to submit bugs. 70.7 -static void print_C_frame(outputStream* st, char* buf, int buflen, address pc) { 70.8 +void frame::print_C_frame(outputStream* st, char* buf, int buflen, address pc) { 70.9 // C/C++ frame 70.10 bool in_vm = os::address_is_in_vm(pc); 70.11 st->print(in_vm ? "V" : "C");
71.1 --- a/src/share/vm/runtime/frame.hpp Sat Sep 21 10:09:42 2013 +0200 71.2 +++ b/src/share/vm/runtime/frame.hpp Tue Sep 24 10:14:02 2013 +0200 71.3 @@ -406,6 +406,7 @@ 71.4 void print_on(outputStream* st) const; 71.5 void interpreter_frame_print_on(outputStream* st) const; 71.6 void print_on_error(outputStream* st, char* buf, int buflen, bool verbose = false) const; 71.7 + static void print_C_frame(outputStream* st, char* buf, int buflen, address pc); 71.8 71.9 // Add annotated descriptions of memory locations belonging to this frame to values 71.10 void describe(FrameValues& values, int frame_no);
72.1 --- a/src/share/vm/runtime/globals.hpp Sat Sep 21 10:09:42 2013 +0200 72.2 +++ b/src/share/vm/runtime/globals.hpp Tue Sep 24 10:14:02 2013 +0200 72.3 @@ -880,7 +880,7 @@ 72.4 "stay alive at the expense of JVM performance") \ 72.5 \ 72.6 diagnostic(bool, LogCompilation, false, \ 72.7 - "Log compilation activity in detail to hotspot.log or LogFile") \ 72.8 + "Log compilation activity in detail to LogFile") \ 72.9 \ 72.10 product(bool, PrintCompilation, false, \ 72.11 "Print compilations") \ 72.12 @@ -2498,16 +2498,17 @@ 72.13 "Print all VM flags with default values and descriptions and exit")\ 72.14 \ 72.15 diagnostic(bool, SerializeVMOutput, true, \ 72.16 - "Use a mutex to serialize output to tty and hotspot.log") \ 72.17 + "Use a mutex to serialize output to tty and LogFile") \ 72.18 \ 72.19 diagnostic(bool, DisplayVMOutput, true, \ 72.20 "Display all VM output on the tty, independently of LogVMOutput") \ 72.21 \ 72.22 - diagnostic(bool, LogVMOutput, trueInDebug, \ 72.23 - "Save VM output to hotspot.log, or to LogFile") \ 72.24 + diagnostic(bool, LogVMOutput, false, \ 72.25 + "Save VM output to LogFile") \ 72.26 \ 72.27 diagnostic(ccstr, LogFile, NULL, \ 72.28 - "If LogVMOutput is on, save VM output to this file [hotspot.log]") \ 72.29 + "If LogVMOutput or LogCompilation is on, save VM output to " \ 72.30 + "this file [default: ./hotspot_pid%p.log] (%p replaced with pid)") \ 72.31 \ 72.32 product(ccstr, ErrorFile, NULL, \ 72.33 "If an error occurs, save the error data to this file " \
73.1 --- a/src/share/vm/runtime/mutexLocker.cpp Sat Sep 21 10:09:42 2013 +0200 73.2 +++ b/src/share/vm/runtime/mutexLocker.cpp Tue Sep 24 10:14:02 2013 +0200 73.3 @@ -45,7 +45,6 @@ 73.4 Mutex* VMStatistic_lock = NULL; 73.5 Mutex* JNIGlobalHandle_lock = NULL; 73.6 Mutex* JNIHandleBlockFreeList_lock = NULL; 73.7 -Mutex* JNICachedItableIndex_lock = NULL; 73.8 Mutex* MemberNameTable_lock = NULL; 73.9 Mutex* JmethodIdCreation_lock = NULL; 73.10 Mutex* JfieldIdCreation_lock = NULL; 73.11 @@ -253,7 +252,6 @@ 73.12 } 73.13 def(Heap_lock , Monitor, nonleaf+1, false); 73.14 def(JfieldIdCreation_lock , Mutex , nonleaf+1, true ); // jfieldID, Used in VM_Operation 73.15 - def(JNICachedItableIndex_lock , Mutex , nonleaf+1, false); // Used to cache an itable index during JNI invoke 73.16 def(MemberNameTable_lock , Mutex , nonleaf+1, false); // Used to protect MemberNameTable 73.17 73.18 def(CompiledIC_lock , Mutex , nonleaf+2, false); // locks VtableStubs_lock, InlineCacheBuffer_lock
74.1 --- a/src/share/vm/runtime/mutexLocker.hpp Sat Sep 21 10:09:42 2013 +0200 74.2 +++ b/src/share/vm/runtime/mutexLocker.hpp Tue Sep 24 10:14:02 2013 +0200 74.3 @@ -1,5 +1,5 @@ 74.4 /* 74.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 74.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 74.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 74.8 * 74.9 * This code is free software; you can redistribute it and/or modify it 74.10 @@ -50,7 +50,6 @@ 74.11 extern Mutex* VMStatistic_lock; // a lock used to guard statistics count increment 74.12 extern Mutex* JNIGlobalHandle_lock; // a lock on creating JNI global handles 74.13 extern Mutex* JNIHandleBlockFreeList_lock; // a lock on the JNI handle block free list 74.14 -extern Mutex* JNICachedItableIndex_lock; // a lock on caching an itable index during JNI invoke 74.15 extern Mutex* MemberNameTable_lock; // a lock on the MemberNameTable updates 74.16 extern Mutex* JmethodIdCreation_lock; // a lock on creating JNI method identifiers 74.17 extern Mutex* JfieldIdCreation_lock; // a lock on creating JNI static field identifiers
75.1 --- a/src/share/vm/runtime/os.cpp Sat Sep 21 10:09:42 2013 +0200 75.2 +++ b/src/share/vm/runtime/os.cpp Tue Sep 24 10:14:02 2013 +0200 75.3 @@ -459,6 +459,7 @@ 75.4 */ 75.5 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, 75.6 const char *syms[], size_t syms_len) { 75.7 + assert(agent_lib != NULL, "sanity check"); 75.8 const char *lib_name; 75.9 void *handle = agent_lib->os_lib(); 75.10 void *entryName = NULL; 75.11 @@ -489,6 +490,7 @@ 75.12 void *proc_handle; 75.13 void *save_handle; 75.14 75.15 + assert(agent_lib != NULL, "sanity check"); 75.16 if (agent_lib->name() == NULL) { 75.17 return false; 75.18 } 75.19 @@ -498,14 +500,13 @@ 75.20 // We want to look in this process' symbol table. 75.21 agent_lib->set_os_lib(proc_handle); 75.22 ret = find_agent_function(agent_lib, true, syms, syms_len); 75.23 - agent_lib->set_os_lib(save_handle); 75.24 if (ret != NULL) { 75.25 // Found an entry point like Agent_OnLoad_lib_name so we have a static agent 75.26 - agent_lib->set_os_lib(proc_handle); 75.27 agent_lib->set_valid(); 75.28 agent_lib->set_static_lib(true); 75.29 return true; 75.30 } 75.31 + agent_lib->set_os_lib(save_handle); 75.32 return false; 75.33 } 75.34
76.1 --- a/src/share/vm/runtime/os.hpp Sat Sep 21 10:09:42 2013 +0200 76.2 +++ b/src/share/vm/runtime/os.hpp Tue Sep 24 10:14:02 2013 +0200 76.3 @@ -91,6 +91,8 @@ 76.4 typedef void (*java_call_t)(JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread); 76.5 76.6 class os: AllStatic { 76.7 + friend class VMStructs; 76.8 + 76.9 public: 76.10 enum { page_sizes_max = 9 }; // Size of _page_sizes array (8 plus a sentinel) 76.11 76.12 @@ -803,6 +805,14 @@ 76.13 #endif 76.14 76.15 public: 76.16 +#ifndef PLATFORM_PRINT_NATIVE_STACK 76.17 + // No platform-specific code for printing the native stack. 76.18 + static bool platform_print_native_stack(outputStream* st, void* context, 76.19 + char *buf, int buf_size) { 76.20 + return false; 76.21 + } 76.22 +#endif 76.23 + 76.24 // debugging support (mostly used by debug.cpp but also fatal error handler) 76.25 static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address 76.26
77.1 --- a/src/share/vm/runtime/reflection.cpp Sat Sep 21 10:09:42 2013 +0200 77.2 +++ b/src/share/vm/runtime/reflection.cpp Tue Sep 24 10:14:02 2013 +0200 77.3 @@ -952,7 +952,8 @@ 77.4 } 77.5 } else { 77.6 // if the method can be overridden, we resolve using the vtable index. 77.7 - int index = reflected_method->vtable_index(); 77.8 + assert(!reflected_method->has_itable_index(), ""); 77.9 + int index = reflected_method->vtable_index(); 77.10 method = reflected_method; 77.11 if (index != Method::nonvirtual_vtable_index) { 77.12 // target_klass might be an arrayKlassOop but all vtables start at
78.1 --- a/src/share/vm/runtime/reflectionUtils.hpp Sat Sep 21 10:09:42 2013 +0200 78.2 +++ b/src/share/vm/runtime/reflectionUtils.hpp Tue Sep 24 10:14:02 2013 +0200 78.3 @@ -109,6 +109,8 @@ 78.4 private: 78.5 int length() const { return _klass->java_fields_count(); } 78.6 78.7 + fieldDescriptor _fd_buf; 78.8 + 78.9 public: 78.10 FieldStream(instanceKlassHandle klass, bool local_only, bool classes_only) 78.11 : KlassStream(klass, local_only, classes_only) { 78.12 @@ -134,6 +136,12 @@ 78.13 int offset() const { 78.14 return _klass->field_offset( index() ); 78.15 } 78.16 + // bridge to a heavier API: 78.17 + fieldDescriptor& field_descriptor() const { 78.18 + fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf); 78.19 + field.reinitialize(_klass(), _index); 78.20 + return field; 78.21 + } 78.22 }; 78.23 78.24 class FilteredField : public CHeapObj<mtInternal> {
79.1 --- a/src/share/vm/runtime/sweeper.cpp Sat Sep 21 10:09:42 2013 +0200 79.2 +++ b/src/share/vm/runtime/sweeper.cpp Tue Sep 24 10:14:02 2013 +0200 79.3 @@ -269,6 +269,7 @@ 79.4 // the number of nmethods changes during the sweep so the final 79.5 // stage must iterate until it there are no more nmethods. 79.6 int todo = (CodeCache::nof_nmethods() - _seen) / _invocations; 79.7 + int swept_count = 0; 79.8 79.9 assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); 79.10 assert(!CodeCache_lock->owned_by_self(), "just checking"); 79.11 @@ -278,6 +279,7 @@ 79.12 79.13 // The last invocation iterates until there are no more nmethods 79.14 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { 79.15 + swept_count++; 79.16 if (SafepointSynchronize::is_synchronizing()) { // Safepoint request 79.17 if (PrintMethodFlushing && Verbose) { 79.18 tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); 79.19 @@ -331,7 +333,7 @@ 79.20 event.set_endtime(sweep_end_counter); 79.21 event.set_sweepIndex(_traversals); 79.22 event.set_sweepFractionIndex(NmethodSweepFraction - _invocations + 1); 79.23 - event.set_sweptCount(todo); 79.24 + event.set_sweptCount(swept_count); 79.25 event.set_flushedCount(_flushed_count); 79.26 event.set_markedCount(_marked_count); 79.27 event.set_zombifiedCount(_zombified_count);
80.1 --- a/src/share/vm/runtime/thread.cpp Sat Sep 21 10:09:42 2013 +0200 80.2 +++ b/src/share/vm/runtime/thread.cpp Tue Sep 24 10:14:02 2013 +0200 80.3 @@ -333,6 +333,8 @@ 80.4 // Reclaim the objectmonitors from the omFreeList of the moribund thread. 80.5 ObjectSynchronizer::omFlush (this) ; 80.6 80.7 + EVENT_THREAD_DESTRUCT(this); 80.8 + 80.9 // stack_base can be NULL if the thread is never started or exited before 80.10 // record_stack_base_and_size called. Although, we would like to ensure 80.11 // that all started threads do call record_stack_base_and_size(), there is 80.12 @@ -3719,7 +3721,7 @@ 80.13 const char *name = agent->name(); 80.14 const char *msg = "Could not find agent library "; 80.15 80.16 - // First check to see if agent is statcally linked into executable 80.17 + // First check to see if agent is statically linked into executable 80.18 if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) { 80.19 library = agent->os_lib(); 80.20 } else if (agent->is_absolute_path()) {
81.1 --- a/src/share/vm/runtime/vmStructs.cpp Sat Sep 21 10:09:42 2013 +0200 81.2 +++ b/src/share/vm/runtime/vmStructs.cpp Tue Sep 24 10:14:02 2013 +0200 81.3 @@ -315,7 +315,6 @@ 81.4 nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*) \ 81.5 nonstatic_field(InstanceKlass, _generic_signature_index, u2) \ 81.6 nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ 81.7 - nonstatic_field(InstanceKlass, _methods_cached_itable_indices, int*) \ 81.8 volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \ 81.9 nonstatic_field(InstanceKlass, _annotations, Annotations*) \ 81.10 nonstatic_field(InstanceKlass, _dependencies, nmethodBucket*) \ 81.11 @@ -330,11 +329,13 @@ 81.12 nonstatic_field(Klass, _java_mirror, oop) \ 81.13 nonstatic_field(Klass, _modifier_flags, jint) \ 81.14 nonstatic_field(Klass, _super, Klass*) \ 81.15 + nonstatic_field(Klass, _subklass, Klass*) \ 81.16 nonstatic_field(Klass, _layout_helper, jint) \ 81.17 nonstatic_field(Klass, _name, Symbol*) \ 81.18 nonstatic_field(Klass, _access_flags, AccessFlags) \ 81.19 - nonstatic_field(Klass, _subklass, Klass*) \ 81.20 + nonstatic_field(Klass, _prototype_header, markOop) \ 81.21 nonstatic_field(Klass, _next_sibling, Klass*) \ 81.22 + nonstatic_field(vtableEntry, _method, Method*) \ 81.23 nonstatic_field(MethodData, _size, int) \ 81.24 nonstatic_field(MethodData, _method, Method*) \ 81.25 nonstatic_field(MethodData, _data_size, int) \ 81.26 @@ -342,10 +343,15 @@ 81.27 nonstatic_field(MethodData, _nof_decompiles, uint) \ 81.28 nonstatic_field(MethodData, _nof_overflow_recompiles, uint) \ 81.29 nonstatic_field(MethodData, _nof_overflow_traps, uint) \ 81.30 + nonstatic_field(MethodData, _trap_hist._array[0], u1) \ 81.31 nonstatic_field(MethodData, _eflags, intx) \ 81.32 nonstatic_field(MethodData, _arg_local, intx) \ 81.33 nonstatic_field(MethodData, _arg_stack, intx) \ 81.34 nonstatic_field(MethodData, _arg_returned, intx) \ 81.35 + nonstatic_field(DataLayout, _header._struct._tag, u1) \ 81.36 + nonstatic_field(DataLayout, _header._struct._flags, u1) \ 81.37 + nonstatic_field(DataLayout, _header._struct._bci, u2) \ 81.38 + nonstatic_field(DataLayout, _cells[0], intptr_t) \ 81.39 nonstatic_field(MethodCounters, _interpreter_invocation_count, int) \ 81.40 nonstatic_field(MethodCounters, _interpreter_throwout_count, u2) \ 81.41 nonstatic_field(MethodCounters, _number_of_breakpoints, u2) \ 81.42 @@ -357,6 +363,7 @@ 81.43 nonstatic_field(Method, _access_flags, AccessFlags) \ 81.44 nonstatic_field(Method, _vtable_index, int) \ 81.45 nonstatic_field(Method, _method_size, u2) \ 81.46 + nonstatic_field(Method, _intrinsic_id, u1) \ 81.47 nonproduct_nonstatic_field(Method, _compiled_invocation_count, int) \ 81.48 volatile_nonstatic_field(Method, _code, nmethod*) \ 81.49 nonstatic_field(Method, _i2i_entry, address) \ 81.50 @@ -443,12 +450,19 @@ 81.51 static_field(Universe, _bootstrapping, bool) \ 81.52 static_field(Universe, _fully_initialized, bool) \ 81.53 static_field(Universe, _verify_count, int) \ 81.54 + static_field(Universe, _non_oop_bits, intptr_t) \ 81.55 static_field(Universe, _narrow_oop._base, address) \ 81.56 static_field(Universe, _narrow_oop._shift, int) \ 81.57 static_field(Universe, _narrow_oop._use_implicit_null_checks, bool) \ 81.58 static_field(Universe, _narrow_klass._base, address) \ 81.59 static_field(Universe, _narrow_klass._shift, int) \ 81.60 \ 81.61 + /******/ \ 81.62 + /* os */ \ 81.63 + /******/ \ 81.64 + \ 81.65 + static_field(os, _polling_page, address) \ 81.66 + \ 81.67 /**********************************************************************************/ \ 81.68 /* Generation and Space hierarchies */ \ 81.69 /**********************************************************************************/ \ 81.70 @@ -456,6 +470,7 @@ 81.71 unchecked_nonstatic_field(ageTable, sizes, sizeof(ageTable::sizes)) \ 81.72 \ 81.73 nonstatic_field(BarrierSet, _max_covered_regions, int) \ 81.74 + nonstatic_field(BarrierSet, _kind, BarrierSet::Name) \ 81.75 nonstatic_field(BlockOffsetTable, _bottom, HeapWord*) \ 81.76 nonstatic_field(BlockOffsetTable, _end, HeapWord*) \ 81.77 \ 81.78 @@ -495,6 +510,7 @@ 81.79 nonstatic_field(CollectedHeap, _barrier_set, BarrierSet*) \ 81.80 nonstatic_field(CollectedHeap, _defer_initial_card_mark, bool) \ 81.81 nonstatic_field(CollectedHeap, _is_gc_active, bool) \ 81.82 + nonstatic_field(CollectedHeap, _total_collections, unsigned int) \ 81.83 nonstatic_field(CompactibleSpace, _compaction_top, HeapWord*) \ 81.84 nonstatic_field(CompactibleSpace, _first_dead, HeapWord*) \ 81.85 nonstatic_field(CompactibleSpace, _end_of_live, HeapWord*) \ 81.86 @@ -505,7 +521,7 @@ 81.87 nonstatic_field(ContiguousSpace, _saved_mark_word, HeapWord*) \ 81.88 \ 81.89 nonstatic_field(DefNewGeneration, _next_gen, Generation*) \ 81.90 - nonstatic_field(DefNewGeneration, _tenuring_threshold, uint) \ 81.91 + nonstatic_field(DefNewGeneration, _tenuring_threshold, uint) \ 81.92 nonstatic_field(DefNewGeneration, _age_table, ageTable) \ 81.93 nonstatic_field(DefNewGeneration, _eden_space, EdenSpace*) \ 81.94 nonstatic_field(DefNewGeneration, _from_space, ContiguousSpace*) \ 81.95 @@ -552,6 +568,11 @@ 81.96 nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \ 81.97 nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \ 81.98 static_field(ThreadLocalAllocBuffer, _target_refills, unsigned) \ 81.99 + nonstatic_field(ThreadLocalAllocBuffer, _number_of_refills, unsigned) \ 81.100 + nonstatic_field(ThreadLocalAllocBuffer, _fast_refill_waste, unsigned) \ 81.101 + nonstatic_field(ThreadLocalAllocBuffer, _slow_refill_waste, unsigned) \ 81.102 + nonstatic_field(ThreadLocalAllocBuffer, _gc_waste, unsigned) \ 81.103 + nonstatic_field(ThreadLocalAllocBuffer, _slow_allocations, unsigned) \ 81.104 nonstatic_field(VirtualSpace, _low_boundary, char*) \ 81.105 nonstatic_field(VirtualSpace, _high_boundary, char*) \ 81.106 nonstatic_field(VirtualSpace, _low, char*) \ 81.107 @@ -713,6 +734,13 @@ 81.108 \ 81.109 static_field(ClassLoaderDataGraph, _head, ClassLoaderData*) \ 81.110 \ 81.111 + /**********/ \ 81.112 + /* Arrays */ \ 81.113 + /**********/ \ 81.114 + \ 81.115 + nonstatic_field(Array<Klass*>, _length, int) \ 81.116 + nonstatic_field(Array<Klass*>, _data[0], Klass*) \ 81.117 + \ 81.118 /*******************/ \ 81.119 /* GrowableArrays */ \ 81.120 /*******************/ \ 81.121 @@ -720,7 +748,7 @@ 81.122 nonstatic_field(GenericGrowableArray, _len, int) \ 81.123 nonstatic_field(GenericGrowableArray, _max, int) \ 81.124 nonstatic_field(GenericGrowableArray, _arena, Arena*) \ 81.125 - nonstatic_field(GrowableArray<int>, _data, int*) \ 81.126 + nonstatic_field(GrowableArray<int>, _data, int*) \ 81.127 \ 81.128 /********************************/ \ 81.129 /* CodeCache (NOTE: incomplete) */ \ 81.130 @@ -763,7 +791,20 @@ 81.131 /* StubRoutines (NOTE: incomplete) */ \ 81.132 /***********************************/ \ 81.133 \ 81.134 + static_field(StubRoutines, _verify_oop_count, jint) \ 81.135 static_field(StubRoutines, _call_stub_return_address, address) \ 81.136 + static_field(StubRoutines, _aescrypt_encryptBlock, address) \ 81.137 + static_field(StubRoutines, _aescrypt_decryptBlock, address) \ 81.138 + static_field(StubRoutines, _cipherBlockChaining_encryptAESCrypt, address) \ 81.139 + static_field(StubRoutines, _cipherBlockChaining_decryptAESCrypt, address) \ 81.140 + static_field(StubRoutines, _updateBytesCRC32, address) \ 81.141 + static_field(StubRoutines, _crc_table_adr, address) \ 81.142 + \ 81.143 + /*****************/ \ 81.144 + /* SharedRuntime */ \ 81.145 + /*****************/ \ 81.146 + \ 81.147 + static_field(SharedRuntime, _ic_miss_blob, RuntimeStub*) \ 81.148 \ 81.149 /***************************************/ \ 81.150 /* PcDesc and other compiled code info */ \ 81.151 @@ -853,6 +894,7 @@ 81.152 volatile_nonstatic_field(Thread, _suspend_flags, uint32_t) \ 81.153 nonstatic_field(Thread, _active_handles, JNIHandleBlock*) \ 81.154 nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \ 81.155 + nonstatic_field(Thread, _allocated_bytes, jlong) \ 81.156 nonstatic_field(Thread, _current_pending_monitor, ObjectMonitor*) \ 81.157 nonstatic_field(Thread, _current_pending_monitor_is_from_java, bool) \ 81.158 nonstatic_field(Thread, _current_waiting_monitor, ObjectMonitor*) \ 81.159 @@ -866,6 +908,7 @@ 81.160 nonstatic_field(JavaThread, _pending_async_exception, oop) \ 81.161 volatile_nonstatic_field(JavaThread, _exception_oop, oop) \ 81.162 volatile_nonstatic_field(JavaThread, _exception_pc, address) \ 81.163 + volatile_nonstatic_field(JavaThread, _is_method_handle_return, int) \ 81.164 nonstatic_field(JavaThread, _is_compiling, bool) \ 81.165 nonstatic_field(JavaThread, _special_runtime_exit_condition, JavaThread::AsyncRequests) \ 81.166 nonstatic_field(JavaThread, _saved_exception_pc, address) \ 81.167 @@ -875,6 +918,8 @@ 81.168 nonstatic_field(JavaThread, _stack_size, size_t) \ 81.169 nonstatic_field(JavaThread, _vframe_array_head, vframeArray*) \ 81.170 nonstatic_field(JavaThread, _vframe_array_last, vframeArray*) \ 81.171 + nonstatic_field(JavaThread, _satb_mark_queue, ObjPtrQueue) \ 81.172 + nonstatic_field(JavaThread, _dirty_card_queue, DirtyCardQueue) \ 81.173 nonstatic_field(Thread, _resource_area, ResourceArea*) \ 81.174 nonstatic_field(CompilerThread, _env, ciEnv*) \ 81.175 \ 81.176 @@ -1187,7 +1232,7 @@ 81.177 unchecked_nonstatic_field(Array<int>, _data, sizeof(int)) \ 81.178 unchecked_nonstatic_field(Array<u1>, _data, sizeof(u1)) \ 81.179 unchecked_nonstatic_field(Array<u2>, _data, sizeof(u2)) \ 81.180 - unchecked_nonstatic_field(Array<Method*>, _data, sizeof(Method*)) \ 81.181 + unchecked_nonstatic_field(Array<Method*>, _data, sizeof(Method*)) \ 81.182 unchecked_nonstatic_field(Array<Klass*>, _data, sizeof(Klass*)) \ 81.183 \ 81.184 /*********************************/ \ 81.185 @@ -1203,7 +1248,7 @@ 81.186 /* Miscellaneous fields */ \ 81.187 /************************/ \ 81.188 \ 81.189 - nonstatic_field(CompileTask, _method, Method*) \ 81.190 + nonstatic_field(CompileTask, _method, Method*) \ 81.191 nonstatic_field(CompileTask, _osr_bci, int) \ 81.192 nonstatic_field(CompileTask, _comp_level, int) \ 81.193 nonstatic_field(CompileTask, _compile_id, uint) \ 81.194 @@ -1217,7 +1262,11 @@ 81.195 \ 81.196 nonstatic_field(vframeArrayElement, _frame, frame) \ 81.197 nonstatic_field(vframeArrayElement, _bci, int) \ 81.198 - nonstatic_field(vframeArrayElement, _method, Method*) \ 81.199 + nonstatic_field(vframeArrayElement, _method, Method*) \ 81.200 + \ 81.201 + nonstatic_field(PtrQueue, _active, bool) \ 81.202 + nonstatic_field(PtrQueue, _buf, void**) \ 81.203 + nonstatic_field(PtrQueue, _index, size_t) \ 81.204 \ 81.205 nonstatic_field(AccessFlags, _flags, jint) \ 81.206 nonstatic_field(elapsedTimer, _counter, jlong) \ 81.207 @@ -1363,7 +1412,7 @@ 81.208 /* MetadataOopDesc hierarchy (NOTE: some missing) */ \ 81.209 /**************************************************/ \ 81.210 \ 81.211 - declare_toplevel_type(CompiledICHolder) \ 81.212 + declare_toplevel_type(CompiledICHolder) \ 81.213 declare_toplevel_type(MetaspaceObj) \ 81.214 declare_type(Metadata, MetaspaceObj) \ 81.215 declare_type(Klass, Metadata) \ 81.216 @@ -1374,17 +1423,20 @@ 81.217 declare_type(InstanceClassLoaderKlass, InstanceKlass) \ 81.218 declare_type(InstanceMirrorKlass, InstanceKlass) \ 81.219 declare_type(InstanceRefKlass, InstanceKlass) \ 81.220 - declare_type(ConstantPool, Metadata) \ 81.221 - declare_type(ConstantPoolCache, MetaspaceObj) \ 81.222 - declare_type(MethodData, Metadata) \ 81.223 - declare_type(Method, Metadata) \ 81.224 - declare_type(MethodCounters, MetaspaceObj) \ 81.225 - declare_type(ConstMethod, MetaspaceObj) \ 81.226 + declare_type(ConstantPool, Metadata) \ 81.227 + declare_type(ConstantPoolCache, MetaspaceObj) \ 81.228 + declare_type(MethodData, Metadata) \ 81.229 + declare_type(Method, Metadata) \ 81.230 + declare_type(MethodCounters, MetaspaceObj) \ 81.231 + declare_type(ConstMethod, MetaspaceObj) \ 81.232 + \ 81.233 + declare_toplevel_type(vtableEntry) \ 81.234 \ 81.235 declare_toplevel_type(Symbol) \ 81.236 declare_toplevel_type(Symbol*) \ 81.237 declare_toplevel_type(volatile Metadata*) \ 81.238 \ 81.239 + declare_toplevel_type(DataLayout) \ 81.240 declare_toplevel_type(nmethodBucket) \ 81.241 \ 81.242 /********/ \ 81.243 @@ -1432,6 +1484,7 @@ 81.244 declare_type(ModRefBarrierSet, BarrierSet) \ 81.245 declare_type(CardTableModRefBS, ModRefBarrierSet) \ 81.246 declare_type(CardTableModRefBSForCTRS, CardTableModRefBS) \ 81.247 + declare_toplevel_type(BarrierSet::Name) \ 81.248 declare_toplevel_type(GenRemSet) \ 81.249 declare_type(CardTableRS, GenRemSet) \ 81.250 declare_toplevel_type(BlockOffsetSharedArray) \ 81.251 @@ -1450,6 +1503,8 @@ 81.252 declare_toplevel_type(ThreadLocalAllocBuffer) \ 81.253 declare_toplevel_type(VirtualSpace) \ 81.254 declare_toplevel_type(WaterMark) \ 81.255 + declare_toplevel_type(ObjPtrQueue) \ 81.256 + declare_toplevel_type(DirtyCardQueue) \ 81.257 \ 81.258 /* Pointers to Garbage Collection types */ \ 81.259 \ 81.260 @@ -2068,6 +2123,7 @@ 81.261 declare_toplevel_type(StubQueue*) \ 81.262 declare_toplevel_type(Thread*) \ 81.263 declare_toplevel_type(Universe) \ 81.264 + declare_toplevel_type(os) \ 81.265 declare_toplevel_type(vframeArray) \ 81.266 declare_toplevel_type(vframeArrayElement) \ 81.267 declare_toplevel_type(Annotations*) \ 81.268 @@ -2076,6 +2132,8 @@ 81.269 /* Miscellaneous types */ \ 81.270 /***************/ \ 81.271 \ 81.272 + declare_toplevel_type(PtrQueue) \ 81.273 + \ 81.274 /* freelist */ \ 81.275 declare_toplevel_type(FreeChunk*) \ 81.276 declare_toplevel_type(Metablock*) \ 81.277 @@ -2106,6 +2164,7 @@ 81.278 /* Useful globals */ \ 81.279 /******************/ \ 81.280 \ 81.281 + declare_preprocessor_constant("ASSERT", DEBUG_ONLY(1) NOT_DEBUG(0)) \ 81.282 \ 81.283 /**************/ \ 81.284 /* Stack bias */ \ 81.285 @@ -2122,6 +2181,8 @@ 81.286 declare_constant(BytesPerWord) \ 81.287 declare_constant(BytesPerLong) \ 81.288 \ 81.289 + declare_constant(LogKlassAlignmentInBytes) \ 81.290 + \ 81.291 /********************************************/ \ 81.292 /* Generation and Space Hierarchy Constants */ \ 81.293 /********************************************/ \ 81.294 @@ -2130,6 +2191,9 @@ 81.295 \ 81.296 declare_constant(BarrierSet::ModRef) \ 81.297 declare_constant(BarrierSet::CardTableModRef) \ 81.298 + declare_constant(BarrierSet::CardTableExtension) \ 81.299 + declare_constant(BarrierSet::G1SATBCT) \ 81.300 + declare_constant(BarrierSet::G1SATBCTLogging) \ 81.301 declare_constant(BarrierSet::Other) \ 81.302 \ 81.303 declare_constant(BlockOffsetSharedArray::LogN) \ 81.304 @@ -2248,8 +2312,11 @@ 81.305 declare_constant(Klass::_primary_super_limit) \ 81.306 declare_constant(Klass::_lh_instance_slow_path_bit) \ 81.307 declare_constant(Klass::_lh_log2_element_size_shift) \ 81.308 + declare_constant(Klass::_lh_log2_element_size_mask) \ 81.309 declare_constant(Klass::_lh_element_type_shift) \ 81.310 + declare_constant(Klass::_lh_element_type_mask) \ 81.311 declare_constant(Klass::_lh_header_size_shift) \ 81.312 + declare_constant(Klass::_lh_header_size_mask) \ 81.313 declare_constant(Klass::_lh_array_tag_shift) \ 81.314 declare_constant(Klass::_lh_array_tag_type_value) \ 81.315 declare_constant(Klass::_lh_array_tag_obj_value) \ 81.316 @@ -2268,6 +2335,12 @@ 81.317 declare_constant(ConstMethod::_has_default_annotations) \ 81.318 declare_constant(ConstMethod::_has_type_annotations) \ 81.319 \ 81.320 + /**************/ \ 81.321 + /* DataLayout */ \ 81.322 + /**************/ \ 81.323 + \ 81.324 + declare_constant(DataLayout::cell_size) \ 81.325 + \ 81.326 /*************************************/ \ 81.327 /* InstanceKlass enum */ \ 81.328 /*************************************/ \ 81.329 @@ -2402,6 +2475,13 @@ 81.330 declare_constant(Deoptimization::Reason_LIMIT) \ 81.331 declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ 81.332 \ 81.333 + declare_constant(Deoptimization::Action_none) \ 81.334 + declare_constant(Deoptimization::Action_maybe_recompile) \ 81.335 + declare_constant(Deoptimization::Action_reinterpret) \ 81.336 + declare_constant(Deoptimization::Action_make_not_entrant) \ 81.337 + declare_constant(Deoptimization::Action_make_not_compilable) \ 81.338 + declare_constant(Deoptimization::Action_LIMIT) \ 81.339 + \ 81.340 /*********************/ \ 81.341 /* Matcher (C2 only) */ \ 81.342 /*********************/ \ 81.343 @@ -2468,6 +2548,16 @@ 81.344 declare_constant(vmSymbols::FIRST_SID) \ 81.345 declare_constant(vmSymbols::SID_LIMIT) \ 81.346 \ 81.347 + /****************/ \ 81.348 + /* vmIntrinsics */ \ 81.349 + /****************/ \ 81.350 + \ 81.351 + declare_constant(vmIntrinsics::_invokeBasic) \ 81.352 + declare_constant(vmIntrinsics::_linkToVirtual) \ 81.353 + declare_constant(vmIntrinsics::_linkToStatic) \ 81.354 + declare_constant(vmIntrinsics::_linkToSpecial) \ 81.355 + declare_constant(vmIntrinsics::_linkToInterface) \ 81.356 + \ 81.357 /********************************/ \ 81.358 /* Calling convention constants */ \ 81.359 /********************************/ \ 81.360 @@ -2515,6 +2605,8 @@ 81.361 declare_constant(markOopDesc::biased_lock_bit_in_place) \ 81.362 declare_constant(markOopDesc::age_mask) \ 81.363 declare_constant(markOopDesc::age_mask_in_place) \ 81.364 + declare_constant(markOopDesc::epoch_mask) \ 81.365 + declare_constant(markOopDesc::epoch_mask_in_place) \ 81.366 declare_constant(markOopDesc::hash_mask) \ 81.367 declare_constant(markOopDesc::hash_mask_in_place) \ 81.368 declare_constant(markOopDesc::biased_lock_alignment) \
82.1 --- a/src/share/vm/services/gcNotifier.cpp Sat Sep 21 10:09:42 2013 +0200 82.2 +++ b/src/share/vm/services/gcNotifier.cpp Tue Sep 24 10:14:02 2013 +0200 82.3 @@ -209,7 +209,7 @@ 82.4 GCNotificationRequest *request = getRequest(); 82.5 if (request != NULL) { 82.6 NotificationMark nm(request); 82.7 - Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD); 82.8 + Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, CHECK); 82.9 82.10 Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK); 82.11 Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
83.1 --- a/src/share/vm/services/memPtr.cpp Sat Sep 21 10:09:42 2013 +0200 83.2 +++ b/src/share/vm/services/memPtr.cpp Tue Sep 24 10:14:02 2013 +0200 83.3 @@ -1,5 +1,5 @@ 83.4 /* 83.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 83.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 83.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 83.8 * 83.9 * This code is free software; you can redistribute it and/or modify it 83.10 @@ -34,9 +34,9 @@ 83.11 jint seq = Atomic::add(1, &_seq_number); 83.12 if (seq < 0) { 83.13 MemTracker::shutdown(MemTracker::NMT_sequence_overflow); 83.14 + } else { 83.15 + NOT_PRODUCT(_max_seq_number = (seq > _max_seq_number) ? seq : _max_seq_number;) 83.16 } 83.17 - assert(seq > 0, "counter overflow"); 83.18 - NOT_PRODUCT(_max_seq_number = (seq > _max_seq_number) ? seq : _max_seq_number;) 83.19 return seq; 83.20 } 83.21
84.1 --- a/src/share/vm/trace/traceMacros.hpp Sat Sep 21 10:09:42 2013 +0200 84.2 +++ b/src/share/vm/trace/traceMacros.hpp Tue Sep 24 10:14:02 2013 +0200 84.3 @@ -26,6 +26,7 @@ 84.4 #define SHARE_VM_TRACE_TRACE_MACRO_HPP 84.5 84.6 #define EVENT_THREAD_EXIT(thread) 84.7 +#define EVENT_THREAD_DESTRUCT(thread) 84.8 84.9 #define TRACE_INIT_ID(k) 84.10 #define TRACE_DATA TraceThreadData
85.1 --- a/src/share/vm/utilities/decoder.cpp Sat Sep 21 10:09:42 2013 +0200 85.2 +++ b/src/share/vm/utilities/decoder.cpp Tue Sep 24 10:14:02 2013 +0200 85.3 @@ -24,7 +24,6 @@ 85.4 85.5 #include "precompiled.hpp" 85.6 #include "prims/jvm.h" 85.7 -#include "runtime/mutexLocker.hpp" 85.8 #include "runtime/os.hpp" 85.9 #include "utilities/decoder.hpp" 85.10 #include "utilities/vmError.hpp" 85.11 @@ -80,6 +79,23 @@ 85.12 return decoder; 85.13 } 85.14 85.15 +inline bool DecoderLocker::is_first_error_thread() { 85.16 + return (os::current_thread_id() == VMError::get_first_error_tid()); 85.17 +} 85.18 + 85.19 +DecoderLocker::DecoderLocker() : 85.20 + MutexLockerEx(DecoderLocker::is_first_error_thread() ? 85.21 + NULL : Decoder::shared_decoder_lock(), true) { 85.22 + _decoder = is_first_error_thread() ? 85.23 + Decoder::get_error_handler_instance() : Decoder::get_shared_instance(); 85.24 + assert(_decoder != NULL, "null decoder"); 85.25 +} 85.26 + 85.27 +Mutex* Decoder::shared_decoder_lock() { 85.28 + assert(_shared_decoder_lock != NULL, "Just check"); 85.29 + return _shared_decoder_lock; 85.30 +} 85.31 + 85.32 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { 85.33 assert(_shared_decoder_lock != NULL, "Just check"); 85.34 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
86.1 --- a/src/share/vm/utilities/decoder.hpp Sat Sep 21 10:09:42 2013 +0200 86.2 +++ b/src/share/vm/utilities/decoder.hpp Tue Sep 24 10:14:02 2013 +0200 86.3 @@ -28,6 +28,7 @@ 86.4 86.5 #include "memory/allocation.hpp" 86.6 #include "runtime/mutex.hpp" 86.7 +#include "runtime/mutexLocker.hpp" 86.8 86.9 class AbstractDecoder : public CHeapObj<mtInternal> { 86.10 public: 86.11 @@ -124,6 +125,19 @@ 86.12 86.13 protected: 86.14 static Mutex* _shared_decoder_lock; 86.15 + static Mutex* shared_decoder_lock(); 86.16 + 86.17 + friend class DecoderLocker; 86.18 +}; 86.19 + 86.20 +class DecoderLocker : public MutexLockerEx { 86.21 + AbstractDecoder* _decoder; 86.22 + inline bool is_first_error_thread(); 86.23 +public: 86.24 + DecoderLocker(); 86.25 + AbstractDecoder* decoder() { 86.26 + return _decoder; 86.27 + } 86.28 }; 86.29 86.30 #endif // SHARE_VM_UTILITIES_DECODER_HPP
87.1 --- a/src/share/vm/utilities/ostream.cpp Sat Sep 21 10:09:42 2013 +0200 87.2 +++ b/src/share/vm/utilities/ostream.cpp Tue Sep 24 10:14:02 2013 +0200 87.3 @@ -342,7 +342,7 @@ 87.4 } 87.5 87.6 char* stringStream::as_string() { 87.7 - char* copy = NEW_RESOURCE_ARRAY(char, buffer_pos+1); 87.8 + char* copy = NEW_RESOURCE_ARRAY(char, buffer_pos + 1); 87.9 strncpy(copy, buffer, buffer_pos); 87.10 copy[buffer_pos] = 0; // terminating null 87.11 return copy; 87.12 @@ -355,14 +355,190 @@ 87.13 outputStream* gclog_or_tty; 87.14 extern Mutex* tty_lock; 87.15 87.16 +#define EXTRACHARLEN 32 87.17 +#define CURRENTAPPX ".current" 87.18 +#define FILENAMEBUFLEN 1024 87.19 +// convert YYYY-MM-DD HH:MM:SS to YYYY-MM-DD_HH-MM-SS 87.20 +char* get_datetime_string(char *buf, size_t len) { 87.21 + os::local_time_string(buf, len); 87.22 + int i = (int)strlen(buf); 87.23 + while (i-- >= 0) { 87.24 + if (buf[i] == ' ') buf[i] = '_'; 87.25 + else if (buf[i] == ':') buf[i] = '-'; 87.26 + } 87.27 + return buf; 87.28 +} 87.29 + 87.30 +static const char* make_log_name_internal(const char* log_name, const char* force_directory, 87.31 + int pid, const char* tms) { 87.32 + const char* basename = log_name; 87.33 + char file_sep = os::file_separator()[0]; 87.34 + const char* cp; 87.35 + char pid_text[32]; 87.36 + 87.37 + for (cp = log_name; *cp != '\0'; cp++) { 87.38 + if (*cp == '/' || *cp == file_sep) { 87.39 + basename = cp + 1; 87.40 + } 87.41 + } 87.42 + const char* nametail = log_name; 87.43 + // Compute buffer length 87.44 + size_t buffer_length; 87.45 + if (force_directory != NULL) { 87.46 + buffer_length = strlen(force_directory) + strlen(os::file_separator()) + 87.47 + strlen(basename) + 1; 87.48 + } else { 87.49 + buffer_length = strlen(log_name) + 1; 87.50 + } 87.51 + 87.52 + // const char* star = strchr(basename, '*'); 87.53 + const char* pts = strstr(basename, "%p"); 87.54 + int pid_pos = (pts == NULL) ? -1 : (pts - nametail); 87.55 + 87.56 + if (pid_pos >= 0) { 87.57 + jio_snprintf(pid_text, sizeof(pid_text), "pid%u", pid); 87.58 + buffer_length += strlen(pid_text); 87.59 + } 87.60 + 87.61 + pts = strstr(basename, "%t"); 87.62 + int tms_pos = (pts == NULL) ? -1 : (pts - nametail); 87.63 + if (tms_pos >= 0) { 87.64 + buffer_length += strlen(tms); 87.65 + } 87.66 + 87.67 + // Create big enough buffer. 87.68 + char *buf = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal); 87.69 + 87.70 + strcpy(buf, ""); 87.71 + if (force_directory != NULL) { 87.72 + strcat(buf, force_directory); 87.73 + strcat(buf, os::file_separator()); 87.74 + nametail = basename; // completely skip directory prefix 87.75 + } 87.76 + 87.77 + // who is first, %p or %t? 87.78 + int first = -1, second = -1; 87.79 + const char *p1st = NULL; 87.80 + const char *p2nd = NULL; 87.81 + 87.82 + if (pid_pos >= 0 && tms_pos >= 0) { 87.83 + // contains both %p and %t 87.84 + if (pid_pos < tms_pos) { 87.85 + // case foo%pbar%tmonkey.log 87.86 + first = pid_pos; 87.87 + p1st = pid_text; 87.88 + second = tms_pos; 87.89 + p2nd = tms; 87.90 + } else { 87.91 + // case foo%tbar%pmonkey.log 87.92 + first = tms_pos; 87.93 + p1st = tms; 87.94 + second = pid_pos; 87.95 + p2nd = pid_text; 87.96 + } 87.97 + } else if (pid_pos >= 0) { 87.98 + // contains %p only 87.99 + first = pid_pos; 87.100 + p1st = pid_text; 87.101 + } else if (tms_pos >= 0) { 87.102 + // contains %t only 87.103 + first = tms_pos; 87.104 + p1st = tms; 87.105 + } 87.106 + 87.107 + int buf_pos = (int)strlen(buf); 87.108 + const char* tail = nametail; 87.109 + 87.110 + if (first >= 0) { 87.111 + tail = nametail + first + 2; 87.112 + strncpy(&buf[buf_pos], nametail, first); 87.113 + strcpy(&buf[buf_pos + first], p1st); 87.114 + buf_pos = (int)strlen(buf); 87.115 + if (second >= 0) { 87.116 + strncpy(&buf[buf_pos], tail, second - first - 2); 87.117 + strcpy(&buf[buf_pos + second - first - 2], p2nd); 87.118 + tail = nametail + second + 2; 87.119 + } 87.120 + } 87.121 + strcat(buf, tail); // append rest of name, or all of name 87.122 + return buf; 87.123 +} 87.124 + 87.125 +// log_name comes from -XX:LogFile=log_name or -Xloggc:log_name 87.126 +// in log_name, %p => pipd1234 and 87.127 +// %t => YYYY-MM-DD_HH-MM-SS 87.128 +static const char* make_log_name(const char* log_name, const char* force_directory) { 87.129 + char timestr[32]; 87.130 + get_datetime_string(timestr, sizeof(timestr)); 87.131 + return make_log_name_internal(log_name, force_directory, os::current_process_id(), 87.132 + timestr); 87.133 +} 87.134 + 87.135 +#ifndef PRODUCT 87.136 +void test_loggc_filename() { 87.137 + int pid; 87.138 + char tms[32]; 87.139 + char i_result[FILENAMEBUFLEN]; 87.140 + const char* o_result; 87.141 + get_datetime_string(tms, sizeof(tms)); 87.142 + pid = os::current_process_id(); 87.143 + 87.144 + // test.log 87.145 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "test.log", tms); 87.146 + o_result = make_log_name_internal("test.log", NULL, pid, tms); 87.147 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test.log\", NULL)"); 87.148 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.149 + 87.150 + // test-%t-%p.log 87.151 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "test-%s-pid%u.log", tms, pid); 87.152 + o_result = make_log_name_internal("test-%t-%p.log", NULL, pid, tms); 87.153 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test-%%t-%%p.log\", NULL)"); 87.154 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.155 + 87.156 + // test-%t%p.log 87.157 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "test-%spid%u.log", tms, pid); 87.158 + o_result = make_log_name_internal("test-%t%p.log", NULL, pid, tms); 87.159 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test-%%t%%p.log\", NULL)"); 87.160 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.161 + 87.162 + // %p%t.log 87.163 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "pid%u%s.log", pid, tms); 87.164 + o_result = make_log_name_internal("%p%t.log", NULL, pid, tms); 87.165 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p%%t.log\", NULL)"); 87.166 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.167 + 87.168 + // %p-test.log 87.169 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "pid%u-test.log", pid); 87.170 + o_result = make_log_name_internal("%p-test.log", NULL, pid, tms); 87.171 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p-test.log\", NULL)"); 87.172 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.173 + 87.174 + // %t.log 87.175 + jio_snprintf(i_result, sizeof(char)*FILENAMEBUFLEN, "%s.log", tms); 87.176 + o_result = make_log_name_internal("%t.log", NULL, pid, tms); 87.177 + assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%t.log\", NULL)"); 87.178 + FREE_C_HEAP_ARRAY(char, o_result, mtInternal); 87.179 +} 87.180 +#endif // PRODUCT 87.181 + 87.182 fileStream::fileStream(const char* file_name) { 87.183 _file = fopen(file_name, "w"); 87.184 - _need_close = true; 87.185 + if (_file != NULL) { 87.186 + _need_close = true; 87.187 + } else { 87.188 + warning("Cannot open file %s due to %s\n", file_name, strerror(errno)); 87.189 + _need_close = false; 87.190 + } 87.191 } 87.192 87.193 fileStream::fileStream(const char* file_name, const char* opentype) { 87.194 _file = fopen(file_name, opentype); 87.195 - _need_close = true; 87.196 + if (_file != NULL) { 87.197 + _need_close = true; 87.198 + } else { 87.199 + warning("Cannot open file %s due to %s\n", file_name, strerror(errno)); 87.200 + _need_close = false; 87.201 + } 87.202 } 87.203 87.204 void fileStream::write(const char* s, size_t len) { 87.205 @@ -423,34 +599,51 @@ 87.206 update_position(s, len); 87.207 } 87.208 87.209 -rotatingFileStream::~rotatingFileStream() { 87.210 +// dump vm version, os version, platform info, build id, 87.211 +// memory usage and command line flags into header 87.212 +void gcLogFileStream::dump_loggc_header() { 87.213 + if (is_open()) { 87.214 + print_cr(Abstract_VM_Version::internal_vm_info_string()); 87.215 + os::print_memory_info(this); 87.216 + print("CommandLine flags: "); 87.217 + CommandLineFlags::printSetFlags(this); 87.218 + } 87.219 +} 87.220 + 87.221 +gcLogFileStream::~gcLogFileStream() { 87.222 if (_file != NULL) { 87.223 if (_need_close) fclose(_file); 87.224 - _file = NULL; 87.225 + _file = NULL; 87.226 + } 87.227 + if (_file_name != NULL) { 87.228 FREE_C_HEAP_ARRAY(char, _file_name, mtInternal); 87.229 _file_name = NULL; 87.230 } 87.231 } 87.232 87.233 -rotatingFileStream::rotatingFileStream(const char* file_name) { 87.234 +gcLogFileStream::gcLogFileStream(const char* file_name) { 87.235 _cur_file_num = 0; 87.236 _bytes_written = 0L; 87.237 - _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); 87.238 - jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); 87.239 - _file = fopen(_file_name, "w"); 87.240 - _need_close = true; 87.241 + _file_name = make_log_name(file_name, NULL); 87.242 + 87.243 + // gc log file rotation 87.244 + if (UseGCLogFileRotation && NumberOfGCLogFiles > 1) { 87.245 + char tempbuf[FILENAMEBUFLEN]; 87.246 + jio_snprintf(tempbuf, sizeof(tempbuf), "%s.%d" CURRENTAPPX, _file_name, _cur_file_num); 87.247 + _file = fopen(tempbuf, "w"); 87.248 + } else { 87.249 + _file = fopen(_file_name, "w"); 87.250 + } 87.251 + if (_file != NULL) { 87.252 + _need_close = true; 87.253 + dump_loggc_header(); 87.254 + } else { 87.255 + warning("Cannot open file %s due to %s\n", _file_name, strerror(errno)); 87.256 + _need_close = false; 87.257 + } 87.258 } 87.259 87.260 -rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) { 87.261 - _cur_file_num = 0; 87.262 - _bytes_written = 0L; 87.263 - _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); 87.264 - jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); 87.265 - _file = fopen(_file_name, opentype); 87.266 - _need_close = true; 87.267 -} 87.268 - 87.269 -void rotatingFileStream::write(const char* s, size_t len) { 87.270 +void gcLogFileStream::write(const char* s, size_t len) { 87.271 if (_file != NULL) { 87.272 size_t count = fwrite(s, 1, len, _file); 87.273 _bytes_written += count; 87.274 @@ -466,7 +659,12 @@ 87.275 // write to gc log file at safepoint. If in future, changes made for mutator threads or 87.276 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log 87.277 // must be synchronized. 87.278 -void rotatingFileStream::rotate_log() { 87.279 +void gcLogFileStream::rotate_log() { 87.280 + char time_msg[FILENAMEBUFLEN]; 87.281 + char time_str[EXTRACHARLEN]; 87.282 + char current_file_name[FILENAMEBUFLEN]; 87.283 + char renamed_file_name[FILENAMEBUFLEN]; 87.284 + 87.285 if (_bytes_written < (jlong)GCLogFileSize) { 87.286 return; 87.287 } 87.288 @@ -481,27 +679,89 @@ 87.289 // rotate in same file 87.290 rewind(); 87.291 _bytes_written = 0L; 87.292 + jio_snprintf(time_msg, sizeof(time_msg), "File %s rotated at %s\n", 87.293 + _file_name, os::local_time_string((char *)time_str, sizeof(time_str))); 87.294 + write(time_msg, strlen(time_msg)); 87.295 + dump_loggc_header(); 87.296 return; 87.297 } 87.298 87.299 - // rotate file in names file.0, file.1, file.2, ..., file.<MaxGCLogFileNumbers-1> 87.300 - // close current file, rotate to next file 87.301 +#if defined(_WINDOWS) 87.302 +#ifndef F_OK 87.303 +#define F_OK 0 87.304 +#endif 87.305 +#endif // _WINDOWS 87.306 + 87.307 + // rotate file in names extended_filename.0, extended_filename.1, ..., 87.308 + // extended_filename.<NumberOfGCLogFiles - 1>. Current rotation file name will 87.309 + // have a form of extended_filename.<i>.current where i is the current rotation 87.310 + // file number. After it reaches max file size, the file will be saved and renamed 87.311 + // with .current removed from its tail. 87.312 + size_t filename_len = strlen(_file_name); 87.313 if (_file != NULL) { 87.314 - _cur_file_num ++; 87.315 - if (_cur_file_num >= NumberOfGCLogFiles) _cur_file_num = 0; 87.316 - jio_snprintf(_file_name, strlen(Arguments::gc_log_filename()) + 10, "%s.%d", 87.317 - Arguments::gc_log_filename(), _cur_file_num); 87.318 + jio_snprintf(renamed_file_name, filename_len + EXTRACHARLEN, "%s.%d", 87.319 + _file_name, _cur_file_num); 87.320 + jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX, 87.321 + _file_name, _cur_file_num); 87.322 + jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file has reached the" 87.323 + " maximum size. Saved as %s\n", 87.324 + os::local_time_string((char *)time_str, sizeof(time_str)), 87.325 + renamed_file_name); 87.326 + write(time_msg, strlen(time_msg)); 87.327 + 87.328 fclose(_file); 87.329 _file = NULL; 87.330 + 87.331 + bool can_rename = true; 87.332 + if (access(current_file_name, F_OK) != 0) { 87.333 + // current file does not exist? 87.334 + warning("No source file exists, cannot rename\n"); 87.335 + can_rename = false; 87.336 + } 87.337 + if (can_rename) { 87.338 + if (access(renamed_file_name, F_OK) == 0) { 87.339 + if (remove(renamed_file_name) != 0) { 87.340 + warning("Could not delete existing file %s\n", renamed_file_name); 87.341 + can_rename = false; 87.342 + } 87.343 + } else { 87.344 + // file does not exist, ok to rename 87.345 + } 87.346 + } 87.347 + if (can_rename && rename(current_file_name, renamed_file_name) != 0) { 87.348 + warning("Could not rename %s to %s\n", _file_name, renamed_file_name); 87.349 + } 87.350 } 87.351 - _file = fopen(_file_name, "w"); 87.352 + 87.353 + _cur_file_num++; 87.354 + if (_cur_file_num > NumberOfGCLogFiles - 1) _cur_file_num = 0; 87.355 + jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX, 87.356 + _file_name, _cur_file_num); 87.357 + _file = fopen(current_file_name, "w"); 87.358 + 87.359 if (_file != NULL) { 87.360 _bytes_written = 0L; 87.361 _need_close = true; 87.362 + // reuse current_file_name for time_msg 87.363 + jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, 87.364 + "%s.%d", _file_name, _cur_file_num); 87.365 + jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file created %s\n", 87.366 + os::local_time_string((char *)time_str, sizeof(time_str)), 87.367 + current_file_name); 87.368 + write(time_msg, strlen(time_msg)); 87.369 + dump_loggc_header(); 87.370 + // remove the existing file 87.371 + if (access(current_file_name, F_OK) == 0) { 87.372 + if (remove(current_file_name) != 0) { 87.373 + warning("Could not delete existing file %s\n", current_file_name); 87.374 + } 87.375 + } 87.376 } else { 87.377 - tty->print_cr("failed to open rotation log file %s due to %s\n", 87.378 + warning("failed to open rotation log file %s due to %s\n" 87.379 + "Turned off GC log file rotation\n", 87.380 _file_name, strerror(errno)); 87.381 _need_close = false; 87.382 + FLAG_SET_DEFAULT(UseGCLogFileRotation, false); 87.383 } 87.384 } 87.385 87.386 @@ -530,69 +790,9 @@ 87.387 return _log_file != NULL; 87.388 } 87.389 87.390 -static const char* make_log_name(const char* log_name, const char* force_directory) { 87.391 - const char* basename = log_name; 87.392 - char file_sep = os::file_separator()[0]; 87.393 - const char* cp; 87.394 - for (cp = log_name; *cp != '\0'; cp++) { 87.395 - if (*cp == '/' || *cp == file_sep) { 87.396 - basename = cp+1; 87.397 - } 87.398 - } 87.399 - const char* nametail = log_name; 87.400 - 87.401 - // Compute buffer length 87.402 - size_t buffer_length; 87.403 - if (force_directory != NULL) { 87.404 - buffer_length = strlen(force_directory) + strlen(os::file_separator()) + 87.405 - strlen(basename) + 1; 87.406 - } else { 87.407 - buffer_length = strlen(log_name) + 1; 87.408 - } 87.409 - 87.410 - const char* star = strchr(basename, '*'); 87.411 - int star_pos = (star == NULL) ? -1 : (star - nametail); 87.412 - int skip = 1; 87.413 - if (star == NULL) { 87.414 - // Try %p 87.415 - star = strstr(basename, "%p"); 87.416 - if (star != NULL) { 87.417 - skip = 2; 87.418 - } 87.419 - } 87.420 - star_pos = (star == NULL) ? -1 : (star - nametail); 87.421 - 87.422 - char pid[32]; 87.423 - if (star_pos >= 0) { 87.424 - jio_snprintf(pid, sizeof(pid), "%u", os::current_process_id()); 87.425 - buffer_length += strlen(pid); 87.426 - } 87.427 - 87.428 - // Create big enough buffer. 87.429 - char *buf = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal); 87.430 - 87.431 - strcpy(buf, ""); 87.432 - if (force_directory != NULL) { 87.433 - strcat(buf, force_directory); 87.434 - strcat(buf, os::file_separator()); 87.435 - nametail = basename; // completely skip directory prefix 87.436 - } 87.437 - 87.438 - if (star_pos >= 0) { 87.439 - // convert foo*bar.log or foo%pbar.log to foo123bar.log 87.440 - int buf_pos = (int) strlen(buf); 87.441 - strncpy(&buf[buf_pos], nametail, star_pos); 87.442 - strcpy(&buf[buf_pos + star_pos], pid); 87.443 - nametail += star_pos + skip; // skip prefix and pid format 87.444 - } 87.445 - 87.446 - strcat(buf, nametail); // append rest of name, or all of name 87.447 - return buf; 87.448 -} 87.449 - 87.450 void defaultStream::init_log() { 87.451 // %%% Need a MutexLocker? 87.452 - const char* log_name = LogFile != NULL ? LogFile : "hotspot.log"; 87.453 + const char* log_name = LogFile != NULL ? LogFile : "hotspot_pid%p.log"; 87.454 const char* try_name = make_log_name(log_name, NULL); 87.455 fileStream* file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name); 87.456 if (!file->is_open()) { 87.457 @@ -603,14 +803,15 @@ 87.458 // Note: This feature is for maintainer use only. No need for L10N. 87.459 jio_print(warnbuf); 87.460 FREE_C_HEAP_ARRAY(char, try_name, mtInternal); 87.461 - try_name = make_log_name("hs_pid%p.log", os::get_temp_directory()); 87.462 + try_name = make_log_name(log_name, os::get_temp_directory()); 87.463 jio_snprintf(warnbuf, sizeof(warnbuf), 87.464 "Warning: Forcing option -XX:LogFile=%s\n", try_name); 87.465 jio_print(warnbuf); 87.466 delete file; 87.467 file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name); 87.468 - FREE_C_HEAP_ARRAY(char, try_name, mtInternal); 87.469 } 87.470 + FREE_C_HEAP_ARRAY(char, try_name, mtInternal); 87.471 + 87.472 if (file->is_open()) { 87.473 _log_file = file; 87.474 xmlStream* xs = new(ResourceObj::C_HEAP, mtInternal) xmlStream(file); 87.475 @@ -877,11 +1078,8 @@ 87.476 87.477 gclog_or_tty = tty; // default to tty 87.478 if (Arguments::gc_log_filename() != NULL) { 87.479 - fileStream * gclog = UseGCLogFileRotation ? 87.480 - new(ResourceObj::C_HEAP, mtInternal) 87.481 - rotatingFileStream(Arguments::gc_log_filename()) : 87.482 - new(ResourceObj::C_HEAP, mtInternal) 87.483 - fileStream(Arguments::gc_log_filename()); 87.484 + fileStream * gclog = new(ResourceObj::C_HEAP, mtInternal) 87.485 + gcLogFileStream(Arguments::gc_log_filename()); 87.486 if (gclog->is_open()) { 87.487 // now we update the time stamp of the GC log to be synced up 87.488 // with tty.
88.1 --- a/src/share/vm/utilities/ostream.hpp Sat Sep 21 10:09:42 2013 +0200 88.2 +++ b/src/share/vm/utilities/ostream.hpp Tue Sep 24 10:14:02 2013 +0200 88.3 @@ -231,20 +231,24 @@ 88.4 void flush() {}; 88.5 }; 88.6 88.7 -class rotatingFileStream : public fileStream { 88.8 +class gcLogFileStream : public fileStream { 88.9 protected: 88.10 - char* _file_name; 88.11 + const char* _file_name; 88.12 jlong _bytes_written; 88.13 - uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1 88.14 + uintx _cur_file_num; // current logfile rotation number, from 0 to NumberOfGCLogFiles-1 88.15 public: 88.16 - rotatingFileStream(const char* file_name); 88.17 - rotatingFileStream(const char* file_name, const char* opentype); 88.18 - rotatingFileStream(FILE* file) : fileStream(file) {} 88.19 - ~rotatingFileStream(); 88.20 + gcLogFileStream(const char* file_name); 88.21 + ~gcLogFileStream(); 88.22 virtual void write(const char* c, size_t len); 88.23 virtual void rotate_log(); 88.24 + void dump_loggc_header(); 88.25 }; 88.26 88.27 +#ifndef PRODUCT 88.28 +// unit test for checking -Xloggc:<filename> parsing result 88.29 +void test_loggc_filename(); 88.30 +#endif 88.31 + 88.32 void ostream_init(); 88.33 void ostream_init_log(); 88.34 void ostream_exit();
89.1 --- a/src/share/vm/utilities/vmError.cpp Sat Sep 21 10:09:42 2013 +0200 89.2 +++ b/src/share/vm/utilities/vmError.cpp Tue Sep 24 10:14:02 2013 +0200 89.3 @@ -574,6 +574,10 @@ 89.4 STEP(120, "(printing native stack)" ) 89.5 89.6 if (_verbose) { 89.7 + if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) { 89.8 + // We have printed the native stack in platform-specific code 89.9 + // Windows/x64 needs special handling. 89.10 + } else { 89.11 frame fr = _context ? os::fetch_frame_from_context(_context) 89.12 : os::current_frame(); 89.13 89.14 @@ -604,6 +608,7 @@ 89.15 st->cr(); 89.16 } 89.17 } 89.18 + } 89.19 89.20 STEP(130, "(printing Java stack)" ) 89.21
90.1 --- a/src/share/vm/utilities/vmError.hpp Sat Sep 21 10:09:42 2013 +0200 90.2 +++ b/src/share/vm/utilities/vmError.hpp Tue Sep 24 10:14:02 2013 +0200 90.3 @@ -136,6 +136,10 @@ 90.4 90.5 // check to see if fatal error reporting is in progress 90.6 static bool fatal_error_in_progress() { return first_error != NULL; } 90.7 + 90.8 + static jlong get_first_error_tid() { 90.9 + return first_error_tid; 90.10 + } 90.11 }; 90.12 90.13 #endif // SHARE_VM_UTILITIES_VMERROR_HPP
91.1 --- a/src/share/vm/utilities/yieldingWorkgroup.hpp Sat Sep 21 10:09:42 2013 +0200 91.2 +++ b/src/share/vm/utilities/yieldingWorkgroup.hpp Tue Sep 24 10:14:02 2013 +0200 91.3 @@ -1,5 +1,5 @@ 91.4 /* 91.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 91.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 91.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 91.8 * 91.9 * This code is free software; you can redistribute it and/or modify it 91.10 @@ -26,10 +26,7 @@ 91.11 #define SHARE_VM_UTILITIES_YIELDINGWORKGROUP_HPP 91.12 91.13 #include "utilities/macros.hpp" 91.14 -#if INCLUDE_ALL_GCS 91.15 #include "utilities/workgroup.hpp" 91.16 -#endif // INCLUDE_ALL_GCS 91.17 - 91.18 91.19 // Forward declarations 91.20 class YieldingFlexibleWorkGang;
92.1 --- a/test/TEST.groups Sat Sep 21 10:09:42 2013 +0200 92.2 +++ b/test/TEST.groups Tue Sep 24 10:14:02 2013 +0200 92.3 @@ -84,6 +84,7 @@ 92.4 runtime/NMT/ThreadedVirtualAllocTestType.java \ 92.5 runtime/NMT/VirtualAllocTestType.java \ 92.6 runtime/RedefineObject/TestRedefineObject.java \ 92.7 + runtime/XCheckJniJsig/XCheckJSig.java \ 92.8 serviceability/attach/AttachWithStalePidFile.java 92.9 92.10 # JRE adds further tests to compact3 92.11 @@ -159,7 +160,18 @@ 92.12 gc/g1/TestRegionAlignment.java \ 92.13 gc/g1/TestShrinkToOneRegion.java \ 92.14 gc/metaspace/G1AddMetaspaceDependency.java \ 92.15 - runtime/6929067/Test6929067.sh 92.16 + gc/startup_warnings/TestCMS.java \ 92.17 + gc/startup_warnings/TestCMSIncrementalMode.java \ 92.18 + gc/startup_warnings/TestCMSNoIncrementalMode.java \ 92.19 + gc/startup_warnings/TestDefaultMaxRAMFraction.java \ 92.20 + gc/startup_warnings/TestDefNewCMS.java \ 92.21 + gc/startup_warnings/TestIncGC.java \ 92.22 + gc/startup_warnings/TestParallelGC.java \ 92.23 + gc/startup_warnings/TestParallelScavengeSerialOld.java \ 92.24 + gc/startup_warnings/TestParNewCMS.java \ 92.25 + gc/startup_warnings/TestParNewSerialOld.java \ 92.26 + runtime/6929067/Test6929067.sh \ 92.27 + runtime/SharedArchiveFile/SharedArchiveFile.java 92.28 92.29 # Minimal VM on Compact 2 adds in some compact2 tests 92.30 #
93.1 --- a/test/gc/TestVerifyDuringStartup.java Sat Sep 21 10:09:42 2013 +0200 93.2 +++ b/test/gc/TestVerifyDuringStartup.java Tue Sep 24 10:14:02 2013 +0200 93.3 @@ -48,7 +48,7 @@ 93.4 "-XX:+VerifyDuringStartup", 93.5 "-version"}); 93.6 93.7 - System.out.print("Testing:\n" + JDKToolFinder.getCurrentJDKTool("java")); 93.8 + System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java")); 93.9 for (int i = 0; i < vmOpts.size(); i += 1) { 93.10 System.out.print(" " + vmOpts.get(i)); 93.11 }
94.1 --- a/test/runtime/6878713/Test6878713.sh Sat Sep 21 10:09:42 2013 +0200 94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 94.3 @@ -1,137 +0,0 @@ 94.4 -#!/bin/sh 94.5 - 94.6 -# 94.7 -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 94.8 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 94.9 -# 94.10 -# This code is free software; you can redistribute it and/or modify it 94.11 -# under the terms of the GNU General Public License version 2 only, as 94.12 -# published by the Free Software Foundation. 94.13 -# 94.14 -# This code is distributed in the hope that it will be useful, but WITHOUT 94.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 94.16 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 94.17 -# version 2 for more details (a copy is included in the LICENSE file that 94.18 -# accompanied this code). 94.19 -# 94.20 -# You should have received a copy of the GNU General Public License version 94.21 -# 2 along with this work; if not, write to the Free Software Foundation, 94.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 94.23 -# 94.24 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 94.25 -# or visit www.oracle.com if you need additional information or have any 94.26 -# questions. 94.27 -# 94.28 - 94.29 - 94.30 - 94.31 -## 94.32 -## @test 94.33 -## @bug 6878713 94.34 -## @bug 7030610 94.35 -## @bug 7037122 94.36 -## @bug 7123945 94.37 -## @summary Verifier heap corruption, relating to backward jsrs 94.38 -## @run shell Test6878713.sh 94.39 -## 94.40 -## some tests require path to find test source dir 94.41 -if [ "${TESTSRC}" = "" ] 94.42 -then 94.43 - TESTSRC=${PWD} 94.44 - echo "TESTSRC not set. Using "${TESTSRC}" as default" 94.45 -fi 94.46 -echo "TESTSRC=${TESTSRC}" 94.47 -## Adding common setup Variables for running shell tests. 94.48 -. ${TESTSRC}/../../test_env.sh 94.49 - 94.50 -TARGET_CLASS=OOMCrashClass1960_2 94.51 - 94.52 -echo "INFO: extracting the target class." 94.53 -${COMPILEJAVA}${FS}bin${FS}jar xvf \ 94.54 - ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class 94.55 - 94.56 -# remove any hs_err_pid that might exist here 94.57 -rm -f hs_err_pid*.log 94.58 - 94.59 -echo "INFO: checking for 32-bit versus 64-bit VM." 94.60 -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \ 94.61 - | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1 94.62 -status="$?" 94.63 -if [ "$status" = 0 ]; then 94.64 - echo "INFO: testing a 64-bit VM." 94.65 - is_64_bit=true 94.66 -else 94.67 - echo "INFO: testing a 32-bit VM." 94.68 -fi 94.69 - 94.70 -if [ "$is_64_bit" = true ]; then 94.71 - # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296 94.72 - MALLOC_MAX=100663296 94.73 -else 94.74 - # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592 94.75 - MALLOC_MAX=201326592 94.76 -fi 94.77 -echo "INFO: MALLOC_MAX=$MALLOC_MAX" 94.78 - 94.79 -echo "INFO: executing the target class." 94.80 -# -XX:+PrintCommandLineFlags for debugging purposes 94.81 -# -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without 94.82 -# the new -XX:MallocMaxTestWords option 94.83 -# -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords 94.84 -# -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX 94.85 -${TESTJAVA}${FS}bin${FS}java \ 94.86 - -XX:+PrintCommandLineFlags \ 94.87 - -XX:+IgnoreUnrecognizedVMOptions \ 94.88 - -XX:+UnlockDiagnosticVMOptions \ 94.89 - -XX:MallocMaxTestWords=$MALLOC_MAX \ 94.90 - ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1 94.91 - 94.92 -echo "INFO: begin contents of test.out:" 94.93 -cat test.out 94.94 -echo "INFO: end contents of test.out." 94.95 - 94.96 -echo "INFO: checking for memory allocation error message." 94.97 -# We are looking for this specific memory allocation failure mesg so 94.98 -# we know we exercised the right allocation path with the test class: 94.99 -MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes" 94.100 -grep "$MESG1" test.out 94.101 -status="$?" 94.102 -if [ "$status" = 0 ]; then 94.103 - echo "INFO: found expected memory allocation error message." 94.104 -else 94.105 - echo "INFO: did not find expected memory allocation error message." 94.106 - 94.107 - # If we didn't find MESG1 above, then there are several scenarios: 94.108 - # 1) -XX:MallocMaxTestWords is not supported by the current VM and we 94.109 - # didn't fail TARGET_CLASS's memory allocation attempt; instead 94.110 - # we failed to find TARGET_CLASS's main() method. The TARGET_CLASS 94.111 - # is designed to provoke a memory allocation failure during class 94.112 - # loading; we actually don't care about running the class which is 94.113 - # why it doesn't have a main() method. 94.114 - # 2) we failed a memory allocation, but not the one we were looking 94.115 - # so it might be that TARGET_CLASS no longer tickles the same 94.116 - # memory allocation code path 94.117 - # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by 94.118 - # 6878713 because the test is running on a pre-fix VM. 94.119 - echo "INFO: checking for no main() method message." 94.120 - MESG2="Error: Main method not found in class" 94.121 - grep "$MESG2" test.out 94.122 - status="$?" 94.123 - if [ "$status" = 0 ]; then 94.124 - echo "INFO: found no main() method message." 94.125 - else 94.126 - echo "FAIL: did not find no main() method message." 94.127 - # status is non-zero for exit below 94.128 - 94.129 - if [ -s hs_err_pid*.log ]; then 94.130 - echo "INFO: begin contents of hs_err_pid file:" 94.131 - cat hs_err_pid*.log 94.132 - echo "INFO: end contents of hs_err_pid file." 94.133 - fi 94.134 - fi 94.135 -fi 94.136 - 94.137 -if [ "$status" = 0 ]; then 94.138 - echo "PASS: test found one of the expected messages." 94.139 -fi 94.140 -exit "$status"
95.1 Binary file test/runtime/6878713/testcase.jar has changed
96.1 --- a/test/runtime/7020373/Test7020373.sh Sat Sep 21 10:09:42 2013 +0200 96.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 96.3 @@ -1,43 +0,0 @@ 96.4 -#!/bin/sh 96.5 - 96.6 -## 96.7 -## @test 96.8 -## @bug 7020373 7055247 7053586 7185550 96.9 -## @key cte_test 96.10 -## @summary JSR rewriting can overflow memory address size variables 96.11 -## @ignore Ignore it as 7053586 test uses lots of memory. See bug report for detail. 96.12 -## @run shell Test7020373.sh 96.13 -## 96.14 - 96.15 -if [ "${TESTSRC}" = "" ] 96.16 -then 96.17 - TESTSRC=${PWD} 96.18 - echo "TESTSRC not set. Using "${TESTSRC}" as default" 96.19 -fi 96.20 -echo "TESTSRC=${TESTSRC}" 96.21 -## Adding common setup Variables for running shell tests. 96.22 -. ${TESTSRC}/../../test_env.sh 96.23 - 96.24 -${COMPILEJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar 96.25 - 96.26 -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass4000_1 > test.out 2>&1 96.27 - 96.28 -cat test.out 96.29 - 96.30 -egrep "SIGSEGV|An unexpected error has been detected" test.out 96.31 - 96.32 -if [ $? = 0 ] 96.33 -then 96.34 - echo "Test Failed" 96.35 - exit 1 96.36 -else 96.37 - egrep "java.lang.LinkageError|java.lang.NoSuchMethodError|Main method not found in class OOMCrashClass4000_1|insufficient memory" test.out 96.38 - if [ $? = 0 ] 96.39 - then 96.40 - echo "Test Passed" 96.41 - exit 0 96.42 - else 96.43 - echo "Test Failed" 96.44 - exit 1 96.45 - fi 96.46 -fi
97.1 Binary file test/runtime/7020373/testcase.jar has changed
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 98.2 +++ b/test/runtime/ClassFile/JsrRewriting.java Tue Sep 24 10:14:02 2013 +0200 98.3 @@ -0,0 +1,102 @@ 98.4 +/* 98.5 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 98.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 98.7 + * 98.8 + * This code is free software; you can redistribute it and/or modify it 98.9 + * under the terms of the GNU General Public License version 2 only, as 98.10 + * published by the Free Software Foundation. 98.11 + * 98.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 98.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 98.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 98.15 + * version 2 for more details (a copy is included in the LICENSE file that 98.16 + * accompanied this code). 98.17 + * 98.18 + * You should have received a copy of the GNU General Public License version 98.19 + * 2 along with this work; if not, write to the Free Software Foundation, 98.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 98.21 + * 98.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 98.23 + * or visit www.oracle.com if you need additional information or have any 98.24 + * questions. 98.25 + */ 98.26 + 98.27 + 98.28 + 98.29 +/* 98.30 + * @test JsrRewriting 98.31 + * @summary JSR (jump local subroutine) 98.32 + * rewriting can overflow memory address size variables 98.33 + * @bug 7020373 98.34 + * @bug 7055247 98.35 + * @bug 7053586 98.36 + * @bug 7185550 98.37 + * @bug 7149464 98.38 + * @key cte_test 98.39 + * @library /testlibrary 98.40 + * @run main JsrRewriting 98.41 + */ 98.42 + 98.43 +import com.oracle.java.testlibrary.*; 98.44 +import java.io.File; 98.45 + 98.46 +public class JsrRewriting { 98.47 + 98.48 + public static void main(String[] args) throws Exception { 98.49 + 98.50 + // ======= Configure the test 98.51 + String jarFile = System.getProperty("test.src") + 98.52 + File.separator + "JsrRewritingTestCase.jar"; 98.53 + String className = "OOMCrashClass4000_1"; 98.54 + 98.55 + // limit is 768MB in native words 98.56 + int mallocMaxTestWords = (1024 * 1024 * 768 / 4); 98.57 + if (Platform.is64bit()) 98.58 + mallocMaxTestWords = (mallocMaxTestWords / 2); 98.59 + 98.60 + // ======= extract the test class 98.61 + ProcessBuilder pb = new ProcessBuilder(new String[] { 98.62 + JDKToolFinder.getJDKTool("jar"), 98.63 + "xvf", jarFile } ); 98.64 + OutputAnalyzer output = new OutputAnalyzer(pb.start()); 98.65 + output.shouldHaveExitValue(0); 98.66 + 98.67 + // ======= execute the test 98.68 + pb = ProcessTools.createJavaProcessBuilder( 98.69 + "-cp", ".", 98.70 + "-XX:+UnlockDiagnosticVMOptions", 98.71 + "-XX:MallocMaxTestWords=" + mallocMaxTestWords, 98.72 + className); 98.73 + 98.74 + output = new OutputAnalyzer(pb.start()); 98.75 + String[] expectedMsgs = { 98.76 + "java.lang.LinkageError", 98.77 + "java.lang.NoSuchMethodError", 98.78 + "Main method not found in class " + className, 98.79 + "insufficient memory" 98.80 + }; 98.81 + 98.82 + MultipleOrMatch(output, expectedMsgs); 98.83 + } 98.84 + 98.85 + private static void 98.86 + MultipleOrMatch(OutputAnalyzer analyzer, String[] whatToMatch) { 98.87 + String output = analyzer.getOutput(); 98.88 + 98.89 + for (String expected : whatToMatch) 98.90 + if (output.contains(expected)) 98.91 + return; 98.92 + 98.93 + String err = 98.94 + " stdout: [" + analyzer.getOutput() + "];\n" + 98.95 + " exitValue = " + analyzer.getExitValue() + "\n"; 98.96 + System.err.println(err); 98.97 + 98.98 + StringBuilder msg = new StringBuilder("Output did not contain " + 98.99 + "any of the following expected messages: \n"); 98.100 + for (String expected : whatToMatch) 98.101 + msg.append(expected).append(System.lineSeparator()); 98.102 + throw new RuntimeException(msg.toString()); 98.103 + } 98.104 +} 98.105 +
99.1 Binary file test/runtime/ClassFile/JsrRewritingTestCase.jar has changed
100.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 100.2 +++ b/test/runtime/ClassFile/OomWhileParsingRepeatedJsr.java Tue Sep 24 10:14:02 2013 +0200 100.3 @@ -0,0 +1,74 @@ 100.4 +/* 100.5 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 100.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 100.7 + * 100.8 + * This code is free software; you can redistribute it and/or modify it 100.9 + * under the terms of the GNU General Public License version 2 only, as 100.10 + * published by the Free Software Foundation. 100.11 + * 100.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 100.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 100.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 100.15 + * version 2 for more details (a copy is included in the LICENSE file that 100.16 + * accompanied this code). 100.17 + * 100.18 + * You should have received a copy of the GNU General Public License version 100.19 + * 2 along with this work; if not, write to the Free Software Foundation, 100.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 100.21 + * 100.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 100.23 + * or visit www.oracle.com if you need additional information or have any 100.24 + * questions. 100.25 + */ 100.26 + 100.27 + 100.28 + 100.29 +/* 100.30 + * @test OomWhileParsingRepeatedJsr 100.31 + * @summary Testing class file parser; specifically parsing 100.32 + * a file with repeated JSR (jump local subroutine) 100.33 + * bytecode command. 100.34 + * @bug 6878713 100.35 + * @bug 7030610 100.36 + * @bug 7037122 100.37 + * @bug 7123945 100.38 + * @bug 8016029 100.39 + * @library /testlibrary 100.40 + * @run main OomWhileParsingRepeatedJsr 100.41 + */ 100.42 + 100.43 +import com.oracle.java.testlibrary.*; 100.44 + 100.45 + 100.46 +public class OomWhileParsingRepeatedJsr { 100.47 + 100.48 + public static void main(String[] args) throws Exception { 100.49 + 100.50 + // ======= Configure the test 100.51 + String jarFile = System.getProperty("test.src") + "/testcase.jar"; 100.52 + String className = "OOMCrashClass1960_2"; 100.53 + 100.54 + // limit is 768MB in native words 100.55 + int mallocMaxTestWords = (1024 * 1024 * 768 / 4); 100.56 + if (Platform.is64bit()) 100.57 + mallocMaxTestWords = (mallocMaxTestWords / 2); 100.58 + 100.59 + // ======= extract the test class 100.60 + ProcessBuilder pb = new ProcessBuilder(new String[] { 100.61 + JDKToolFinder.getJDKTool("jar"), 100.62 + "xvf", jarFile } ); 100.63 + OutputAnalyzer output = new OutputAnalyzer(pb.start()); 100.64 + output.shouldHaveExitValue(0); 100.65 + 100.66 + // ======= execute the test 100.67 + pb = ProcessTools.createJavaProcessBuilder( 100.68 + "-cp", ".", 100.69 + "-XX:+UnlockDiagnosticVMOptions", 100.70 + "-XX:MallocMaxTestWords=" + mallocMaxTestWords, 100.71 + className ); 100.72 + 100.73 + output = new OutputAnalyzer(pb.start()); 100.74 + output.shouldContain("Cannot reserve enough memory"); 100.75 + } 100.76 +} 100.77 +
101.1 Binary file test/runtime/ClassFile/testcase.jar has changed
102.1 --- a/test/runtime/InitialThreadOverflow/testme.sh Sat Sep 21 10:09:42 2013 +0200 102.2 +++ b/test/runtime/InitialThreadOverflow/testme.sh Tue Sep 24 10:14:02 2013 +0200 102.3 @@ -43,9 +43,9 @@ 102.4 exit 0 102.5 fi 102.6 102.7 -gcc_cmd=`which gcc` 102.8 -if [ "x$gcc_cmd" == "x" ]; then 102.9 - echo "WARNING: gcc not found. Cannot execute test." 2>&1 102.10 +gcc_cmd=`which g++` 102.11 +if [ "x$gcc_cmd" = "x" ]; then 102.12 + echo "WARNING: g++ not found. Cannot execute test." 2>&1 102.13 exit 0; 102.14 fi 102.15
103.1 --- a/test/testlibrary/com/oracle/java/testlibrary/JDKToolFinder.java Sat Sep 21 10:09:42 2013 +0200 103.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/JDKToolFinder.java Tue Sep 24 10:14:02 2013 +0200 103.3 @@ -23,7 +23,9 @@ 103.4 103.5 package com.oracle.java.testlibrary; 103.6 103.7 -import java.io.File; 103.8 +import java.io.FileNotFoundException; 103.9 +import java.nio.file.Path; 103.10 +import java.nio.file.Paths; 103.11 103.12 public final class JDKToolFinder { 103.13 103.14 @@ -32,38 +34,73 @@ 103.15 103.16 /** 103.17 * Returns the full path to an executable in jdk/bin based on System 103.18 - * property {@code compile.jdk} (set by jtreg test suite) 103.19 + * property {@code test.jdk} or {@code compile.jdk} (both are set by the jtreg test suite) 103.20 * 103.21 * @return Full path to an executable in jdk/bin 103.22 */ 103.23 public static String getJDKTool(String tool) { 103.24 - String binPath = System.getProperty("compile.jdk"); 103.25 - if (binPath == null) { 103.26 - throw new RuntimeException("System property 'compile.jdk' not set. " 103.27 - + "This property is normally set by jtreg. " 103.28 - + "When running test separately, set this property using " 103.29 - + "'-Dcompile.jdk=/path/to/jdk'."); 103.30 + 103.31 + // First try to find the executable in test.jdk 103.32 + try { 103.33 + return getTool(tool, "test.jdk"); 103.34 + } catch (FileNotFoundException e) { 103.35 + 103.36 } 103.37 - binPath += File.separatorChar + "bin" + File.separatorChar + tool; 103.38 103.39 - return binPath; 103.40 + // Now see if it's available in compile.jdk 103.41 + try { 103.42 + return getTool(tool, "compile.jdk"); 103.43 + } catch (FileNotFoundException e) { 103.44 + throw new RuntimeException("Failed to find " + tool + 103.45 + ", looked in test.jdk (" + System.getProperty("test.jdk") + 103.46 + ") and compile.jdk (" + System.getProperty("compile.jdk") + ")"); 103.47 + } 103.48 } 103.49 + 103.50 /** 103.51 - * Returns the full path to an executable in <current jdk>/bin based 103.52 - * on System property {@code test.jdk} (set by jtreg test suite) 103.53 + * Returns the full path to an executable in jdk/bin based on System 103.54 + * property {@code compile.jdk} 103.55 * 103.56 * @return Full path to an executable in jdk/bin 103.57 */ 103.58 - public static String getCurrentJDKTool(String tool) { 103.59 - String binPath = System.getProperty("test.jdk"); 103.60 - if (binPath == null) { 103.61 - throw new RuntimeException("System property 'test.jdk' not set. " 103.62 - + "This property is normally set by jtreg. " 103.63 - + "When running test separately, set this property using " 103.64 - + "'-Dtest.jdk=/path/to/jdk'."); 103.65 + public static String getCompileJDKTool(String tool) { 103.66 + try { 103.67 + return getTool(tool, "compile.jdk"); 103.68 + } catch (FileNotFoundException e) { 103.69 + throw new RuntimeException(e); 103.70 } 103.71 - binPath += File.separatorChar + "bin" + File.separatorChar + tool; 103.72 + } 103.73 103.74 - return binPath; 103.75 + /** 103.76 + * Returns the full path to an executable in jdk/bin based on System 103.77 + * property {@code test.jdk} 103.78 + * 103.79 + * @return Full path to an executable in jdk/bin 103.80 + */ 103.81 + public static String getTestJDKTool(String tool) { 103.82 + try { 103.83 + return getTool(tool, "test.jdk"); 103.84 + } catch (FileNotFoundException e) { 103.85 + throw new RuntimeException(e); 103.86 + } 103.87 + } 103.88 + 103.89 + private static String getTool(String tool, String property) throws FileNotFoundException { 103.90 + String jdkPath = System.getProperty(property); 103.91 + 103.92 + if (jdkPath == null) { 103.93 + throw new RuntimeException( 103.94 + "System property '" + property + "' not set. This property is normally set by jtreg. " 103.95 + + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'."); 103.96 + } 103.97 + 103.98 + Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : "")); 103.99 + 103.100 + Path jdkTool = Paths.get(jdkPath, toolName.toString()); 103.101 + if (!jdkTool.toFile().exists()) { 103.102 + throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath()); 103.103 + } 103.104 + 103.105 + return jdkTool.toAbsolutePath().toString(); 103.106 } 103.107 }