< prev index next >

src/hotspot/share/runtime/threadHeapSampler.cpp

Print this page
rev 52050 : 8211980: Remove ThreadHeapSampler enable/disable/enabled methods
Summary:
Reviewed-by:

*** 31,47 **** // Cheap random number generator uint64_t ThreadHeapSampler::_rnd; // Default is 512kb. int ThreadHeapSampler::_sampling_interval = 512 * 1024; - int ThreadHeapSampler::_enabled; // Statics for the fast log ! static const int FastLogNumBits = 10; ! static const int FastLogMask = (1 << FastLogNumBits) - 1; ! static double log_table[1<<FastLogNumBits]; // Constant ! static bool log_table_initialized; // Returns the next prng value. // pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 // This is the lrand64 generator. static uint64_t next_random(uint64_t rnd) { --- 31,57 ---- // Cheap random number generator uint64_t ThreadHeapSampler::_rnd; // Default is 512kb. int ThreadHeapSampler::_sampling_interval = 512 * 1024; + namespace { // Statics for the fast log ! const int FastLogNumBits = 10; ! const int FastLogMask = (1 << FastLogNumBits) - 1; ! double internal_log_table[1<<FastLogNumBits]; // Constant ! } // anonymous namespace ! ! double *ThreadHeapSampler::_log_table = init_log_table(); ! ! double* ThreadHeapSampler::init_log_table() { ! for (int i = 0; i < (1 << FastLogNumBits); i++) { ! internal_log_table[i] = (log(1.0 + static_cast<double>(i+0.5) / (1 << FastLogNumBits)) ! / log(2.0)); ! } ! return internal_log_table; ! } // Returns the next prng value. // pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 // This is the lrand64 generator. static uint64_t next_random(uint64_t rnd) {
*** 52,72 **** //assert(IS_SAFE_SIZE_MUL(PrngMult, rnd), "Overflow on multiplication."); //assert(IS_SAFE_SIZE_ADD(PrngMult * rnd, PrngAdd), "Overflow on addition."); return (PrngMult * rnd + PrngAdd) & PrngModMask; } ! static double fast_log2(const double & d) { assert(d>0, "bad value passed to assert"); uint64_t x = 0; assert(sizeof(d) == sizeof(x), "double and uint64_t do not have the same size"); x = *reinterpret_cast<const uint64_t*>(&d); const uint32_t x_high = x >> 32; assert(FastLogNumBits <= 20, "FastLogNumBits should be less than 20."); const uint32_t y = x_high >> (20 - FastLogNumBits) & FastLogMask; const int32_t exponent = ((x_high >> 20) & 0x7FF) - 1023; ! return exponent + log_table[y]; } // Generates a geometric variable with the specified mean (512K by default). // This is done by generating a random number between 0 and 1 and applying // the inverse cumulative distribution function for an exponential. --- 62,82 ---- //assert(IS_SAFE_SIZE_MUL(PrngMult, rnd), "Overflow on multiplication."); //assert(IS_SAFE_SIZE_ADD(PrngMult * rnd, PrngAdd), "Overflow on addition."); return (PrngMult * rnd + PrngAdd) & PrngModMask; } ! double ThreadHeapSampler::fast_log2(const double& d) { assert(d>0, "bad value passed to assert"); uint64_t x = 0; assert(sizeof(d) == sizeof(x), "double and uint64_t do not have the same size"); x = *reinterpret_cast<const uint64_t*>(&d); const uint32_t x_high = x >> 32; assert(FastLogNumBits <= 20, "FastLogNumBits should be less than 20."); const uint32_t y = x_high >> (20 - FastLogNumBits) & FastLogMask; const int32_t exponent = ((x_high >> 20) & 0x7FF) - 1023; ! return exponent + internal_log_table[y]; } // Generates a geometric variable with the specified mean (512K by default). // This is done by generating a random number between 0 and 1 and applying // the inverse cumulative distribution function for an exponential.
*** 132,171 **** size_t overflow_bytes = total_allocated_bytes - _bytes_until_sample; pick_next_sample(overflow_bytes); } - void ThreadHeapSampler::init_log_table() { - MutexLockerEx mu(ThreadHeapSampler_lock, Mutex::_no_safepoint_check_flag); - - if (log_table_initialized) { - return; - } - - for (int i = 0; i < (1 << FastLogNumBits); i++) { - log_table[i] = (log(1.0 + static_cast<double>(i+0.5) / (1 << FastLogNumBits)) - / log(2.0)); - } - - log_table_initialized = true; - } - - void ThreadHeapSampler::enable() { - // Done here to be done when things have settled. This adds a mutex lock but - // presumably, users won't be enabling and disabling all the time. - init_log_table(); - OrderAccess::release_store(&_enabled, 1); - } - - int ThreadHeapSampler::enabled() { - return OrderAccess::load_acquire(&_enabled); - } - - void ThreadHeapSampler::disable() { - OrderAccess::release_store(&_enabled, 0); - } - int ThreadHeapSampler::get_sampling_interval() { return OrderAccess::load_acquire(&_sampling_interval); } void ThreadHeapSampler::set_sampling_interval(int sampling_interval) { --- 142,151 ----
< prev index next >