[kaffe] CVS kaffe (guilhem): Important JVMPI fixes. A few fixes for some compilers too.

Kaffe CVS cvs-commits at kaffe.org
Tue Jul 19 09:32:24 PDT 2005


PatchSet 6748 
Date: 2005/07/19 16:27:28
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Important JVMPI fixes. A few fixes for some compilers too.

	* include/jvmpi.h: Added support for JVMPI_VERSION_1_2.

	* include/kaffe_jni.h: Added new VM parameters about the profiler
	to load at startup.

	* kaffe/jvmpi/Makefile.am: JVMPI should be compiled and linked
	like the rest of the VM.

	* kaffe/jvmpi/Makefile.in: Regenerated.

	* kaffe/jvmpi/jvmpi_kaffe.c,
	kaffe/jvmpi/jvmpi_kaffe.h
	(jvmpiFillObjectLoad): Handle array more correctly.
	(jvmpiFillClassLoad): Fill the right structure entry using the
	instance field lists.
	(jvmpiFillMethodLoad): New function.
	(jvmpiRawMonitorCreate,
	jvmpiRawMonitorEnter,
	jvmpiRawMonitorExit,
	jvmpiRawMonitorWait,
	jvmpiRawMonitorNotifyAll,
	jvmpiRawMonitorDestroy): Use Klocks.
	(jvmpiRequestEvent): Return success if successful.
	(jvmpiCleanupThreadStart): New function.

	* kaffe/kaffe/main.c
	(options): Loading and executing the profiler is now handled by
	JNI itself.

	* kaffe/kaffevm/classPool.c
	(walkClassPool): Only walk valid entries.

	* kaffe/kaffevm/external.c,
	kaffe/kaffevm/external.h
	(loadNativeLibrary): Use "const char *" for the library name.

	* kaffe/kaffevm/gcFuncs.c
	(destroyClass): JVMPI is supported for all translators. Fixed
	typo.

	* kaffe/kaffevm/kaffe.def
	(IRETURN, LRETURN, FRETURN,
	DRETURN, ARETURN, RETURN): Acknowledge method exit.

	* kaffe/kaffevm/locks.c: Removed slowlock's timing. Updated JVMPI
	event handling for contended mutexes as the algorithm has changed.

	* kaffe/kaffevm/soft.c
	(soft_enter_method): Rearranged ifdefs.

	* kaffe/kaffevm/stats.c,
	kaffe/kaffevm/stats.h: Put variable definitions in KAFFE_STATS
	(for darwin). Added fulljit timer.

	* kaffe/kaffevm/thread.c
	(firstStartThread): Use jvmpiCleanupThreadStart now.

	* kaffe/kaffevm/intrp/machine.c
	(virtualMachine): Acknowledge enter/exit method using JVMPI.

	* kaffe/kaffevm/jit/machine.c
	(translate): Acknowledge translate completion.

	* kaffe/kaffevm/jit/native-wrapper.c
	(Kaffe_wrapper): Invoke exit_method() before method exit.

	* kaffe/kaffevm/jit3/machine.c
	(translate): Measure translation time using fulljit. Moved JVMPI
	event handling into an helper function.

	* kaffe/kaffevm/intrp/icode.h,
	kaffe/kaffevm/jit/codeproto.h,
	kaffe/kaffevm/jit/icode.c,
	kaffe/kaffevm/jit3/codeproto.h,
	kaffe/kaffevm/jit3/icode.c
	(exit_method) New icode to be called before exiting a method.
	(softcall_enter_method, softcall_exit_method): Implemented in JIT.

	* kaffe/kaffevm/jni/jni-base.c
	(JNI_CreateJavaVM): Load and invoke the profiler if needed.

	* kaffe/kaffevm/jni/jni-refs.c
	(KaffeJNI_NewWeakGlobalRef, KaffeJNI_DeleteWeakGlobalRef): Handle
	JVMPI events.

	* kaffe/kaffevm/jni/jni.c
	(Kaffe_GetEnv): Accept JVMPI 1.2.
	(Kaffe_JavaVMInitArgs): Initialize the new fields to NULL.

	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
	(jthread_on_condvar, jthread_on_mutex, jthread_has_run,
	jthread_clear_run, jthread_get_status, jthread_from_data): Implemented.

