This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: libjava test suite keeps getting stuck


On Mon, Apr 23, 2001 at 04:52:36PM -0700, Richard Henderson wrote:
> On Thu, Apr 19, 2001 at 10:41:25PM -0700, Zack Weinberg wrote:
> > __gxx_personality_v0 is another can of worms entirely.  It looks to be
> > referenced from all of the C++ source code.  It's deeply involved with
> > the new exception handling scheme.  I do not know whether it's
> > appropriate to keep using the C++ version or whether java should have
> > its own.
> 
> Java does have its own -- __gcj_personality_v0.
> 
> The problem at the moment is that the c++ front end uses the existance
> of a throw or a catch of a Java object to determine that we should be
> emulating Java exception handling in this module.  We really ought to
> be using a pragma instead so that it is (1) affirmative and (2) works
> with only cleanups present.

Hmm, like this?

With this pair of patches, I can build libgcj without linking
libsupc++.  (Mainline only.)  I still get a ton of libjava testsuite
failures, but I'm not sure if this tree is consistent.  Real test
results in slightly more than two hours.

jvm.h was the first header I found which was included by all the C++
files that needed to get hit by the pragma, and marked "implementation
internals"; there may be a better place.  I don't know where to
document the new pragma.

How is it that 'throw new <object>', which is all over the C++ code in
libjava, generates calls to _Jv_AllocObject not _Znwj?

zw

gcc/cp:
	* except.c (choose_personality_routine): Export.
	* cp-tree.h: Prototype choose_personality_routine.
	* lex.c (handle_pragma_java_exceptions): New function.
	(init_cp_pragma): Register #pragma GCC java_exceptions.

libjava:
	* Makefile.am (libgcj.la): Remove libsupc++convenience.la from
	link line.
	* Makefile.in: Regenerate (by hand).
	* include/jvm.h: Insert #pragma GCC java_exceptions here.
	* prims.cc (_Jv_ThisExecutable): Use _Jv_Malloc.
	* java/lang/natClassLoader.cc (_Jv_RegisterInitiatingLoader):
	Likewise.

===================================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h	2001/04/21 00:04:08	1.602
+++ gcc/cp/cp-tree.h	2001/04/24 02:37:13
@@ -4020,6 +4020,7 @@ extern tree build_throw				PARAMS ((tree
 extern void mark_all_runtime_matches            PARAMS ((void));
 extern int nothrow_libfn_p			PARAMS ((tree));
 extern void check_handlers			PARAMS ((tree));
+extern void choose_personality_routine		PARAMS ((bool));
 
 /* in expr.c */
 extern void init_cplus_expand			PARAMS ((void));
===================================================================
Index: gcc/cp/except.c
--- gcc/cp/except.c	2001/04/22 23:50:06	1.129
+++ gcc/cp/except.c	2001/04/24 02:37:14
@@ -43,7 +43,6 @@ static int dtor_nothrow PARAMS ((tree));
 static tree do_end_catch PARAMS ((tree));
 static void push_eh_cleanup PARAMS ((tree));
 static bool decl_is_java_type PARAMS ((tree decl, int err));
-static void choose_personality_routine PARAMS ((bool));
 static void initialize_handler_parm PARAMS ((tree, tree));
 static tree do_allocate_exception PARAMS ((tree));
 static int complete_ptr_ref_or_void_ptr_p PARAMS ((tree, tree));
@@ -259,7 +258,7 @@ decl_is_java_type (decl, err)
   return r;
 }
 
-static void
+void
 choose_personality_routine (is_java)
      bool is_java;
 {
===================================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c	2001/04/19 22:49:48	1.242
+++ gcc/cp/lex.c	2001/04/24 02:37:14
@@ -61,6 +61,7 @@ static void handle_pragma_vtable PARAMS 
 static void handle_pragma_unit PARAMS ((cpp_reader *));
 static void handle_pragma_interface PARAMS ((cpp_reader *));
 static void handle_pragma_implementation PARAMS ((cpp_reader *));
+static void handle_pragma_java_exceptions PARAMS ((cpp_reader *));
 static void cxx_init PARAMS ((void));
 static void cxx_finish PARAMS ((void));
 static void cxx_init_options PARAMS ((void));
@@ -680,6 +681,8 @@ init_cp_pragma ()
   cpp_register_pragma (parse_in, "GCC", "interface", handle_pragma_interface);
   cpp_register_pragma (parse_in, "GCC", "implementation",
 		       handle_pragma_implementation);
+  cpp_register_pragma (parse_in, "GCC", "java_exceptions",
+		       handle_pragma_java_exceptions);
 }
 
 const char *
@@ -1172,6 +1175,18 @@ handle_pragma_implementation (dfile)
       ifiles->next = impl_file_chain;
       impl_file_chain = ifiles;
     }
