// update_rate() is called from select_task() while holding a compile queue lock. void AdvancedThresholdPolicy::update_rate(jlong t, methodOop m) { if (is_old(m)) { // We don't remove old methods from the queue, // so we can just zero the rate. m->set_rate(0); return; } // We don't update the rate if we've just came out of a safepoint. // delta_s is the time since last safepoint in milliseconds. jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement // How many events were there since the last time? int event_count = m->invocation_count() + m->backedge_count(); int delta_e = event_count - m->prev_event_count(); // We should be running for at least 1ms. if (delta_s >= TieredRateUpdateMinTime) { // And we must've taken the previous point at least 1ms before. if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) { m->set_prev_time(t); m->set_prev_event_count(event_count); m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond } else if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) { // If nothing happened for 25ms, zero the rate. Don't modify prev values. m->set_rate(0); } } }
// Called with the queue locked and with at least one element CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { #if INCLUDE_JVMCI CompileTask *max_non_jvmci_task = NULL; #endif CompileTask *max_task = NULL; Method* max_method = NULL; jlong t = os::javaTimeMillis(); // Iterate through the queue and find a method with a maximum rate. for (CompileTask* task = compile_queue->first(); task != NULL;) { CompileTask* next_task = task->next(); Method* method = task->method(); update_rate(t, method); if (max_task == NULL) { max_task = task; max_method = method; } else { // If a method has been stale for some time, remove it from the queue. if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { if (PrintTieredEvents) { print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level()); } task->log_task_dequeued("stale"); compile_queue->remove_and_mark_stale(task); method->clear_queued_for_compilation(); task = next_task; continue; } // Select a method with a higher rate if (compare_methods(method, max_method)) { max_task = task; max_method = method; } } task = next_task; } #if INCLUDE_JVMCI if (UseJVMCICompiler) { if (max_non_jvmci_task != NULL) { max_task = max_non_jvmci_task; max_method = max_task->method(); } } #endif if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile && is_method_profiled(max_method)) { max_task->set_comp_level(CompLevel_limited_profile); if (PrintTieredEvents) { print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); } } return max_task; }
void print_hours(event prev, event next) { int hour; double len = difftime(next.stamp, prev.stamp) / HOURS; time_t stamp; for (hour = 0; hour < HOURS; hour++) { stamp = prev.stamp + (time_t)(hour * len); if (is_old(stamp)) continue; sleep_until(stamp); puts(MESSAGES[hour + prev.type * HOURS]); fflush(stdout); } }
bool symbolOopDesc::verify() { bool flag = byteArrayOopDesc::verify(); if (flag) { if (!is_old()) { error("symbolOop %#lx isn't tenured", this); flag = false; } symbolOop s = Universe::symbol_table->lookup((char*) bytes(), length()); if (s != this) { error("symbolOop %#lx isn't canonical", this); flag = false; } } return flag; }
unsigned int num_old_gold_waiting(bzz_t *lock) { unsigned int num_old_gold_waiting = 0; list_t *waiting_gold_threads = lock->waiting_gold_threads; list_iterator_start(waiting_gold_threads); // Iterate through waiting gold threads checking for old threads while(list_iterator_hasnext(waiting_gold_threads)) { bzz_thread_t *current = list_iterator_next(waiting_gold_threads); if(is_old(current, lock)) { num_old_gold_waiting++; } } list_iterator_stop(waiting_gold_threads); return num_old_gold_waiting; }
void AccessFlags::print_on(outputStream* st) const { if (is_public ()) st->print("public " ); if (is_private ()) st->print("private " ); if (is_protected ()) st->print("protected " ); if (is_static ()) st->print("static " ); if (is_final ()) st->print("final " ); if (is_synchronized()) st->print("synchronized "); if (is_volatile ()) st->print("volatile " ); if (is_transient ()) st->print("transient " ); if (is_native ()) st->print("native " ); if (is_interface ()) st->print("interface " ); if (is_abstract ()) st->print("abstract " ); if (is_strict ()) st->print("strict " ); if (is_synthetic ()) st->print("synthetic " ); if (is_old ()) st->print("{old} " ); if (is_obsolete ()) st->print("{obsolete} " ); }
// Called with the queue locked and with at least one element CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { CompileTask *max_task = NULL; methodOop max_method; jlong t = os::javaTimeMillis(); // Iterate through the queue and find a method with a maximum rate. for (CompileTask* task = compile_queue->first(); task != NULL;) { CompileTask* next_task = task->next(); methodOop method = (methodOop)JNIHandles::resolve(task->method_handle()); methodDataOop mdo = method->method_data(); update_rate(t, method); if (max_task == NULL) { max_task = task; max_method = method; } else { // If a method has been stale for some time, remove it from the queue. if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { if (PrintTieredEvents) { print_event(KILL, method, method, task->osr_bci(), (CompLevel)task->comp_level()); } CompileTaskWrapper ctw(task); // Frees the task compile_queue->remove(task); method->clear_queued_for_compilation(); task = next_task; continue; } // Select a method with a higher rate if (compare_methods(method, max_method)) { max_task = task; max_method = method; } } task = next_task; } if (max_task->comp_level() == CompLevel_full_profile && is_method_profiled(max_method)) { max_task->set_comp_level(CompLevel_limited_profile); if (PrintTieredEvents) { print_event(UPDATE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); } } return max_task; }
void bzz_lock(bzz_t *lock) { pid_t id = get_thread_id(); pthread_mutex_lock(&lock->mutex); bzz_thread_t *thread = (bzz_thread_t *)get_thread(id, lock); if(full_active_threads(lock)) { // No active slots! Lets wait add_to_waiting_threads(thread, lock); do { pthread_cond_wait(&lock->cond, &lock->mutex); // Woken up, see if we can become active if(!full_active_threads(lock)) { if(is_gold(thread)) { if(is_old(thread, lock)) { add_active(thread, lock); pthread_mutex_unlock(&lock->mutex); return; } else if(num_black_waiting(lock) <= 0) { add_active(thread, lock); pthread_mutex_unlock(&lock->mutex); return; } } else { if(num_old_gold_waiting(lock) <= 0) { add_active(thread, lock); pthread_mutex_unlock(&lock->mutex); return; } } } } while(1); // Loop again due to accidental wake ups } else { // Hey a slot just for us as we were created! add_active(thread, lock); pthread_mutex_unlock(&lock->mutex); return; } }