Members: 
	ChangeLog:1.4273->1.4274 
	include/jvmpi.h:INITIAL->1.7 
	include/kaffe_jni.h:1.2->1.3 
	kaffe/jvmpi/Makefile.am:INITIAL->1.9 
	kaffe/jvmpi/Makefile.in:1.72->1.73 
	kaffe/jvmpi/jvmpi_kaffe.c:1.11->1.12 
	kaffe/jvmpi/jvmpi_kaffe.h:1.3->1.4 
	kaffe/kaffe/main.c:1.89->1.90 
	kaffe/kaffevm/classPool.c:1.36->1.37 
	kaffe/kaffevm/external.c:1.81->1.82 
	kaffe/kaffevm/external.h:INITIAL->1.12 
	kaffe/kaffevm/gcFuncs.c:1.78->1.79 
	kaffe/kaffevm/kaffe.def:1.40->1.41 
	kaffe/kaffevm/locks.c:1.62->1.63 
	kaffe/kaffevm/soft.c:1.78->1.79 
	kaffe/kaffevm/stats.c:1.9->1.10 
	kaffe/kaffevm/stats.h:1.3->1.4 
	kaffe/kaffevm/thread.c:1.102->1.103 
	kaffe/kaffevm/intrp/icode.h:1.25->1.26 
	kaffe/kaffevm/intrp/machine.c:1.50->1.51 
	kaffe/kaffevm/jit/codeproto.h:INITIAL->1.6 
	kaffe/kaffevm/jit/icode.c:1.35->1.36 
	kaffe/kaffevm/jit/machine.c:1.80->1.81 
	kaffe/kaffevm/jit/native-wrapper.c:1.11->1.12 
	kaffe/kaffevm/jit3/codeproto.h:INITIAL->1.18 
	kaffe/kaffevm/jit3/icode.c:1.57->1.58 
	kaffe/kaffevm/jit3/machine.c:1.76->1.77 
	kaffe/kaffevm/jni/jni-base.c:1.20->1.21 
	kaffe/kaffevm/jni/jni-refs.c:1.2->1.3 
	kaffe/kaffevm/jni/jni.c:1.35->1.36 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.85->1.86 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.40->1.41 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4273 kaffe/ChangeLog:1.4274
--- kaffe/ChangeLog:1.4273	Tue Jul 19 13:07:49 2005
+++ kaffe/ChangeLog	Tue Jul 19 16:27:28 2005
@@ -1,5 +1,101 @@
 2005-07-19  Guilhem Lavaux  <guilhem at kaffe.org>
 
+	* include/jvmpi.h: Added support for JVMPI_VERSION_1_2.
+
+	* include/kaffe_jni.h: Added new VM parameters about the profiler
+	to load at startup.
+
+	* kaffe/jvmpi/Makefile.am: JVMPI should be compiled and linked
+	like the rest of the VM.
+
+	* kaffe/jvmpi/Makefile.in: Regenerated.
+
+	* kaffe/jvmpi/jvmpi_kaffe.c,
+	kaffe/jvmpi/jvmpi_kaffe.h
+	(jvmpiFillObjectLoad): Handle array more correctly.
+	(jvmpiFillClassLoad): Fill the right structure entry using the
+	instance field lists.
+	(jvmpiFillMethodLoad): New function.
+	(jvmpiRawMonitorCreate,
+	jvmpiRawMonitorEnter,
+	jvmpiRawMonitorExit,
+	jvmpiRawMonitorWait,
+	jvmpiRawMonitorNotifyAll,
+	jvmpiRawMonitorDestroy): Use Klocks.
+	(jvmpiRequestEvent): Return success if successful.
+	(jvmpiCleanupThreadStart): New function.
+	
+	* kaffe/kaffe/main.c
+	(options): Loading and executing the profiler is now handled by
+	JNI itself.
+
+	* kaffe/kaffevm/classPool.c
+	(walkClassPool): Only walk valid entries.
+
+	* kaffe/kaffevm/external.c,
+	kaffe/kaffevm/external.h
+	(loadNativeLibrary): Use "const char *" for the library name.
+
+	* kaffe/kaffevm/gcFuncs.c
+	(destroyClass): JVMPI is supported for all translators. Fixed
+	typo.
+
+	* kaffe/kaffevm/kaffe.def
+	(IRETURN, LRETURN, FRETURN,
+	DRETURN, ARETURN, RETURN): Acknowledge method exit.
+
+	* kaffe/kaffevm/locks.c: Removed slowlock's timing. Updated JVMPI
+	event handling for contended mutexes as the algorithm has changed.
+
+	* kaffe/kaffevm/soft.c
+	(soft_enter_method): Rearranged ifdefs.
+
+	* kaffe/kaffevm/stats.c,
+	kaffe/kaffevm/stats.h: Put variable definitions in KAFFE_STATS
+	(for darwin). Added fulljit timer.
+
+	* kaffe/kaffevm/thread.c
+	(firstStartThread): Use jvmpiCleanupThreadStart now.
+	
+	* kaffe/kaffevm/intrp/machine.c
+	(virtualMachine): Acknowledge enter/exit method using JVMPI.
+
+	* kaffe/kaffevm/jit/machine.c
+	(translate): Acknowledge translate completion.
+
+	* kaffe/kaffevm/jit/native-wrapper.c
+	(Kaffe_wrapper): Invoke exit_method() before method exit.
+
+	* kaffe/kaffevm/jit3/machine.c
+	(translate): Measure translation time using fulljit. Moved JVMPI
+	event handling into an helper function.
+	
+	* kaffe/kaffevm/intrp/icode.h,
+	kaffe/kaffevm/jit/codeproto.h,
+	kaffe/kaffevm/jit/icode.c,
+	kaffe/kaffevm/jit3/codeproto.h,
+	kaffe/kaffevm/jit3/icode.c
+	(exit_method) New icode to be called before exiting a method.
+	(softcall_enter_method, softcall_exit_method): Implemented in JIT.
+
+	* kaffe/kaffevm/jni/jni-base.c
+	(JNI_CreateJavaVM): Load and invoke the profiler if needed.
+
+	* kaffe/kaffevm/jni/jni-refs.c
+	(KaffeJNI_NewWeakGlobalRef, KaffeJNI_DeleteWeakGlobalRef): Handle
+	JVMPI events.
+
+	* kaffe/kaffevm/jni/jni.c
+	(Kaffe_GetEnv): Accept JVMPI 1.2.
+	(Kaffe_JavaVMInitArgs): Initialize the new fields to NULL.
+
+	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
+	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
+	(jthread_on_condvar, jthread_on_mutex, jthread_has_run,
+	jthread_clear_run, jthread_get_status, jthread_from_data): Implemented.
+
+2005-07-19  Guilhem Lavaux  <guilhem at kaffe.org>
+
 	* configure: Regenerated.
 
 2005-07-19  Dalibor Topic  <robilad at kaffe.org>
