void AdvancedThresholdPolicy::initialize() { // Turn on ergonomic compiler count selection if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) { FLAG_SET_DEFAULT(CICompilerCountPerCPU, true); } int count = CICompilerCount; if (CICompilerCountPerCPU) { // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n int log_cpu = log2_intptr(os::active_processor_count()); int loglog_cpu = log2_intptr(MAX2(log_cpu, 1)); count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2; } set_c1_count(MAX2(count / 3, 1)); set_c2_count(MAX2(count - count / 3, 1)); // Some inlining tuning #ifdef X86 if (FLAG_IS_DEFAULT(InlineSmallCode)) { FLAG_SET_DEFAULT(InlineSmallCode, 2000); } #endif #ifdef SPARC if (FLAG_IS_DEFAULT(InlineSmallCode)) { FLAG_SET_DEFAULT(InlineSmallCode, 2500); } #endif set_start_time(os::javaTimeMillis()); }
//============================================================================= //------------------------------Ideal------------------------------------------ // Check for power-of-2 multiply, then try the regular MulNode::Ideal Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) { // Swap constant to right jint con; if( in(1)->get_int( &con ) ) { swap_edges(1, 2); // Finish rest of method to use info in 'con' } else if( !in(2)->get_int( &con ) ) return MulNode::Ideal(phase, can_reshape); // Now we have a constant Node on the right and the constant in con if( con == 0 ) return NULL; // By zero is handled by Value call if( con == 1 ) return NULL; // By one is handled by Identity call // Check for negative constant; if so negate the final result bool sign_flip = false; if( con < 0 ) { con = -con; sign_flip = true; } // Get low bit; check for being the only bit Node *res = NULL; int bit1 = con & -con; // Extract low bit if( bit1 == con ) { // Found a power of 2? res = new (3) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ); } else { // Check for constant with 2 bits set int bit2 = con-bit1; bit2 = bit2 & -bit2; // Extract 2nd bit if( bit2 + bit1 == con ) { // Found all bits in con? Node *n1 = phase->transform( new (3) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ) ); Node *n2 = phase->transform( new (3) LShiftINode( in(1), phase->intcon(log2_intptr(bit2)) ) ); res = new (3) AddINode( n2, n1 ); // Sleezy: power-of-2 -1. Next time be generic. } else if( is_power_of_2(con+1) ) { int temp = (int) (con + 1); Node *n1 = phase->transform( new (3) LShiftINode( in(1), phase->intcon(log2_intptr(temp)) ) ); res = new (3) SubINode( n1, in(1) ); } else { return MulNode::Ideal(phase, can_reshape); } } if( sign_flip ) { // Need to negate result? res = phase->transform(res);// Transform, before making the zero con res = new (3) SubINode(phase->intcon(0),res); } return res; // Return final result }
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { assert(left != result, "should be different registers"); if (is_power_of_2(c + 1)) { __ shift_left(left, log2_intptr(c + 1), result); __ sub(result, left, result); return true; } else if (is_power_of_2(c - 1)) { __ shift_left(left, log2_intptr(c - 1), result); __ add(result, left, result); return true; } return false; }
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { if (tmp->is_valid()) { if (is_power_of_2(c + 1)) { __ move(left, tmp); __ shift_left(left, log2_intptr(c + 1), left); __ sub(left, tmp, result); return true; } else if (is_power_of_2(c - 1)) { __ move(left, tmp); __ shift_left(left, log2_intptr(c - 1), left); __ add(left, tmp, result); return true; } } return false; }
static int compiler_count() { return CICompilerCountPerCPU // Example: if CICompilerCountPerCPU is true, then we get // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine. // May help big-app startup time. ? (MAX2(log2_intptr(os::active_processor_count())-1,1)) : CICompilerCount; }
void NonTieredCompPolicy::initialize() { // Setup the compiler thread numbers if (CICompilerCountPerCPU) { // Example: if CICompilerCountPerCPU is true, then we get // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine. // May help big-app startup time. _compiler_count = MAX2(log2_intptr(os::active_processor_count())-1,1); } else { _compiler_count = CICompilerCount; } }
void SimpleThresholdPolicy::initialize() { if (FLAG_IS_DEFAULT(CICompilerCount)) { FLAG_SET_DEFAULT(CICompilerCount, 3); } int count = CICompilerCount; if (CICompilerCountPerCPU) { count = MAX2(log2_intptr(os::active_processor_count()), 1) * 3 / 2; } set_c1_count(MAX2(count / 3, 1)); set_c2_count(MAX2(count - c1_count(), 1)); FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count()); }
// HashtableEntrys are allocated in blocks to reduce the space overhead. template <MEMFLAGS F> BasicHashtableEntry<F>* BasicHashtable<F>::new_entry(unsigned int hashValue) { BasicHashtableEntry<F>* entry = new_entry_free_list(); if (entry == NULL) { if (_first_free_entry + _entry_size >= _end_block) { int block_size = MIN2(512, MAX2((int)_table_size / 2, (int)_number_of_entries)); int len = _entry_size * block_size; len = 1 << log2_intptr(len); // round down to power of 2 assert(len >= _entry_size, ""); _first_free_entry = NEW_C_HEAP_ARRAY2(char, len, F, CURRENT_PC); _end_block = _first_free_entry + len; } entry = (BasicHashtableEntry<F>*)_first_free_entry; _first_free_entry += _entry_size; }
BasicHashtableEntry* BasicHashtable::new_entry(unsigned int hashValue) { BasicHashtableEntry* entry; if (_free_list) { entry = _free_list; _free_list = _free_list->next(); } else { if (_first_free_entry + _entry_size >= _end_block) { int block_size = MIN2(512, MAX2((int)_table_size / 2, (int)_number_of_entries)); int len = _entry_size * block_size; len = 1 << log2_intptr(len); // round down to power of 2 assert(len >= _entry_size, ""); _first_free_entry = NEW_C_HEAP_ARRAY(char, len); _end_block = _first_free_entry + len; } entry = (BasicHashtableEntry*)_first_free_entry; _first_free_entry += _entry_size; }
void SimpleThresholdPolicy::initialize() { if (FLAG_IS_DEFAULT(CICompilerCount)) { FLAG_SET_DEFAULT(CICompilerCount, 3); } int count = CICompilerCount; #ifdef _LP64 // On 64-bit systems, scale the number of compiler threads with // the number of cores available on the system. Scaling is not // performed on 32-bit systems because it can lead to exhaustion // of the virtual memory address space available to the JVM. if (CICompilerCountPerCPU) { count = MAX2(log2_intptr(os::active_processor_count()) * 3 / 2, 2); FLAG_SET_ERGO(intx, CICompilerCount, count); } #endif if (TieredStopAtLevel < CompLevel_full_optimization) { // No C2 compiler thread required set_c1_count(count); } else { set_c1_count(MAX2(count / 3, 1)); set_c2_count(MAX2(count - c1_count(), 1)); } assert(count == c1_count() + c2_count(), "inconsistent compiler thread count"); }
//* the argument must be exactly a power of 2 inline int exact_log2(intptr_t x) { #ifdef ASSERT if (!is_power_of_2(x)) basic_fatal("x must be a power of 2"); #endif return log2_intptr(x); }