Fri, 16 May 2014 19:13:42 -0400
Merge
1.1 --- a/.hgtags Mon May 12 20:20:19 2014 -0400 1.2 +++ b/.hgtags Fri May 16 19:13:42 2014 -0400 1.3 @@ -464,3 +464,5 @@ 1.4 47951595af60460a479b8574622375bfbf5c8ed2 jdk8u20-b13 1.5 798f5b02be897151fdad44d695446088b1cca6b1 hs25.20-b13 1.6 28bbbecff5f08c1e343fc0c40923c05d86b7cf82 hs25.20-b14 1.7 +c20d8a452574c85c8fc1f7f2d4e788cd6b156bc9 jdk8u20-b14 1.8 +87bdb86f0aedbd9b9ef8e9999b273114c8be4748 hs25.20-b15
2.1 --- a/make/hotspot_version Mon May 12 20:20:19 2014 -0400 2.2 +++ b/make/hotspot_version Fri May 16 19:13:42 2014 -0400 2.3 @@ -35,7 +35,7 @@ 2.4 2.5 HS_MAJOR_VER=25 2.6 HS_MINOR_VER=20 2.7 -HS_BUILD_NUMBER=15 2.8 +HS_BUILD_NUMBER=16 2.9 2.10 JDK_MAJOR_VER=1 2.11 JDK_MINOR_VER=8
3.1 --- a/src/os/bsd/vm/os_bsd.cpp Mon May 12 20:20:19 2014 -0400 3.2 +++ b/src/os/bsd/vm/os_bsd.cpp Fri May 16 19:13:42 2014 -0400 3.3 @@ -127,8 +127,12 @@ 3.4 // global variables 3.5 julong os::Bsd::_physical_memory = 0; 3.6 3.7 - 3.8 +#ifdef __APPLE__ 3.9 +mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0}; 3.10 +volatile uint64_t os::Bsd::_max_abstime = 0; 3.11 +#else 3.12 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL; 3.13 +#endif 3.14 pthread_t os::Bsd::_main_thread; 3.15 int os::Bsd::_page_size = -1; 3.16 3.17 @@ -986,13 +990,15 @@ 3.18 return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000); 3.19 } 3.20 3.21 +#ifndef __APPLE__ 3.22 #ifndef CLOCK_MONOTONIC 3.23 #define CLOCK_MONOTONIC (1) 3.24 #endif 3.25 +#endif 3.26 3.27 #ifdef __APPLE__ 3.28 void os::Bsd::clock_init() { 3.29 - // XXXDARWIN: Investigate replacement monotonic clock 3.30 + mach_timebase_info(&_timebase_info); 3.31 } 3.32 #else 3.33 void os::Bsd::clock_init() { 3.34 @@ -1007,10 +1013,38 @@ 3.35 #endif 3.36 3.37 3.38 +#ifdef __APPLE__ 3.39 + 3.40 +jlong os::javaTimeNanos() { 3.41 + const uint64_t tm = mach_absolute_time(); 3.42 + const uint64_t now = (tm * Bsd::_timebase_info.numer) / Bsd::_timebase_info.denom; 3.43 + const uint64_t prev = Bsd::_max_abstime; 3.44 + if (now <= prev) { 3.45 + return prev; // same or retrograde time; 3.46 + } 3.47 + const uint64_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&Bsd::_max_abstime, prev); 3.48 + assert(obsv >= prev, "invariant"); // Monotonicity 3.49 + // If the CAS succeeded then we're done and return "now". 3.50 + // If the CAS failed and the observed value "obsv" is >= now then 3.51 + // we should return "obsv". If the CAS failed and now > obsv > prv then 3.52 + // some other thread raced this thread and installed a new value, in which case 3.53 + // we could either (a) retry the entire operation, (b) retry trying to install now 3.54 + // or (c) just return obsv. We use (c). No loop is required although in some cases 3.55 + // we might discard a higher "now" value in deference to a slightly lower but freshly 3.56 + // installed obsv value. That's entirely benign -- it admits no new orderings compared 3.57 + // to (a) or (b) -- and greatly reduces coherence traffic. 3.58 + // We might also condition (c) on the magnitude of the delta between obsv and now. 3.59 + // Avoiding excessive CAS operations to hot RW locations is critical. 3.60 + // See https://blogs.oracle.com/dave/entry/cas_and_cache_trivia_invalidate 3.61 + return (prev == obsv) ? now : obsv; 3.62 +} 3.63 + 3.64 +#else // __APPLE__ 3.65 + 3.66 jlong os::javaTimeNanos() { 3.67 if (Bsd::supports_monotonic_clock()) { 3.68 struct timespec tp; 3.69 - int status = Bsd::clock_gettime(CLOCK_MONOTONIC, &tp); 3.70 + int status = Bsd::_clock_gettime(CLOCK_MONOTONIC, &tp); 3.71 assert(status == 0, "gettime error"); 3.72 jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec); 3.73 return result; 3.74 @@ -1023,6 +1057,8 @@ 3.75 } 3.76 } 3.77 3.78 +#endif // __APPLE__ 3.79 + 3.80 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { 3.81 if (Bsd::supports_monotonic_clock()) { 3.82 info_ptr->max_value = ALL_64_BITS;
4.1 --- a/src/os/bsd/vm/os_bsd.hpp Mon May 12 20:20:19 2014 -0400 4.2 +++ b/src/os/bsd/vm/os_bsd.hpp Fri May 16 19:13:42 2014 -0400 4.3 @@ -58,7 +58,13 @@ 4.4 // For signal flags diagnostics 4.5 static int sigflags[MAXSIGNUM]; 4.6 4.7 +#ifdef __APPLE__ 4.8 + // mach_absolute_time 4.9 + static mach_timebase_info_data_t _timebase_info; 4.10 + static volatile uint64_t _max_abstime; 4.11 +#else 4.12 static int (*_clock_gettime)(clockid_t, struct timespec *); 4.13 +#endif 4.14 4.15 static GrowableArray<int>* _cpu_to_node; 4.16 4.17 @@ -135,11 +141,11 @@ 4.18 static void clock_init(void); 4.19 4.20 static inline bool supports_monotonic_clock() { 4.21 +#ifdef __APPLE__ 4.22 + return true; 4.23 +#else 4.24 return _clock_gettime != NULL; 4.25 - } 4.26 - 4.27 - static int clock_gettime(clockid_t clock_id, struct timespec *tp) { 4.28 - return _clock_gettime ? _clock_gettime(clock_id, tp) : -1; 4.29 +#endif 4.30 } 4.31 4.32 // Stack repair handling
5.1 --- a/src/os/solaris/vm/os_solaris.cpp Mon May 12 20:20:19 2014 -0400 5.2 +++ b/src/os/solaris/vm/os_solaris.cpp Fri May 16 19:13:42 2014 -0400 5.3 @@ -415,11 +415,7 @@ 5.4 5.5 static hrtime_t first_hrtime = 0; 5.6 static const hrtime_t hrtime_hz = 1000*1000*1000; 5.7 -const int LOCK_BUSY = 1; 5.8 -const int LOCK_FREE = 0; 5.9 -const int LOCK_INVALID = -1; 5.10 static volatile hrtime_t max_hrtime = 0; 5.11 -static volatile int max_hrtime_lock = LOCK_FREE; // Update counter with LSB as lock-in-progress 5.12 5.13 5.14 void os::Solaris::initialize_system_info() { 5.15 @@ -1534,58 +1530,31 @@ 5.16 } 5.17 5.18 5.19 -// gethrtime can move backwards if read from one cpu and then a different cpu 5.20 -// getTimeNanos is guaranteed to not move backward on Solaris 5.21 -// local spinloop created as faster for a CAS on an int than 5.22 -// a CAS on a 64bit jlong. Also Atomic::cmpxchg for jlong is not 5.23 -// supported on sparc v8 or pre supports_cx8 intel boxes. 5.24 -// oldgetTimeNanos for systems which do not support CAS on 64bit jlong 5.25 -// i.e. sparc v8 and pre supports_cx8 (i486) intel boxes 5.26 -inline hrtime_t oldgetTimeNanos() { 5.27 - int gotlock = LOCK_INVALID; 5.28 - hrtime_t newtime = gethrtime(); 5.29 - 5.30 - for (;;) { 5.31 -// grab lock for max_hrtime 5.32 - int curlock = max_hrtime_lock; 5.33 - if (curlock & LOCK_BUSY) continue; 5.34 - if (gotlock = Atomic::cmpxchg(LOCK_BUSY, &max_hrtime_lock, LOCK_FREE) != LOCK_FREE) continue; 5.35 - if (newtime > max_hrtime) { 5.36 - max_hrtime = newtime; 5.37 - } else { 5.38 - newtime = max_hrtime; 5.39 - } 5.40 - // release lock 5.41 - max_hrtime_lock = LOCK_FREE; 5.42 - return newtime; 5.43 - } 5.44 -} 5.45 -// gethrtime can move backwards if read from one cpu and then a different cpu 5.46 -// getTimeNanos is guaranteed to not move backward on Solaris 5.47 +// gethrtime() should be monotonic according to the documentation, 5.48 +// but some virtualized platforms are known to break this guarantee. 5.49 +// getTimeNanos() must be guaranteed not to move backwards, so we 5.50 +// are forced to add a check here. 5.51 inline hrtime_t getTimeNanos() { 5.52 - if (VM_Version::supports_cx8()) { 5.53 - const hrtime_t now = gethrtime(); 5.54 - // Use atomic long load since 32-bit x86 uses 2 registers to keep long. 5.55 - const hrtime_t prev = Atomic::load((volatile jlong*)&max_hrtime); 5.56 - if (now <= prev) return prev; // same or retrograde time; 5.57 - const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev); 5.58 - assert(obsv >= prev, "invariant"); // Monotonicity 5.59 - // If the CAS succeeded then we're done and return "now". 5.60 - // If the CAS failed and the observed value "obs" is >= now then 5.61 - // we should return "obs". If the CAS failed and now > obs > prv then 5.62 - // some other thread raced this thread and installed a new value, in which case 5.63 - // we could either (a) retry the entire operation, (b) retry trying to install now 5.64 - // or (c) just return obs. We use (c). No loop is required although in some cases 5.65 - // we might discard a higher "now" value in deference to a slightly lower but freshly 5.66 - // installed obs value. That's entirely benign -- it admits no new orderings compared 5.67 - // to (a) or (b) -- and greatly reduces coherence traffic. 5.68 - // We might also condition (c) on the magnitude of the delta between obs and now. 5.69 - // Avoiding excessive CAS operations to hot RW locations is critical. 5.70 - // See http://blogs.sun.com/dave/entry/cas_and_cache_trivia_invalidate 5.71 - return (prev == obsv) ? now : obsv ; 5.72 - } else { 5.73 - return oldgetTimeNanos(); 5.74 - } 5.75 + const hrtime_t now = gethrtime(); 5.76 + const hrtime_t prev = max_hrtime; 5.77 + if (now <= prev) { 5.78 + return prev; // same or retrograde time; 5.79 + } 5.80 + const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev); 5.81 + assert(obsv >= prev, "invariant"); // Monotonicity 5.82 + // If the CAS succeeded then we're done and return "now". 5.83 + // If the CAS failed and the observed value "obsv" is >= now then 5.84 + // we should return "obsv". If the CAS failed and now > obsv > prv then 5.85 + // some other thread raced this thread and installed a new value, in which case 5.86 + // we could either (a) retry the entire operation, (b) retry trying to install now 5.87 + // or (c) just return obsv. We use (c). No loop is required although in some cases 5.88 + // we might discard a higher "now" value in deference to a slightly lower but freshly 5.89 + // installed obsv value. That's entirely benign -- it admits no new orderings compared 5.90 + // to (a) or (b) -- and greatly reduces coherence traffic. 5.91 + // We might also condition (c) on the magnitude of the delta between obsv and now. 5.92 + // Avoiding excessive CAS operations to hot RW locations is critical. 5.93 + // See https://blogs.oracle.com/dave/entry/cas_and_cache_trivia_invalidate 5.94 + return (prev == obsv) ? now : obsv; 5.95 } 5.96 5.97 // Time since start-up in seconds to a fine granularity.
6.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Mon May 12 20:20:19 2014 -0400 6.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Fri May 16 19:13:42 2014 -0400 6.3 @@ -1697,6 +1697,15 @@ 6.4 return NULL; 6.5 } 6.6 6.7 +void GraphBuilder::check_args_for_profiling(Values* obj_args, int expected) { 6.8 +#ifdef ASSERT 6.9 + bool ignored_will_link; 6.10 + ciSignature* declared_signature = NULL; 6.11 + ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); 6.12 + assert(expected == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); 6.13 +#endif 6.14 +} 6.15 + 6.16 // Collect arguments that we want to profile in a list 6.17 Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver) { 6.18 int start = 0; 6.19 @@ -1705,13 +1714,14 @@ 6.20 return NULL; 6.21 } 6.22 int s = obj_args->size(); 6.23 - for (int i = start, j = 0; j < s; i++) { 6.24 + // if called through method handle invoke, some arguments may have been popped 6.25 + for (int i = start, j = 0; j < s && i < args->length(); i++) { 6.26 if (args->at(i)->type()->is_object_kind()) { 6.27 obj_args->push(args->at(i)); 6.28 j++; 6.29 } 6.30 } 6.31 - assert(s == obj_args->length(), "missed on arg?"); 6.32 + check_args_for_profiling(obj_args, s); 6.33 return obj_args; 6.34 } 6.35 6.36 @@ -3843,14 +3853,7 @@ 6.37 j++; 6.38 } 6.39 } 6.40 -#ifdef ASSERT 6.41 - { 6.42 - bool ignored_will_link; 6.43 - ciSignature* declared_signature = NULL; 6.44 - ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); 6.45 - assert(s == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); 6.46 - } 6.47 -#endif 6.48 + check_args_for_profiling(obj_args, s); 6.49 } 6.50 profile_call(callee, recv, holder_known ? callee->holder() : NULL, obj_args, true); 6.51 }
7.1 --- a/src/share/vm/c1/c1_GraphBuilder.hpp Mon May 12 20:20:19 2014 -0400 7.2 +++ b/src/share/vm/c1/c1_GraphBuilder.hpp Fri May 16 19:13:42 2014 -0400 7.3 @@ -392,6 +392,7 @@ 7.4 7.5 Values* args_list_for_profiling(ciMethod* target, int& start, bool may_have_receiver); 7.6 Values* collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver); 7.7 + void check_args_for_profiling(Values* obj_args, int expected); 7.8 7.9 public: 7.10 NOT_PRODUCT(void print_stats();)
8.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp Mon May 12 20:20:19 2014 -0400 8.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Fri May 16 19:13:42 2014 -0400 8.3 @@ -2634,8 +2634,10 @@ 8.4 // LIR_Assembler::emit_profile_type() from emitting useless code 8.5 profiled_k = ciTypeEntries::with_status(result, profiled_k); 8.6 } 8.7 - if (exact_signature_k != NULL && exact_klass != exact_signature_k) { 8.8 - assert(exact_klass == NULL, "obj and signature disagree?"); 8.9 + // exact_klass and exact_signature_k can be both non NULL but 8.10 + // different if exact_klass is loaded after the ciObject for 8.11 + // exact_signature_k is created. 8.12 + if (exact_klass == NULL && exact_signature_k != NULL && exact_klass != exact_signature_k) { 8.13 // sometimes the type of the signature is better than the best type 8.14 // the compiler has 8.15 exact_klass = exact_signature_k; 8.16 @@ -2646,8 +2648,7 @@ 8.17 if (improved_klass == NULL) { 8.18 improved_klass = comp->cha_exact_type(callee_signature_k); 8.19 } 8.20 - if (improved_klass != NULL && exact_klass != improved_klass) { 8.21 - assert(exact_klass == NULL, "obj and signature disagree?"); 8.22 + if (exact_klass == NULL && improved_klass != NULL && exact_klass != improved_klass) { 8.23 exact_klass = exact_signature_k; 8.24 } 8.25 }
9.1 --- a/src/share/vm/runtime/os.hpp Mon May 12 20:20:19 2014 -0400 9.2 +++ b/src/share/vm/runtime/os.hpp Fri May 16 19:13:42 2014 -0400 9.3 @@ -48,6 +48,9 @@ 9.4 #ifdef TARGET_OS_FAMILY_bsd 9.5 # include "jvm_bsd.h" 9.6 # include <setjmp.h> 9.7 +# ifdef __APPLE__ 9.8 +# include <mach/mach_time.h> 9.9 +# endif 9.10 #endif 9.11 9.12 class AgentLibrary;
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/compiler/profiling/TestMethodHandleInvokesIntrinsic.java Fri May 16 19:13:42 2014 -0400 10.3 @@ -0,0 +1,92 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 8041458 10.30 + * @summary profiling of arguments in C1 at MethodHandle invoke of intrinsic tries to profile popped argument. 10.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TieredStopAtLevel=3 TestMethodHandleInvokesIntrinsic 10.32 + * 10.33 + */ 10.34 + 10.35 +import java.lang.invoke.*; 10.36 + 10.37 +public class TestMethodHandleInvokesIntrinsic { 10.38 + 10.39 + static final MethodHandle mh_nanoTime; 10.40 + static final MethodHandle mh_getClass; 10.41 + static { 10.42 + MethodHandles.Lookup lookup = MethodHandles.lookup(); 10.43 + MethodType mt = MethodType.methodType(long.class); 10.44 + MethodHandle MH = null; 10.45 + try { 10.46 + MH = lookup.findStatic(System.class, "nanoTime", mt); 10.47 + } catch(NoSuchMethodException nsme) { 10.48 + nsme.printStackTrace(); 10.49 + throw new RuntimeException("TEST FAILED", nsme); 10.50 + } catch(IllegalAccessException iae) { 10.51 + iae.printStackTrace(); 10.52 + throw new RuntimeException("TEST FAILED", iae); 10.53 + } 10.54 + mh_nanoTime = MH; 10.55 + 10.56 + mt = MethodType.methodType(Class.class); 10.57 + MH = null; 10.58 + try { 10.59 + MH = lookup.findVirtual(Object.class, "getClass", mt); 10.60 + } catch(NoSuchMethodException nsme) { 10.61 + nsme.printStackTrace(); 10.62 + throw new RuntimeException("TEST FAILED", nsme); 10.63 + } catch(IllegalAccessException iae) { 10.64 + iae.printStackTrace(); 10.65 + throw new RuntimeException("TEST FAILED", iae); 10.66 + } 10.67 + mh_getClass = MH; 10.68 + } 10.69 + 10.70 + static long m1() throws Throwable { 10.71 + return (long)mh_nanoTime.invokeExact(); 10.72 + } 10.73 + 10.74 + static Class m2(Object o) throws Throwable { 10.75 + return (Class)mh_getClass.invokeExact(o); 10.76 + } 10.77 + 10.78 + static public void main(String[] args) { 10.79 + try { 10.80 + for (int i = 0; i < 20000; i++) { 10.81 + m1(); 10.82 + } 10.83 + TestMethodHandleInvokesIntrinsic o = new TestMethodHandleInvokesIntrinsic(); 10.84 + for (int i = 0; i < 20000; i++) { 10.85 + m2(o); 10.86 + } 10.87 + } catch(Throwable t) { 10.88 + System.out.println("Unexpected exception"); 10.89 + t.printStackTrace(); 10.90 + throw new RuntimeException("TEST FAILED", t); 10.91 + } 10.92 + 10.93 + System.out.println("TEST PASSED"); 10.94 + } 10.95 +}