===================================================================
Checking out kaffe/include/jvmpi.h
RCS:  /home/cvs/kaffe/kaffe/include/jvmpi.h,v
VERS: 1.7
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/include/jvmpi.h	Tue Jul 19 16:32:23 2005
@@ -0,0 +1,381 @@
+/*
+ * jvmpi.h
+ * Java Virtual Machine Profiling Interface
+ */
+
+#ifndef _KAFFE_JVMPI_H
+#define _KAFFE_JVMPI_H
+
+#include <jni.h>
+
+/* JVMPI version numbers. */
+#define JVMPI_VERSION_1	0x10000001
+#define JVMPI_VERSION_1_1	0x10000002
+#define JVMPI_VERSION_1_2	0x10000003
+
+typedef void *jobjectID;
+
+enum {
+	JVMPI_FAIL = -1,
+	JVMPI_SUCCESS,
+	JVMPI_NOT_AVAILABLE
+};
+
+enum {
+	JVMPI_THREAD_RUNNABLE = 1,
+	JVMPI_THREAD_MONITOR_WAIT,
+	JVMPI_THREAD_CONDVAR_WAIT
+};
+
+enum {
+	JVMPI_THREAD_INTERRUPTED = 0x4000,
+	JVMPI_THREAD_SUSPENDED = 0x8000
+};
+
+enum {
+	JVMPI_MINIMUM_PRIORITY = 1,
+	JVMPI_NORMAL_PRIORITY = 5,
+	JVMPI_MAXIMUM_PRIORITY = 10
+};
+
+enum {
+	JVMPI_EVENT_METHOD_ENTRY = 1,
+	JVMPI_EVENT_METHOD_ENTRY2,
+	JVMPI_EVENT_METHOD_EXIT,
+	
+	JVMPI_EVENT_OBJECT_ALLOC = 4,
+	JVMPI_EVENT_OBJECT_FREE,
+	JVMPI_EVENT_OBJECT_MOVE,
+	
+	JVMPI_EVENT_COMPILED_METHOD_LOAD = 7,
+	JVMPI_EVENT_COMPILED_METHOD_UNLOAD,
+	
+	JVMPI_EVENT_INSTRUCTION_START = 9,
+	
+	JVMPI_EVENT_THREAD_START = 33,
+	JVMPI_EVENT_THREAD_END,
+	
+	JVMPI_EVENT_CLASS_LOAD_HOOK = 35,
+	
+	JVMPI_EVENT_HEAP_DUMP = 37,
+	
+	JVMPI_EVENT_JNI_GLOBALREF_ALLOC = 38,
+	JVMPI_EVENT_JNI_GLOBALREF_FREE,
+	JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC,
+	JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE,
+	
+	JVMPI_EVENT_CLASS_LOAD = 42,
+	JVMPI_EVENT_CLASS_UNLOAD,
+	
+	JVMPI_EVENT_DATA_DUMP_REQUEST = 44,
+	JVMPI_EVENT_DATA_RESET_REQUEST,
+	
+	JVMPI_EVENT_JVM_INIT_DONE = 46,
+	JVMPI_EVENT_JVM_SHUT_DOWN,
+	
+	JVMPI_EVENT_ARENA_NEW = 48,
+	JVMPI_EVENT_ARENA_DELETE,
+	
+	JVMPI_EVENT_OBJECT_DUMP = 50,
+	
+	JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER = 51,
+	JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED,
+	JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT,
+	JVMPI_EVENT_MONITOR_CONTENDED_ENTER,
+	JVMPI_EVENT_MONITOR_CONTENDED_ENTERED,
+	JVMPI_EVENT_MONITOR_CONTENDED_EXIT,
+	JVMPI_EVENT_MONITOR_WAIT,
+	JVMPI_EVENT_MONITOR_WAITED,
+	JVMPI_EVENT_MONITOR_DUMP,
+	
+	JVMPI_EVENT_GC_START = 60,
+	JVMPI_EVENT_GC_FINISH,
+	
+	JVMPI_EVENT_COUNT,
+	
+	JVMPI_REQUESTED_EVENT = 0x10000000
+};
+
+enum {
+	JVMPI_DUMP_LEVEL_0,
+	JVMPI_DUMP_LEVEL_1,
+	JVMPI_DUMP_LEVEL_2
+};
+
+enum {
+	JVMPI_NORMAL_OBJECT = 0,
+	JVMPI_CLASS = 2,
+	JVMPI_BOOLEAN = 4,
+	JVMPI_CHAR = 5,
+	JVMPI_FLOAT = 6,
+	JVMPI_DOUBLE = 7,
+	JVMPI_BYTE = 8,
+	JVMPI_SHORT = 9,
+	JVMPI_INT = 10,
+	JVMPI_LONG = 11
+};
+
+enum {
+	JVMPI_GC_ROOT_JNI_GLOBAL = 1,
+	JVMPI_GC_ROOT_JNI_LOCAL,
+	JVMPI_GC_ROOT_JAVA_FRAME,
+	JVMPI_GC_ROOT_NATIVE_STACK,
+	JVMPI_GC_ROOT_STICKY_CLASS,
+	JVMPI_GC_ROOT_THREAD_BLOCK,
+	JVMPI_GC_ROOT_MONITOR_USED,
+	JVMPI_GC_ROOT_THREAD_OBJ,
+	
+	JVMPI_GC_CLASS_DUMP = 0x20,
+	JVMPI_GC_INSTANCE_DUMP,
+	JVMPI_GC_OBJ_ARRAY_DUMP,
+	JVMPI_GC_PRIM_ARRAY_DUMP,
+	
+	JVMPI_GC_ROOT_UNKNOWN = 0xff
+};
+
+enum {
+	JVMPI_MONITOR_JAVA = 1,
+	JVMPI_MONITOR_RAW
+};
+
+typedef struct {
+	jint lineno;
+	jmethodID method_id;
+} JVMPI_CallFrame;
+
+typedef struct {
+	JNIEnv *env_id;
+	jint num_frames;
+	JVMPI_CallFrame *frames;
+} JVMPI_CallTrace;
+
+typedef struct {
+	const char *field_name;
+	const char *field_signature;
+} JVMPI_Field;
+
+typedef struct {
+	jint heap_dump_level;
+} JVMPI_HeapDumpArg;
+
+typedef struct {
+	jint offset;
+	jint lineno;
+} JVMPI_Lineno;
+
+typedef struct {
+	const char *method_name;
+	const char *method_signature;
+	jint start_lineno;
+	jint end_lineno;
+	jmethodID method_id;
+} JVMPI_Method;
+
+typedef struct _JVMPI_RawMonitor *JVMPI_RawMonitor;
+
+typedef struct {
+	jint event_type;
+	JNIEnv *env_id;
+  
+	union {
+		struct {
+			jint arena_id;
+			char *arena_name;
+		} new_arena;
+
+		struct {
+			jint arena_id;
+		} delete_arena;
+		
+		struct {
+			unsigned char *class_data;
+			jint class_data_len;
+			unsigned char *new_class_data;
+			jint new_class_data_len;
+			void * (*malloc_f)(unsigned int);
+		} class_load_hook;
+
+		struct {
+			const char *class_name;
+			char *source_name;
+			jint num_interfaces;
+			jint num_methods;
+			JVMPI_Method *methods;
+			jint num_static_fields;
+			JVMPI_Field *statics;
+			jint num_instance_fields;
+			JVMPI_Field *instances;
+			jobjectID class_id;
+		} class_load;
+
+		struct {
+			jobjectID class_id;
+		} class_unload;
+
+		struct {
+			jmethodID method_id;
+			void *code_addr;
+			jint code_size;
+			jint lineno_table_size;
+			JVMPI_Lineno *lineno_table;
+		} compiled_method_load;
+
+		struct { 
+			jmethodID method_id;
+		} compiled_method_unload;
+		
+		struct {
+			jlong used_objects;
+			jlong used_object_space;
+			jlong total_object_space;
+		} gc_info;
+
+		struct {
+			int dump_level;
+			char *begin;
+			char *end;
+			jint num_traces;
+			JVMPI_CallTrace *traces;
+		} heap_dump;
+
+		struct {
+			jobjectID obj_id;
+			jobject ref_id;
+		} jni_globalref_alloc;
+
+		struct {
+			jobject ref_id;
+		} jni_globalref_free;
+
+		struct {
+			jmethodID method_id;
+		} method;
+		
+		struct {
+			jmethodID method_id;
+			jobjectID obj_id;
+		} method_entry2;
+
+		struct {
+			jobjectID object;
+		} monitor;
+
+		struct {
+			char *begin;
+			char *end;
+			jint num_traces;
+			JVMPI_CallTrace *traces;
+			jint *threads_status;
+		} monitor_dump;
+
+		struct {
+			jobjectID object;
+			jlong timeout;
+		} monitor_wait;
+
+		struct {
+			jint arena_id;
+			jobjectID class_id;
+			jint is_array;
+			jint size;
+			jobjectID obj_id;
+		} obj_alloc;
+
+		struct {
+			jobjectID obj_id;
+		} obj_free;
+
+		struct {
+			jint data_len;
+			char *data;
+		} object_dump;
+
+		struct {
+			jint arena_id;
+			jobjectID obj_id;
+			jint new_arena_id;
+			jobjectID new_obj_id;
+		} obj_move;
+
+		struct {
+			char *name;
+			JVMPI_RawMonitor id;
+		} raw_monitor;
+
+		struct {
+			char *thread_name;
+			char *group_name;
+			char *parent_name;
+			jobjectID thread_id;
+			JNIEnv *thread_env_id;
+		} thread_start;
+
+		struct {
+			jmethodID method_id;
+			jint offset;
+			union {
+				struct {
+					jboolean is_true;
+				} if_info;
+				struct {
+					jint key;
+					jint low;
+					jint hi;
+				} tableswitch_info;
+				struct {
+					jint chosen_pair_index;
+					jboolean is_default;
+				} lookupswitch_info;
+			} u;
+		} instruction;
+	} u;
+} JVMPI_Event;
+
+typedef struct {
+	jint version;
+
+	void (*NotifyEvent)(JVMPI_Event *event);
+
+	jint (*EnableEvent)(jint event_type, void *arg);
+	jint (*DisableEvent)(jint event_type, void *arg);
+	jint (*RequestEvent)(jint event_type, void *arg);
+
+	void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
+
+	void (*ProfilerExit)(jint);
+
+	JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
+	void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
+	void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
+	void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
+	void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
+	void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
+
+	jlong (*GetCurrentThreadCpuTime)(void);
+	void (*SuspendThread)(JNIEnv *env);
+	void (*ResumeThread)(JNIEnv *env);
+	jint (*GetThreadStatus)(JNIEnv *env);
+	jboolean (*ThreadHasRun)(JNIEnv *env);
+	jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
+	void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
+	void * (*GetThreadLocalStorage)(JNIEnv *env_id);
+
+	void (*DisableGC)(void);
+	void (*EnableGC)(void);
+	void (*RunGC)(void);
+
+	jobjectID (*GetThreadObject)(JNIEnv *env);
+	jobjectID (*GetMethodClass)(jmethodID mid);
+
+	/* JNI handle <-> object ID conversions; VERSION_1_1 and newer */
+
+	jobject   (*jobjectID2jobject)(jobjectID jid);
+	jobjectID (*jobject2jobjectID)(jobject   j);
+
+	/* VERSION_1_2 and newer: */
+
+	void (*SuspendThreadList)(jint reqCount, JNIEnv **reqList, jint *results);
+	void (*ResumeThreadList)(jint reqCount, JNIEnv **reqList, jint *results);
+} JVMPI_Interface;
+
+#endif
Index: kaffe/include/kaffe_jni.h
diff -u kaffe/include/kaffe_jni.h:1.2 kaffe/include/kaffe_jni.h:1.3
--- kaffe/include/kaffe_jni.h:1.2	Thu Mar 31 10:39:27 2005
+++ kaffe/include/kaffe_jni.h	Tue Jul 19 16:27:33 2005
@@ -25,6 +25,8 @@
         jint            allocHeapSize;
         const char*     classhome;
         const char*     libraryhome;
