Fri, 16 May 2014 03:25:23 -0700
Merge
1.1 --- a/make/hotspot_version Tue May 13 23:17:52 2014 -0700 1.2 +++ b/make/hotspot_version Fri May 16 03:25:23 2014 -0700 1.3 @@ -35,7 +35,7 @@ 1.4 1.5 HS_MAJOR_VER=25 1.6 HS_MINOR_VER=20 1.7 -HS_BUILD_NUMBER=14 1.8 +HS_BUILD_NUMBER=15 1.9 1.10 JDK_MAJOR_VER=1 1.11 JDK_MINOR_VER=8
2.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp Tue May 13 23:17:52 2014 -0700 2.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp Fri May 16 03:25:23 2014 -0700 2.3 @@ -3152,10 +3152,12 @@ 2.4 // if fast computation is not possible, result is NaN. Requires 2.5 // fallback from user of this macro. 2.6 // increase precision for intermediate steps of the computation 2.7 + BLOCK_COMMENT("fast_pow {"); 2.8 increase_precision(); 2.9 fyl2x(); // Stack: (Y*log2(X)) ... 2.10 pow_exp_core_encoding(); // Stack: exp(X) ... 2.11 restore_precision(); 2.12 + BLOCK_COMMENT("} fast_pow"); 2.13 } 2.14 2.15 void MacroAssembler::fast_exp() {
3.1 --- a/src/os/bsd/vm/os_bsd.cpp Tue May 13 23:17:52 2014 -0700 3.2 +++ b/src/os/bsd/vm/os_bsd.cpp Fri May 16 03:25:23 2014 -0700 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 Tue May 13 23:17:52 2014 -0700 4.2 +++ b/src/os/bsd/vm/os_bsd.hpp Fri May 16 03:25:23 2014 -0700 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 Tue May 13 23:17:52 2014 -0700 5.2 +++ b/src/os/solaris/vm/os_solaris.cpp Fri May 16 03:25:23 2014 -0700 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 Tue May 13 23:17:52 2014 -0700 6.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Fri May 16 03:25:23 2014 -0700 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 Tue May 13 23:17:52 2014 -0700 7.2 +++ b/src/share/vm/c1/c1_GraphBuilder.hpp Fri May 16 03:25:23 2014 -0700 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 Tue May 13 23:17:52 2014 -0700 8.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Fri May 16 03:25:23 2014 -0700 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/opto/library_call.cpp Tue May 13 23:17:52 2014 -0700 9.2 +++ b/src/share/vm/opto/library_call.cpp Fri May 16 03:25:23 2014 -0700 9.3 @@ -216,7 +216,7 @@ 9.4 bool inline_math_subtractExactL(bool is_decrement); 9.5 bool inline_exp(); 9.6 bool inline_pow(); 9.7 - void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); 9.8 + Node* finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); 9.9 bool inline_min_max(vmIntrinsics::ID id); 9.10 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); 9.11 // This returns Type::AnyPtr, RawPtr, or OopPtr. 9.12 @@ -1678,7 +1678,7 @@ 9.13 return true; 9.14 } 9.15 9.16 -void LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { 9.17 +Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { 9.18 //------------------- 9.19 //result=(result.isNaN())? funcAddr():result; 9.20 // Check: If isNaN() by checking result!=result? then either trap 9.21 @@ -1694,7 +1694,7 @@ 9.22 uncommon_trap(Deoptimization::Reason_intrinsic, 9.23 Deoptimization::Action_make_not_entrant); 9.24 } 9.25 - set_result(result); 9.26 + return result; 9.27 } else { 9.28 // If this inlining ever returned NaN in the past, we compile a call 9.29 // to the runtime to properly handle corner cases 9.30 @@ -1724,9 +1724,10 @@ 9.31 9.32 result_region->init_req(2, control()); 9.33 result_val->init_req(2, value); 9.34 - set_result(result_region, result_val); 9.35 + set_control(_gvn.transform(result_region)); 9.36 + return _gvn.transform(result_val); 9.37 } else { 9.38 - set_result(result); 9.39 + return result; 9.40 } 9.41 } 9.42 } 9.43 @@ -1738,7 +1739,8 @@ 9.44 Node* arg = round_double_node(argument(0)); 9.45 Node* n = _gvn.transform(new (C) ExpDNode(C, control(), arg)); 9.46 9.47 - finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); 9.48 + n = finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); 9.49 + set_result(n); 9.50 9.51 C->set_has_split_ifs(true); // Has chance for split-if optimization 9.52 return true; 9.53 @@ -1748,27 +1750,48 @@ 9.54 // Inline power instructions, if possible. 9.55 bool LibraryCallKit::inline_pow() { 9.56 // Pseudocode for pow 9.57 - // if (x <= 0.0) { 9.58 - // long longy = (long)y; 9.59 - // if ((double)longy == y) { // if y is long 9.60 - // if (y + 1 == y) longy = 0; // huge number: even 9.61 - // result = ((1&longy) == 0)?-DPow(abs(x), y):DPow(abs(x), y); 9.62 + // if (y == 2) { 9.63 + // return x * x; 9.64 + // } else { 9.65 + // if (x <= 0.0) { 9.66 + // long longy = (long)y; 9.67 + // if ((double)longy == y) { // if y is long 9.68 + // if (y + 1 == y) longy = 0; // huge number: even 9.69 + // result = ((1&longy) == 0)?-DPow(abs(x), y):DPow(abs(x), y); 9.70 + // } else { 9.71 + // result = NaN; 9.72 + // } 9.73 // } else { 9.74 - // result = NaN; 9.75 + // result = DPow(x,y); 9.76 // } 9.77 - // } else { 9.78 - // result = DPow(x,y); 9.79 + // if (result != result)? { 9.80 + // result = uncommon_trap() or runtime_call(); 9.81 + // } 9.82 + // return result; 9.83 // } 9.84 - // if (result != result)? { 9.85 - // result = uncommon_trap() or runtime_call(); 9.86 - // } 9.87 - // return result; 9.88 9.89 Node* x = round_double_node(argument(0)); 9.90 Node* y = round_double_node(argument(2)); 9.91 9.92 Node* result = NULL; 9.93 9.94 + Node* const_two_node = makecon(TypeD::make(2.0)); 9.95 + Node* cmp_node = _gvn.transform(new (C) CmpDNode(y, const_two_node)); 9.96 + Node* bool_node = _gvn.transform(new (C) BoolNode(cmp_node, BoolTest::eq)); 9.97 + IfNode* if_node = create_and_xform_if(control(), bool_node, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); 9.98 + Node* if_true = _gvn.transform(new (C) IfTrueNode(if_node)); 9.99 + Node* if_false = _gvn.transform(new (C) IfFalseNode(if_node)); 9.100 + 9.101 + RegionNode* region_node = new (C) RegionNode(3); 9.102 + region_node->init_req(1, if_true); 9.103 + 9.104 + Node* phi_node = new (C) PhiNode(region_node, Type::DOUBLE); 9.105 + // special case for x^y where y == 2, we can convert it to x * x 9.106 + phi_node->init_req(1, _gvn.transform(new (C) MulDNode(x, x))); 9.107 + 9.108 + // set control to if_false since we will now process the false branch 9.109 + set_control(if_false); 9.110 + 9.111 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { 9.112 // Short form: skip the fancy tests and just check for NaN result. 9.113 result = _gvn.transform(new (C) PowDNode(C, control(), x, y)); 9.114 @@ -1892,7 +1915,15 @@ 9.115 result = _gvn.transform(phi); 9.116 } 9.117 9.118 - finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); 9.119 + result = finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); 9.120 + 9.121 + // control from finish_pow_exp is now input to the region node 9.122 + region_node->set_req(2, control()); 9.123 + // the result from finish_pow_exp is now input to the phi node 9.124 + phi_node->init_req(2, result); 9.125 + set_control(_gvn.transform(region_node)); 9.126 + record_for_igvn(region_node); 9.127 + set_result(_gvn.transform(phi_node)); 9.128 9.129 C->set_has_split_ifs(true); // Has chance for split-if optimization 9.130 return true;
10.1 --- a/src/share/vm/runtime/os.hpp Tue May 13 23:17:52 2014 -0700 10.2 +++ b/src/share/vm/runtime/os.hpp Fri May 16 03:25:23 2014 -0700 10.3 @@ -48,6 +48,9 @@ 10.4 #ifdef TARGET_OS_FAMILY_bsd 10.5 # include "jvm_bsd.h" 10.6 # include <setjmp.h> 10.7 +# ifdef __APPLE__ 10.8 +# include <mach/mach_time.h> 10.9 +# endif 10.10 #endif 10.11 10.12 class AgentLibrary;
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/compiler/profiling/TestMethodHandleInvokesIntrinsic.java Fri May 16 03:25:23 2014 -0700 11.3 @@ -0,0 +1,92 @@ 11.4 +/* 11.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/* 11.28 + * @test 11.29 + * @bug 8041458 11.30 + * @summary profiling of arguments in C1 at MethodHandle invoke of intrinsic tries to profile popped argument. 11.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TieredStopAtLevel=3 TestMethodHandleInvokesIntrinsic 11.32 + * 11.33 + */ 11.34 + 11.35 +import java.lang.invoke.*; 11.36 + 11.37 +public class TestMethodHandleInvokesIntrinsic { 11.38 + 11.39 + static final MethodHandle mh_nanoTime; 11.40 + static final MethodHandle mh_getClass; 11.41 + static { 11.42 + MethodHandles.Lookup lookup = MethodHandles.lookup(); 11.43 + MethodType mt = MethodType.methodType(long.class); 11.44 + MethodHandle MH = null; 11.45 + try { 11.46 + MH = lookup.findStatic(System.class, "nanoTime", mt); 11.47 + } catch(NoSuchMethodException nsme) { 11.48 + nsme.printStackTrace(); 11.49 + throw new RuntimeException("TEST FAILED", nsme); 11.50 + } catch(IllegalAccessException iae) { 11.51 + iae.printStackTrace(); 11.52 + throw new RuntimeException("TEST FAILED", iae); 11.53 + } 11.54 + mh_nanoTime = MH; 11.55 + 11.56 + mt = MethodType.methodType(Class.class); 11.57 + MH = null; 11.58 + try { 11.59 + MH = lookup.findVirtual(Object.class, "getClass", mt); 11.60 + } catch(NoSuchMethodException nsme) { 11.61 + nsme.printStackTrace(); 11.62 + throw new RuntimeException("TEST FAILED", nsme); 11.63 + } catch(IllegalAccessException iae) { 11.64 + iae.printStackTrace(); 11.65 + throw new RuntimeException("TEST FAILED", iae); 11.66 + } 11.67 + mh_getClass = MH; 11.68 + } 11.69 + 11.70 + static long m1() throws Throwable { 11.71 + return (long)mh_nanoTime.invokeExact(); 11.72 + } 11.73 + 11.74 + static Class m2(Object o) throws Throwable { 11.75 + return (Class)mh_getClass.invokeExact(o); 11.76 + } 11.77 + 11.78 + static public void main(String[] args) { 11.79 + try { 11.80 + for (int i = 0; i < 20000; i++) { 11.81 + m1(); 11.82 + } 11.83 + TestMethodHandleInvokesIntrinsic o = new TestMethodHandleInvokesIntrinsic(); 11.84 + for (int i = 0; i < 20000; i++) { 11.85 + m2(o); 11.86 + } 11.87 + } catch(Throwable t) { 11.88 + System.out.println("Unexpected exception"); 11.89 + t.printStackTrace(); 11.90 + throw new RuntimeException("TEST FAILED", t); 11.91 + } 11.92 + 11.93 + System.out.println("TEST PASSED"); 11.94 + } 11.95 +}