+}
+
+/* Indicate that this file uses Java-personality exception handling.  */
+static void
+handle_pragma_java_exceptions (dfile)
+     cpp_reader *dfile ATTRIBUTE_UNUSED;
+{
+  tree x;
+  if (c_lex (&x) != CPP_EOF)
+    warning ("junk at end of #pragma GCC java_exceptions");
+
+  choose_personality_routine (/* is_java = */ true);
 }
 
 void
===================================================================
Index: libjava/Makefile.am
--- libjava/Makefile.am	2001/04/22 03:05:37	1.139
+++ libjava/Makefile.am	2001/04/24 02:37:18
@@ -260,7 +260,6 @@ libgcj.la: $(libgcj_la_OBJECTS) $(libgcj
 	@echo $(libgcj_la_OBJECTS) > libgcj.objectlist;
 	@echo $(libgcj_la_LIBADD) >> libgcj.objectlist;
 	$(libgcj_la_LINK) -objectlist libgcj.objectlist \
-	../libstdc++-v3/libsupc++/libsupc++convenience.la \
 	../libffi/libfficonvenience.la \
 	-rpath $(toolexeclibdir) $(libgcj_la_LDFLAGS) $(LIBS)
 
===================================================================
Index: libjava/Makefile.in
--- libjava/Makefile.in	2001/04/22 03:05:37	1.149
+++ libjava/Makefile.in	2001/04/24 02:37:19
@@ -2362,7 +2362,6 @@ libgcj.la: $(libgcj_la_OBJECTS) $(libgcj
 	@echo $(libgcj_la_OBJECTS) > libgcj.objectlist;
 	@echo $(libgcj_la_LIBADD) >> libgcj.objectlist;
 	$(libgcj_la_LINK) -objectlist libgcj.objectlist \
-	../libstdc++-v3/libsupc++/libsupc++convenience.la \
 	../libffi/libfficonvenience.la \
 	-rpath $(toolexeclibdir) $(libgcj_la_LDFLAGS) $(LIBS)
 
===================================================================
Index: libjava/prims.cc
--- libjava/prims.cc	2001/03/26 07:05:31	1.49
+++ libjava/prims.cc	2001/04/24 02:37:21
@@ -609,7 +609,7 @@ _Jv_ThisExecutable (const char *name)
 {
   if (name)
     {
-      _Jv_execName = new char[strlen (name) + 1];
+      _Jv_execName = (char *) _Jv_Malloc (strlen (name) + 1);
       strcpy (_Jv_execName, name);
     }
 }
===================================================================
Index: libjava/include/jvm.h
--- libjava/include/jvm.h	2001/03/23 19:15:43	1.32
+++ libjava/include/jvm.h	2001/04/24 02:37:21
@@ -11,6 +11,9 @@ details.  */
 #ifndef __JAVA_JVM_H__
 #define __JAVA_JVM_H__
 
+// Force C++ compiler to use Java-style exceptions.
+#pragma GCC java_exceptions
+
 #include <gcj/javaprims.h>
 
 #include <java-assert.h>
===================================================================
Index: libjava/java/lang/natClassLoader.cc
--- libjava/java/lang/natClassLoader.cc	2001/03/26 07:05:32	1.30
+++ libjava/java/lang/natClassLoader.cc	2001/04/24 02:37:24
@@ -403,7 +403,8 @@ _Jv_UnregisterClass (jclass the_class)
 void
 _Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
 {
-  _Jv_LoaderInfo *info = new _Jv_LoaderInfo; // non-gc alloc!
+  // non-gc alloc!
+  _Jv_LoaderInfo *info = (_Jv_LoaderInfo *) _Jv_Malloc (sizeof(_Jv_LoaderInfo));
   jint hash = HASH_UTF(klass->name);
 
   _Jv_MonitorEnter (&ClassClass);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]