+        const char*     profilerLibname;
+        const char*     profilerArguments;
 } KaffeVM_Arguments;
 
 extern KaffeVM_Arguments Kaffe_JavaVMArgs;
===================================================================
Checking out kaffe/kaffe/jvmpi/Makefile.am
RCS:  /home/cvs/kaffe/kaffe/kaffe/jvmpi/Makefile.am,v
VERS: 1.9
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/jvmpi/Makefile.am	Tue Jul 19 16:32:24 2005
@@ -0,0 +1,26 @@
+
+AM_CPPFLAGS = -I$(top_srcdir)/kaffe/kaffevm/$(THREAD_DIR) $(ENGINE_INCLUDES) -I$(top_srcdir)/libltdl $(ENGINE_DEFS) -I$(top_srcdir)/kaffe/kaffevm -I$(top_builddir)/include
+
+lib_LTLIBRARIES = libkaffejvmpi.la
+
+libkaffejvmpi_la_CFLAGS = \
+	$(CFLAGS_PG)
+
+libkaffejvmpi_la_LDFLAGS = \
+	-no-undefined \
+	-export-dynamic \
+	-release $(PACKAGE_VERSION)
+
+libkaffejvmpi_la_DEPENDENCIES = \
+	$(LIBLTDL) \
+	$(top_builddir)/kaffe/kaffevm/libkaffevm.la
+
+libkaffejvmpi_la_LIBADD = \
+	$(libkaffejvmpi_la_DEPENDENCIES) \
+	$(KVMLIBFLAGS) \
+	$(VM_LIBS) \
+	$(M_LIBS)
+
+libkaffejvmpi_la_SOURCES = \
+	jvmpi_kaffe.c \
+	jvmpi_kaffe.h
Index: kaffe/kaffe/jvmpi/Makefile.in
diff -u kaffe/kaffe/jvmpi/Makefile.in:1.72 kaffe/kaffe/jvmpi/Makefile.in:1.73
--- kaffe/kaffe/jvmpi/Makefile.in:1.72	Tue Jul 19 01:16:08 2005
+++ kaffe/kaffe/jvmpi/Makefile.in	Tue Jul 19 16:27:34 2005
@@ -389,6 +389,7 @@
 
 libkaffejvmpi_la_LIBADD = \
 	$(libkaffejvmpi_la_DEPENDENCIES) \
