[kaffe] JIT3 on M68k Platform (Amiga/Linux)

Kiyo Inaba inaba@src.ricoh.co.jp
Sun Jun 1 00:50:01 2003


Hi,

--- Dalibor Topic <robilad@yahoo.com> wrote:
>--- Tony Wyatt <wyattaw@optushome.com.au> wrote:
>> Hi all,
>> 
>> I thought this little gem should be shared with other M68k owners. There was
>> only one big problem that made the JIT3 crash on the Amiga and native m68k
>> Linux on my machine, and this patch fixes it.
>
>thanks a lot for tracking down that one, I've checked it in.

I checked this mod with my patch attached, but still something is wrong.
Simple '$JAVA HelloWorldApp' does not output anything, and compiling
fails. I am wondering my gcc/glibc version is wrong, or linux version
specific...

I will check it next week more in detail.

Kiyo
-----------------------------------------------------------------------------
diff -Naur kaffe-snap-030515.orig/config/config-mem.h kaffe-snap-030515/config/config-mem.h
--- kaffe-snap-030515.orig/config/config-mem.h	Tue May  6 11:33:42 2003
+++ kaffe-snap-030515/config/config-mem.h	Sun Jun  1 13:32:22 2003
@@ -43,6 +43,9 @@
 #endif
 
 #if !defined(HAVE_DECLARED_SWAB)
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
 /* 
  * Some systems (Linux) do not declare swab in any standard header file
  */
diff -Naur kaffe-snap-030515.orig/config/config.h.in kaffe-snap-030515/config/config.h.in
--- kaffe-snap-030515.orig/config/config.h.in	Wed May 21 20:10:47 2003
+++ kaffe-snap-030515/config/config.h.in	Sun Jun  1 13:34:33 2003
@@ -289,6 +289,9 @@
 /* Define to 1 if you have the <netinet/tcp.h> header file. */
 #undef HAVE_NETINET_TCP_H
 
+/* Define to 1 if you have the <netpacket/packet.h> header file. */
+#undef HAVE_NETPACKET_PACKET_H
+
 /* Define to 1 if you have the `on_exit' function. */
 #undef HAVE_ON_EXIT
 
diff -Naur kaffe-snap-030515.orig/config/m68k/linux/config.frag kaffe-snap-030515/config/m68k/linux/config.frag
--- kaffe-snap-030515.orig/config/m68k/linux/config.frag	Sat Dec 18 14:09:34 1999
+++ kaffe-snap-030515/config/m68k/linux/config.frag	Sun Jun  1 13:35:07 2003
@@ -3,8 +3,8 @@
 #
 Khost_cpu=m68k
 Khost_os=linux
-CFLAGS="-g -fno-omit-frame-pointer"
-#CFLAGS="-g -O -fno-omit-frame-pointer"
+#CFLAGS="-g -fno-omit-frame-pointer"
+CFLAGS="-g -O -fno-omit-frame-pointer"
 if [ "$cross_compiling" = yes ]; then
 # if we use cross environment, following values may not be detected.
   ac_cv_alignmentof_voidp=${ac_cv_alignmentof_voidp='2'}
diff -Naur kaffe-snap-030515.orig/config/m68k/linux/jit3-md.h kaffe-snap-030515/config/m68k/linux/jit3-md.h
--- kaffe-snap-030515.orig/config/m68k/linux/jit3-md.h	Thu Jan  1 09:00:00 1970
+++ kaffe-snap-030515/config/m68k/linux/jit3-md.h	Sun Jun  1 15:54:20 2003
@@ -0,0 +1 @@
+#include "m68k/linux/jit-md.h"
diff -Naur kaffe-snap-030515.orig/configure kaffe-snap-030515/configure
--- kaffe-snap-030515.orig/configure	Wed May 21 20:18:20 2003
+++ kaffe-snap-030515/configure	Sun Jun  1 13:33:43 2003
@@ -23914,6 +23914,7 @@
 netinet/in.h \
 netinet/in_systm.h \
 netinet/tcp.h \
+netpacket/packet.h \
 png.h \
 poll.h \
 pwd.h \
