Exemple #1
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;
}
/* Get the object index and thread serial number for this local object */
static void
localReference(jlong *tag_ptr, jlong class_tag, jlong thread_tag, 
     jlong size, ObjectIndex *pobject_index, SerialNumber *pthread_serial_num)
{
    ObjectIndex  object_index;
    SerialNumber thread_serial_num;

    HPROF_ASSERT(pobject_index!=NULL);
    HPROF_ASSERT(pthread_serial_num!=NULL);
    HPROF_ASSERT(tag_ptr!=NULL);
    HPROF_ASSERT(class_tag!=(jlong)0);
    
    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 {
        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;
        }
        /* Create and set the tag. */
        *tag_ptr = make_new_tag(class_tag, size, gdata->system_trace_index,
                  thread_serial_num, &object_index, NULL);
    }

    HPROF_ASSERT(thread_serial_num!=0);
    HPROF_ASSERT(object_index!=0);
    *pobject_index      = object_index;
    *pthread_serial_num = thread_serial_num;
}