+	$(KVMLIBFLAGS) \
 	$(VM_LIBS) \
 	$(M_LIBS)
 
Index: kaffe/kaffe/jvmpi/jvmpi_kaffe.c
diff -u kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.11 kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.12
--- kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.11	Sun May 22 15:49:46 2005
+++ kaffe/kaffe/jvmpi/jvmpi_kaffe.c	Tue Jul 19 16:27:34 2005
@@ -5,6 +5,10 @@
  * Copyright (c) 2003 University of Utah and the Flux Group.
  * All rights reserved.
  *
+ * Copyright (c) 2003-2005 
+ *    The Kaffe.org's developers. All Rights reserved.
+ *    See ChangeLog for details.
+ *
  * This file is licensed under the terms of the GNU Public License.
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -41,7 +45,8 @@
 	JVMPI_Interface *retval;
 
 	assert((version == JVMPI_VERSION_1) ||
-	       (version == JVMPI_VERSION_1_1));
+	       (version == JVMPI_VERSION_1_1) ||
+	       (version == JVMPI_VERSION_1_2));
 	
 	retval = &jvmpi_data.jk_Interface;
 	retval->version = version;
@@ -133,37 +138,44 @@
 	if( CLASS_IS_ARRAY(cl) )
 	{
 		jint prim_type = 0;
+		Hjava_lang_Class *eclazz = CLASS_ELEMENT_TYPE(cl);
 		
-		switch( CLASS_PRIM_SIG(CLASS_ELEMENT_TYPE(cl)) )
-		{
-		case 'I':
+		if (CLASS_IS_PRIMITIVE(eclazz))
+		  {
+		    switch( CLASS_PRIM_SIG(eclazz) )
+		      {
+		      case 'I':
 			prim_type = JVMPI_INT;
 			break;
-		case 'Z':
+		      case 'Z':
 			prim_type = JVMPI_BOOLEAN;
 			break;
-		case 'S':
+		      case 'S':
 			prim_type = JVMPI_SHORT;
 			break;
-		case 'B':
+		      case 'B':
 			prim_type = JVMPI_BYTE;
 			break;
-		case 'C':
+		      case 'C':
 			prim_type = JVMPI_CHAR;
 			break;
-		case 'F':
+		      case 'F':
 			prim_type = JVMPI_FLOAT;
 			break;
-		case 'D':
+		      case 'D':
 			prim_type = JVMPI_DOUBLE;
 			break;
-		case 'J':
+		      case 'J':
 			prim_type = JVMPI_LONG;
 			break;
-		default:
-			assert(0);
+		      default:
+			dprintf("Invalid primitive signature in jvmpiFillObjectAlloc\n");
+			KAFFEVM_ABORT();
 			break;
-		}
+		      }
+		  }
+		else
+		  prim_type = JVMPI_CLASS;
 		ev->u.obj_alloc.is_array = prim_type;
 	}
 	else