diff -Naur kaffe-snap-030515.orig/configure.in kaffe-snap-030515/configure.in
--- kaffe-snap-030515.orig/configure.in	Wed May 21 20:18:22 2003
+++ kaffe-snap-030515/configure.in	Sun Jun  1 13:34:02 2003
@@ -741,6 +741,7 @@
 netinet/in.h \
 netinet/in_systm.h \
 netinet/tcp.h \
+netpacket/packet.h \
 png.h \
 poll.h \
 pwd.h \
diff -Naur kaffe-snap-030515.orig/kaffe/kaffevm/stringParsing.c kaffe-snap-030515/kaffe/kaffevm/stringParsing.c
--- kaffe-snap-030515.orig/kaffe/kaffevm/stringParsing.c	Sat Apr 26 06:35:34 2003
+++ kaffe-snap-030515/kaffe/kaffevm/stringParsing.c	Sat May 31 17:19:34 2003
@@ -822,10 +822,14 @@
 	parseErrorInfo pe;
 	parsedString ps;
 	int retval;
+	va_list * args;
+
+	args = KCALLOC(1, sizeof(args));
 
 	ps.data = str;
 	ps.len = strlen(str);
-	retval = parseString_private(&pe, &ps, ss, values, SPO_Noop, NULL);
+	retval = parseString_private(&pe, &ps, ss, values, SPO_Noop, *args);
+	KFREE(args);
 	return( retval );
 }
 
@@ -838,541 +842,5 @@
 		strncpy(retval, ps->data, ps->len);
 		retval[ps->len] = '\0';
 	}
