void site_update_stats(SiteIndex index, jint size, jint hits) { SiteInfo *info; table_lock_enter(gdata->site_table); { info = get_info(index); info->n_live_instances += hits; info->n_live_bytes += size; info->changed = 1; gdata->total_live_bytes += size; gdata->total_live_instances += hits; if ( size > 0 ) { info->n_alloced_instances += hits; info->n_alloced_bytes += size; gdata->total_alloced_bytes = jlong_add(gdata->total_alloced_bytes, jint_to_jlong(size)); gdata->total_alloced_instances = jlong_add(gdata->total_alloced_instances, jint_to_jlong(hits)); } } table_lock_exit(gdata->site_table); }
static void hprof_bill_frames_cost(hprof_frames_cost_t *fc, JNIEnv *env_id, jmethodID *frames) { jlong self_time = jlong_div(fc->self_time, jint_to_jlong(1000000));/* convert to ms */ jlong cost = jlong_zero; int num_hits = fc->num_hits; int bill_it = 0; if ((timing_format == OLD_PROF_OUTPUT_FORMAT) && (num_hits > 0)) { env_id = NULL; /* no thread info for old prof */ cost = jlong_div(fc->total_time, jint_to_jlong(1000000)); /* convert to ms */ bill_it = 1; } else if ((timing_format == NEW_PROF_OUTPUT_FORMAT) && CVMlongGt(self_time, jlong_zero)) { cost = self_time; bill_it = 1; } /* if we are billing */ if (bill_it) { int i; int n_frames = fc->num_frames; hprof_trace_t *trace_tmp = hprof_alloc_tmp_trace(n_frames, env_id); hprof_trace_t *result; for (i = 0; i < n_frames; i++) { hprof_frame_t *frame = hprof_intern_jvmpi_frame(frames[i],-1); if (frame == NULL) { fprintf(stderr, "HPROF ERROR: got a NULL frame in bill_frames_cost\n"); hprof_free(trace_tmp); return; } trace_tmp->frames[i] = frame; } result = hprof_intern_tmp_trace(trace_tmp); /* bill the cost and num_hits and zero out the values in frames_cost * to prevent them from getting billed more than once */ result->cost = jlong_add(result->cost, cost); result->num_hits += num_hits; fc->self_time = jlong_zero; fc->total_time = jlong_zero; fc->num_hits = 0; } }