@@ -198,6 +210,13 @@
 		&KTHREAD(get_data)((jthread_t)tid->vmThread->vmdata)->jniEnv;
 }
 
+void jvmpiCleanupThreadStart(JVMPI_Event *ev)
+{
+        KFREE(ev->u.thread_start.parent_name);
+	KFREE(ev->u.thread_start.group_name);
+	KFREE(ev->u.thread_start.thread_name);
+}
+
 void jvmpiFillClassLoad(JVMPI_Event *ev, struct Hjava_lang_Class *cl)
 {
 	int lpc;
@@ -217,7 +236,7 @@
 	}
 	for( lpc = 0; lpc < CLASS_NIFIELDS(cl); lpc++ )
 	{
-		jvmpiConvertField(&ev->u.class_load.statics[lpc],
+		jvmpiConvertField(&ev->u.class_load.instances[lpc],
 				  &CLASS_IFIELDS(cl)[lpc]);
 	}
 	ev->event_type = JVMPI_EVENT_CLASS_LOAD;
@@ -230,6 +249,39 @@
 	ev->u.class_load.class_id = cl;
 }
 
+void jvmpiFillMethodLoad(JVMPI_Event *ev, Method *xmeth)
+{
+  ev->event_type = JVMPI_EVENT_COMPILED_METHOD_LOAD;
+  ev->u.compiled_method_load.method_id = xmeth;
+  ev->u.compiled_method_load.code_addr = METHOD_NATIVECODE(xmeth);
+  ev->u.compiled_method_load.code_size =
+    (uintp)xmeth->c.ncode.ncode_end - (uintp)xmeth->c.ncode.ncode_start;
+  
+  if( xmeth->lines )
+    {
+      JVMPI_Lineno *jvmpi_lineno = NULL;
+      int lpc;
+      
+      jvmpi_lineno = alloca(sizeof(JVMPI_Lineno) *
+			    xmeth->lines->length);
+      for( lpc = 0; lpc < xmeth->lines->length; lpc++ )
+	{
+	  jvmpiConvertLineno(&jvmpi_lineno[lpc],
+			     &xmeth->lines->entry[lpc],
+			     METHOD_NATIVECODE(xmeth));
+	}
+      ev.u.compiled_method_load.lineno_table_size =
+	xmeth->lines->length;
+      ev.u.compiled_method_load.lineno_table =
+	jvmpi_lineno;
+    }
+  else
+    {
+      ev->u.compiled_method_load.lineno_table_size = 0;
+      ev->u.compiled_method_load.lineno_table = NULL;
+    }
+}
+
 static jint jvmpiCreateSystemThread(char *name,
 				    jint priority,
 				    void (*f)(void *))