-	return( retval );
-}
-
-static
-char *test1Strings[] = {
-	"[team:0x1:create]",
-	"[a:0x100:b]",
-	"[team:0x1:create",
-	"[team:1:create",
-	"[team:0x1:create]baddata",
-	"[]",
-	"[:]",
-	"[::]",
-	"[a:b:c]",
-	0
-};
-
-static
-parsedString test1Substrings[] = {
-	{ "[team:0x1:create] ** This is junk ** " },
-	{ "[a:0x100:b] ** This is junk ** " },
-	{ "[team:0x1:create ** This is junk ** " },
-	{ "[team:1:create ** This is junk ** " },
-	{ "[team:0x1:create]baddata ** This is junk ** " },
-	{ "[] ** This is junk ** " },
-	{ "[:] ** This is junk ** " },
-	{ "[::] ** This is junk ** " },
-	{ "[a:b:c] ** This is junk ** " },
-	{ 0 }
-};
-
-static
-struct {
-	int result;
-	parsedString name;
-	int commands;
-	parsedString usage;
-} test1Results[] = {
-	{
-		1,
-		{ "team:0x1:create]", 4 },
-		0x1,
-		{ "create]", 6 }
-	},
-	{
-		1,
-		{ "a:0x100:b]", 1 },
-		0x100,
-		{ "b]", 1 }
-	},
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } }
-};
-
-static
-struct {
-	int result;
-	parsedString name;
-	int commands;
-	parsedString usage;
-} test1SubResults[] = {
-	{
-		1,
-		{ "team:0x1:create] ** This is junk ** ", 4 },
-		0x1,
-		{ "create] ** This is junk ** ", 6 }
-	},
-	{
-		1,
-		{ "a:0x100:b] ** This is junk ** ", 1 },
-		0x100,
-		{ "b] ** This is junk ** ", 1 }
-	},
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } },
-	{ 0, { 0, 0 }, 0, { 0, 0 } }
-};
-
-static
-stringScript test1Commands[] = {
-	{ SPO_Expect, { "[" } },
-	{ SPO_String },
-	{ SPO_Expect, { ":" } },
-	{ SPO_Integer },
-	{ SPO_Expect, { ":" } },
-	{ SPO_String },
-	{ SPO_Expect, { "]" } },
-	{ SPO_End },
-};
-
-static
-int test1(void)
-{
-	int lpc, result, commands, retval = 1;
-	parsedString name, usage;
-
-	for( lpc = 0; test1Strings[lpc]; lpc++ )
-	{
-		result = parseString(test1Strings[lpc],
-				     SPO_Expect, "[",
-				     SPO_String, &name,
-				     SPO_Expect, ":",
-				     SPO_Integer, &commands,
-				     SPO_Expect, ":",
-				     SPO_String, &usage,
-				     SPO_Expect, "]",
-				     SPO_End);
-		if( (test1Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test1Results[lpc].name.data, name.data) &&
-		      (test1Results[lpc].name.len == name.len) &&
-		      (test1Results[lpc].commands == commands) &&
-		      !strcmp(test1Results[lpc].usage.data, usage.data) &&
-		      (test1Results[lpc].usage.len == usage.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test1Strings[lpc]);
-			retval = 0;
-		}
-	}
-	
-	for( lpc = 0; test1Strings[lpc]; lpc++ )
-	{
-		result = parseString_script(test1Strings[lpc],
-					    test1Commands,
-					    &name,
-					    &commands,
-					    &usage);
-		if( (test1Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test1Results[lpc].name.data, name.data) &&
-		      (test1Results[lpc].name.len == name.len) &&
-		      (test1Results[lpc].commands == commands) &&
-		      !strcmp(test1Results[lpc].usage.data, usage.data) &&
-		      (test1Results[lpc].usage.len == usage.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test1Strings[lpc]);
-			retval = 0;
-		}
-	}
-	
-	for( lpc = 0; test1Strings[lpc]; lpc++ )
-	{
-		void *values[] = {
-			&name,
-			&commands,
-			&usage
-		};
-		
-		result = parseString_script_values(test1Strings[lpc],
-						   test1Commands,
-						   values);
-		if( (test1Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test1Results[lpc].name.data, name.data) &&
-		      (test1Results[lpc].name.len == name.len) &&
-		      (test1Results[lpc].commands == commands) &&
-		      !strcmp(test1Results[lpc].usage.data, usage.data) &&
-		      (test1Results[lpc].usage.len == usage.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test1Strings[lpc]);
-			retval = 0;
-		}
-	}
-	
-	for( lpc = 0; test1Substrings[lpc].data; lpc++ )
-	{
-		test1Substrings[lpc].len = strlen(test1Strings[lpc]);
-		result = parseSubString(&test1Substrings[lpc],
-					SPO_Expect, "[",
-					SPO_String, &name,
-					SPO_Expect, ":",
-					SPO_Integer, &commands,
-					SPO_Expect, ":",
-					SPO_String, &usage,
-					SPO_Expect, "]",
-					SPO_End);
-		if( (test1SubResults[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test1SubResults[lpc].name.data, name.data) &&
-		      (test1SubResults[lpc].name.len == name.len) &&
-		      (test1SubResults[lpc].commands == commands) &&
-		      !strcmp(test1SubResults[lpc].usage.data, usage.data) &&
-		      (test1SubResults[lpc].usage.len == usage.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test1Substrings[lpc].data);
-			retval = 0;
-		}
-	}
-	return( retval );
-}
-
-static
-char *test2Strings[] = {
-	".:../Klasses.jar",
-	".",
-	":",
-	".:",
-	0
-};
-
-struct test2Parse {
-	int lpc;
-	int event;
-	parsedString cpath;
-};
-
-static
-struct {
-	int result;
-} test2Results[] = {
-	{ 1 },
-	{ 1 },
-	{ 0 },
-	{ 0 }
-};
-
-static
-parsedString test2ParseValues[] = {
-	{ ".:../Klasses.jar", 1 },
-	{ "../Klasses.jar", 14 },
-	{ ".", 1 },
-	{ ":", 0 },
-	{ "", 0 },
-	{ ".:", 1 },
-	{ "", 0 }
-};
-
-static
-struct {
-	parsedString *values;
-} test2HandledValues[] = {
-	{ &test2ParseValues[0] },
-	{ &test2ParseValues[2] },
-	{ &test2ParseValues[3] },
-	{ &test2ParseValues[5] }
-};
-
-static
-int test2Handler(struct test2Parse *tp)
-{
-	int retval = 0;
-	
-	if( !strcmp(tp->cpath.data,
-		    test2HandledValues[tp->lpc].values[tp->event].data) &&
-	    (tp->cpath.len ==
-	     test2HandledValues[tp->lpc].values[tp->event].len) )
-	{
-		retval = 1;
-	}
-	tp->event++;
-	return( retval );
-}
-
-static
-int test2(void)
-{
-	int result, lpc, retval = 1;
-	struct test2Parse tp;
-
-	for( lpc = 0; test2Strings[lpc]; lpc++ )
-	{
-		tp.lpc = lpc;
-		tp.event = 0;
-		result = parseString(test2Strings[lpc],
-				     SPO_NotEmpty,
-				       SPO_Do,
-				         SPO_NonEmptyString, &tp.cpath,
-				         SPO_While, ":", "",
-				         SPO_Handle, test2Handler, &tp,
-				         SPO_End,
-				       SPO_End,
-				     SPO_End);
-		if( test2Results[lpc].result == result )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test2Strings[lpc]);
-			retval = 0;
-		}
-	}
-	return( retval );
-}
-
-static
-char *test3Strings[] = {
-	"stack.tim@irontown",
-	"stack.tim",
-	"stack",
-	"stack@irontown",
-	"stack@irontown.cs.utah.edu",
-	0
-};
-
-struct {
-	int result;
-	parsedString name;
-	parsedString instance;
-	parsedString realm;
-} test3Results[] = {
-	{ 1, { "stack.tim@irontown", 5 }, { "tim@irontown", 3 }, { "irontown", 8 } },
-	{ 1, { "stack.tim", 5 }, { "tim", 3 }, { "irontown", 8 } },
-	{ 1, { "stack", 5 }, { "", 0 }, { "irontown", 8 } },
-	{ 1, { "stack@irontown", 5 }, { "", 0, }, { "irontown", 8 } },
-	{ 1, { "stack@irontown.cs.utah.edu", 5 }, { "", 0 }, { "irontown.cs.utah.edu", 20 } }
-};
-
-static
-int test3(void)
-{
-	parsedString name, instance, realm;
-	int result, lpc, retval = 1;
-
-	for( lpc = 0; test3Strings[lpc]; lpc++ )
-	{
-		instance.data = "";
-		instance.len = 0;
-		realm.data = "irontown";
-		realm.len = 8;
-		result = parseString(test3Strings[lpc],
-				     SPO_String, &name,
-				     SPO_OneOf, ".@",
-				       SPO_Cond, ".",
-				         SPO_String, &instance,
-				         SPO_End,
-				       SPO_Cond, "@",
-				         SPO_String, &realm,
-				         SPO_End,
-				       SPO_End,
-				     SPO_End);
-		if( (test3Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test3Results[lpc].name.data, name.data) &&
-		      (test3Results[lpc].name.len == name.len) &&
-		      !strcmp(test3Results[lpc].instance.data, instance.data) &&
-		      (test3Results[lpc].instance.len == instance.len) &&
-		      !strcmp(test3Results[lpc].realm.data, realm.data) &&
-		      (test3Results[lpc].realm.len == realm.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test3Strings[lpc]);
-			retval = 0;
-		}
-	}
-	return( retval );
-}
-
-static
-char *test4Strings[] = {
-	"tcp:localhost/14000",
-	"localhost/14000",
-	0
-};
-
-static
-struct {
-	int result;
-	parsedString protocol;
-	parsedString host;
-	int port;
-} test4Results[] = {
-	{ 1, { "tcp:localhost/14000", 3 }, { "localhost/14000", 9 }, 14000 },
-	{ 1, { "tcp", 3 }, { "localhost/14000", 9 }, 14000 }
-};
-
-static
-int test4(void)
-{
-	int result, lpc, port, retval = 1;
-	parsedString protocol, host;
-
-	for( lpc = 0; test4Strings[lpc]; lpc++ )
-	{
-		protocol.data = "tcp";
-		protocol.len = 3;
-		result = parseString(test4Strings[lpc],
-				     SPO_NonEmptyString, &protocol,
-				     SPO_Cond, ":",
-				       SPO_End,
-				     SPO_NonEmptyString, &host,
-				     SPO_Expect, "/",
-				     SPO_Integer, &port,
-				     SPO_End);
-		if( (test4Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test4Results[lpc].protocol.data, protocol.data) &&
-		      (test4Results[lpc].protocol.len == protocol.len) &&
-		      !strcmp(test4Results[lpc].host.data, host.data) &&
-		      (test4Results[lpc].host.len == host.len) &&
-		      (test4Results[lpc].port == port))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test4Strings[lpc]);
-			retval = 0;
-		}
-	}
-	return( retval );
-}
-
-static
-char *test5Strings[] = {
-	"arg1",
-	"arg1 arg2",
-	"arg1 arg2 arg3",
-	0
-};
-
-static
-int test5Handler(parsedString *ps)
-{
-	int retval = 1;
-
-	return( retval );
-}
-
-static
-int test5(void)
-{
-	int lpc, retval = 1;
-	parsedString arg;
-	
-	for( lpc = 0; test5Strings[lpc]; lpc++ )
-	{
-		parseString(test5Strings[lpc],
-			    SPO_Do,
-			      SPO_NonEmptyString, &arg,
-			      SPO_WhileSpace,
-			      SPO_Handle, test5Handler, &arg,
-			      SPO_End,
-			    SPO_End);
-	}
-	return( retval );
-}
-
-static
-char *test6Strings[] = {
-	"irontown:/z/stack/jinstall/Image",
-	"irontown:/Image",
-	"irontown:/Image/",
-	0
-};
-
-static
-struct {
-	int result;
-	parsedString host;
-	parsedString dir;
-	parsedString file;
-} test6Results[] = {
-	{ 1,
-	  { "irontown:/z/stack/jinstall/Image", 8 },
-	  { "/z/stack/jinstall/Image", 17 },
-	  { "Image", 5 } },
-	{ 1,
-	  { "irontown:/Image", 8 },
-	  { "/Image", 0 },
-	  { "Image", 5 } },
-	{ 1,
-	  { "irontown:/Image/", 8 },
-	  { "/Image/", 6 },
-	  { "", 0 } },
-};
-
-static
-int test6(void)
-{
-	parsedString host, dir, file;
-	int result, lpc, retval = 1;
-
-	for( lpc = 0; test6Strings[lpc]; lpc++ )
-	{
-		result = parseString(test6Strings[lpc],
-				     SPO_NotEmpty,
-				       SPO_String, &host,
-				       SPO_Expect, ":",
-				       SPO_String, &dir,
-				       SPO_Do,
-				         SPO_String, &file,
-				         SPO_While, "/", "",
-				         SPO_End,
-				       SPO_End,
-				     SPO_End);
-		if( (test6Results[lpc].result == result) &&
-		    (!result ||
-		     (!strcmp(test6Results[lpc].host.data, host.data) &&
-		      (test6Results[lpc].host.len == host.len) &&
-		      !strcmp(test6Results[lpc].dir.data, dir.data) &&
-		      (test6Results[lpc].dir.len == dir.len) &&
-		      !strcmp(test6Results[lpc].file.data, file.data) &&
-		      (test6Results[lpc].file.len == file.len))) )
-		{
-		}
-		else
-		{
-			printf("Failure on %s\n", test6Strings[lpc]);
-			retval = 0;
-		}
-	}
-	return( retval );
-}
-
-int testStringParsingModule(void)
-{
-	int retval;
-
-	retval = test1() &&
-		test2() &&
-		test3() &&
-		test4() &&
-		test5() &&
-		test6();
 	return( retval );
 }
