Exemplo n.º 1
0
/* Setup tag on root object */
static void
setup_tag_on_root(jlong *tag_ptr, jlong class_tag, jlong size,
		  SerialNumber thread_serial_num,
                  ObjectIndex *pindex, SiteIndex *psite)
{
    ObjectIndex object_index;
    SiteIndex   object_site_index;
    
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index      = tag_extract(*tag_ptr);
	if ( psite != NULL ) {
	    object_site_index = object_get_site(object_index);
	}
    } else {
	object_site_index = site_find_or_create(
				 find_cnum(class_tag), 
				 gdata->system_trace_index);
	object_index      = object_new(object_site_index, 
				 (jint)size, OBJECT_SYSTEM, 
				 thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }
    if ( pindex != NULL ) {
        *pindex = object_index;
    }
    if ( psite != NULL ) {
	*psite = object_site_index;
    }
}
Exemplo n.º 2
0
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL
stack_object(jvmtiHeapRootKind root_kind, 
		jlong class_tag, jlong size, jlong* tag_ptr, 
		jlong thread_tag, jint depth, jmethodID method, jint slot,
		void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    ObjectIndex  object_index;
    SerialNumber thread_serial_num;

    HPROF_ASSERT(tag_ptr!=NULL);
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index = tag_extract(*tag_ptr);
	thread_serial_num = object_get_thread_serial_number(object_index);
        thread_serial_num = checkThreadSerialNumber(thread_serial_num);
    } else {
	SiteIndex site_index;
	
        site_index = site_find_or_create(find_cnum(class_tag), 
				gdata->system_trace_index);
	if ( thread_tag != (jlong)0 ) {
	    ObjectIndex thread_object_index;

	    thread_object_index = tag_extract(thread_tag);
	    thread_serial_num = 
	           object_get_thread_serial_number(thread_object_index);
            thread_serial_num = checkThreadSerialNumber(thread_serial_num);
	} else {
	    thread_serial_num = gdata->unknown_thread_serial_num;
	}
	object_index = object_new(site_index, (jint)size, OBJECT_SYSTEM,
			    thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }

    HPROF_ASSERT(thread_serial_num!=0);
    HPROF_ASSERT(object_index!=0);
    switch ( root_kind ) {
        case JVMTI_HEAP_ROOT_STACK_LOCAL:
	    io_heap_root_java_frame(object_index, thread_serial_num, depth);
	    break;
        case JVMTI_HEAP_ROOT_JNI_LOCAL:
	    io_heap_root_jni_local(object_index, thread_serial_num, depth);
	    break;
	default:
	    break;
    }
    return JVMTI_ITERATION_CONTINUE;
}
Exemplo n.º 3
0
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL
reference_object(jvmtiObjectReferenceKind reference_kind, 
		jlong class_tag, jlong size, jlong* tag_ptr, 
		jlong referrer_tag, jint referrer_index, void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    RefIndex      ref_index;
    RefIndex      prev_ref_index;
    ObjectIndex   referrer_object_index;
    ObjectIndex   object_index;
    jlong         object_tag;

    HPROF_ASSERT(tag_ptr!=NULL);
    HPROF_ASSERT(referrer_tag!=(jlong)0);
    
    if ( referrer_tag != (jlong)0 ) {
	referrer_object_index = tag_extract(referrer_tag);
    } else {
        return JVMTI_ITERATION_CONTINUE;
    }
    
    object_tag = *tag_ptr;
    if ( object_tag != (jlong)0 ) {
        object_index = tag_extract(object_tag);
    } else {
        SiteIndex site_index;
	
        site_index = site_find_or_create(find_cnum(class_tag), 
			gdata->system_trace_index);
	object_index = object_new(site_index, (jint)size, OBJECT_SYSTEM,
				gdata->system_thread_serial_num);
	object_tag = tag_create(object_index);
	*tag_ptr   = object_tag;
    }

    /* Save reference information */
    prev_ref_index = object_get_references(referrer_object_index);
    ref_index = reference_new(prev_ref_index, reference_kind,
		    class_tag, size, object_tag, referrer_index);
    object_set_references(referrer_object_index, ref_index);
    
    return JVMTI_ITERATION_CONTINUE;
}
/* Create tag and object entry for an untagged object (should be rare) */
static jlong
make_new_tag(jlong class_tag, jlong size, TraceIndex trace_index,
                  SerialNumber thread_serial_num,
                  ObjectIndex *pindex, SiteIndex *psite)
{
    ObjectIndex object_index;
    SiteIndex   object_site_index;

    HPROF_ASSERT(class_tag!=(jlong)0);
    object_site_index = site_find_or_create(find_cnum(class_tag), trace_index);
    object_index      = object_new(object_site_index, (jint)size, 
                                   OBJECT_SYSTEM, thread_serial_num);
    if ( pindex != NULL ) {
        *pindex = object_index;
    }
    if ( psite != NULL ) {
        *psite = object_site_index;
    }
    return tag_create(object_index);
}
Exemplo n.º 5
0
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL 
root_object(jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, 
		jlong* tag_ptr, void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    ObjectIndex   object_index;
    SiteIndex     object_site_index;
    
    HPROF_ASSERT(tag_ptr!=NULL);
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index      = tag_extract(*tag_ptr);
	object_site_index = object_get_site(object_index);
    } else {
        object_site_index = site_find_or_create(find_cnum(class_tag), 
				gdata->system_trace_index);
	object_index      = object_new(object_site_index, (jint)size, 
			    OBJECT_SYSTEM, gdata->system_thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }

    switch ( root_kind ) {
        case JVMTI_HEAP_ROOT_JNI_GLOBAL: {
		SerialNumber trace_serial_num;
		SerialNumber gref_serial_num;
		
		if ( object_site_index != 0 ) {
		    SiteKey     *pkey;
		    TraceIndex  trace_index;
		    
		    pkey = get_pkey(object_site_index);
		    trace_index = pkey->trace_index;
		    trace_serial_num = trace_get_serial_number(trace_index);
		} else {
		    trace_serial_num = 
			trace_get_serial_number(gdata->system_trace_index);
		}
		gref_serial_num = gdata->gref_serial_number_counter++;
		io_heap_root_jni_global(object_index, gref_serial_num, 
					trace_serial_num);
		break;
	    }
        case JVMTI_HEAP_ROOT_SYSTEM_CLASS: {
		char *sig;

		sig = "Unknown";
		if ( object_site_index != 0 ) {
		    SiteKey *pkey;
		    
		    pkey = get_pkey(object_site_index);
		    sig = string_get(class_get_signature(pkey->cnum));
		}
		io_heap_root_system_class(object_index, sig);
		break;
	    }
        case JVMTI_HEAP_ROOT_MONITOR: {
		io_heap_root_monitor(object_index);
		break;
	    }
        case JVMTI_HEAP_ROOT_THREAD: {
		SerialNumber thread_serial_num;

		if ( object_index != 0 ) {
		    thread_serial_num = 
			  object_get_thread_serial_number(object_index);
		} else {
		    thread_serial_num = gdata->system_thread_serial_num;
		}
		io_heap_root_thread(object_index, thread_serial_num);
		break;
	    }
        case JVMTI_HEAP_ROOT_OTHER: {
		io_heap_root_unknown(object_index);
		break;
	    }
	default:
	    break;
    }
    return JVMTI_ITERATION_CONTINUE;
}