@@ -505,8 +557,7 @@
 
 	if( (retval = jmalloc(sizeof(struct _JVMPI_RawMonitor))) != NULL )
 	{
-		jmutex_initialise(&retval->mux);
-		jcondvar_initialise(&retval->cv);
+	        initStaticLock(&retval->monitor);
 		retval->lock_name = lock_name;
 	}
 	return( retval );
@@ -516,8 +567,7 @@
 {
 	if( lock_id != NULL )
 	{
-		KMUTEX(destroy)(&lock_id->mux);
-		KCONDVAR(destroy)(&lock_id->cv);
+	        destroyStaticLock(&lock_id->monitor);
 		jfree(lock_id);
 	}
 }
@@ -526,28 +576,28 @@
 {
 	assert(lock_id != NULL);
 	
-	KMUTEX(lock)(&lock_id->mux);
+	lockStaticMutex(&lock_id->monitor);
 }
 
 static void jvmpiRawMonitorExit(JVMPI_RawMonitor lock_id)
 {
 	assert(lock_id != NULL);
 	
-	KMUTEX(unlock)(&lock_id->mux);
+	unlockStaticMutex(&lock_id->monitor);
 }
 
 static void jvmpiRawMonitorNotifyAll(JVMPI_RawMonitor lock_id)
 {
 	assert(lock_id != NULL);
 	
-	KCONDVAR(broadcast)(&lock_id->cv, &lock_id->mux);
+	broadcastStaticCond(&lock_id->monitor);
 }
 
 static void jvmpiRawMonitorWait(JVMPI_RawMonitor lock_id, jlong ms)
 {
 	assert(lock_id != NULL);
 	
-	KCONDVAR(wait)(&lock_id->cv, &lock_id->mux, ms);
+	waitStaticCond(&lock_id->monitor, ms);
 }
 
 static jint jvmpiRequestEvent(jint event_type, void *arg)