diff -Naur kaffe-snap-030515.orig/kaffe/kaffevm/support.c kaffe-snap-030515/kaffe/kaffevm/support.c
--- kaffe-snap-030515.orig/kaffe/kaffevm/support.c	Tue May  6 11:34:59 2003
+++ kaffe-snap-030515/kaffe/kaffevm/support.c	Sun Jun  1 14:10:59 2003
@@ -816,6 +816,8 @@
 	call.ret = ret;
 
 #if defined(TRANSLATOR)
+	assert((func == (METHOD_NATIVECODE(meth)))
+	       || (func == (((Hjava_lang_Object*)obj)->dtable->method[meth->idx])));
 	call.function = func;
 
 	/* GCDIAG wipes free memory with 0xf4... */
diff -Naur kaffe-snap-030515.orig/replace/getifaddrs.c kaffe-snap-030515/replace/getifaddrs.c
--- kaffe-snap-030515.orig/replace/getifaddrs.c	Fri Feb 21 18:51:11 2003
+++ kaffe-snap-030515/replace/getifaddrs.c	Sun Jun  1 13:32:53 2003
@@ -17,7 +17,7 @@
 
 #if defined(HAVE_GETIFADDRS)
 
-#elif defined(linux)
+#elif defined(linux) && defined(HAVE_NETPACKET_PACKET_H)
 
 #if !defined(__set_errno)
 #define __set_errno(x) errno = x