@@ -569,6 +619,7 @@
 			JVMPI_Field *jvmpi_fields;
 			JVMPI_Event ev;
 
+			retval = JVMPI_SUCCESS;
 			cl = (struct Hjava_lang_Class *)arg;
 			jvmpi_methods = alloca(sizeof(JVMPI_Method) *
 					       CLASS_NMETHODS(cl));
@@ -589,6 +640,7 @@
 			struct Hjava_lang_Thread *tid;
 			JVMPI_Event ev;
 
+			retval = JVMPI_SUCCESS;
 			tid = (struct Hjava_lang_Thread *)arg;
 			jvmpiFillThreadStart(&ev, tid);
 			ev.event_type |= JVMPI_REQUESTED_EVENT;
@@ -603,6 +655,7 @@
 			struct Hjava_lang_Object *obj;
 			JVMPI_Event ev;
 
+			retval = JVMPI_SUCCESS;
 			obj = (struct Hjava_lang_Object *)arg;
 			jvmpiFillObjectAlloc(&ev, obj);
 			ev.event_type |= JVMPI_REQUESTED_EVENT;
Index: kaffe/kaffe/jvmpi/jvmpi_kaffe.h
diff -u kaffe/kaffe/jvmpi/jvmpi_kaffe.h:1.3 kaffe/kaffe/jvmpi/jvmpi_kaffe.h:1.4
--- kaffe/kaffe/jvmpi/jvmpi_kaffe.h:1.3	Wed Jul  6 17:49:40 2005
+++ kaffe/kaffe/jvmpi/jvmpi_kaffe.h	Tue Jul 19 16:27:34 2005
@@ -22,14 +22,13 @@
 #include "lock-impl.h"
 #include "support.h"
 #include "code.h"
+#include "locks.h"
 
 /**
- * Implementation of a JVMPI_RawMonitor.  Just uses jmutex/jcondvar to do the
- * work.
+ * Implementation of a JVMPI_RawMonitor.  We use internal kaffe reentrant fast lock.
  */
 struct _JVMPI_RawMonitor {
-	jmutex mux;
-	jcondvar cv;
+        iStaticLock monitor;
 	char *lock_name;
 };
 
@@ -125,6 +124,14 @@
 void jvmpiFillThreadStart(JVMPI_Event *ev, struct Hjava_lang_Thread *tid);
 
 /**
+ * Free all requested memory by jvmpiFillThreadStart. This must be called after the
+ * event has been posted to the profiler.
+ *
+ * @param ev The event object to cleanup. 
+ */
+void jvmpiCleanupThreadStart(JVMPI_Event *ev);
+
+/**
  * Fill in a JVMPI_Event structure with the data for a JVMPI_EVENT_CLASS_LOAD
  * event.  Note:  The class_load.methods, class_load.statics, and
  * class_load.instances arrays must be allocated before calling this method.
@@ -133,6 +140,15 @@
  * @param obj The object to describe in the event.
  */
 void jvmpiFillClassLoad(JVMPI_Event *ev, struct Hjava_lang_Class *cl);
+
+/**
+ * Fill in a JVMPI_Event structure with the data for a JVMPI_EVENT_METHOD_LOAD
+ * event.
+ *
+ * @param ev The event data structure to be filled.
+ * @param meth The method which will be used for filling.
+ */
+void jvmpiFillMethodLoad(JVMPI_Event *ev, Method *meth);
 
 #else
 
Index: kaffe/kaffe/kaffe/main.c
diff -u kaffe/kaffe/kaffe/main.c:1.89 kaffe/kaffe/kaffe/main.c:1.90
--- kaffe/kaffe/kaffe/main.c:1.89	Wed Jul 13 13:31:12 2005
+++ kaffe/kaffe/kaffe/main.c	Tue Jul 19 16:27:34 2005
@@ -62,7 +62,6 @@
 JNIEnv* global_env;
 JavaVM* global_vm;
 static int isJar = 0;
-static char *jvm_onload;
 
 static int options(char**, int);
 static void usage(void);
@@ -179,46 +178,6 @@
 	/* Initialise */
 	JNI_CreateJavaVM(&global_vm, &global_env, &vmargs);
 
-	/* Handle the '-Xrun' argument. */
-	if( jvm_onload != NULL )
-	{
-		char *libpath, *libargs;
-		char errbuf[512];
-		int i;
-
-		/* XXX Pull findLibrary() from the JanosVM. */
-		libpath = &jvm_onload[2];
-		libpath[0] = 'l';
-		libpath[1] = 'i';
-		libpath[2] = 'b';
-
-		if( (libargs = strchr(jvm_onload, ':')) != NULL )
-		{
-			*libargs = '\0';
-			libargs += 1;
-		}

*** Patch too long, truncated ***




More information about the kaffe mailing list