2003-01-31  Andrew Haley  <aph@redhat.com>

	* except.c (prepare_eh_table_type): Use new encoding for exception
	handlers when using -fno-assume-compiled.
 
Index: libjava/exception.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/exception.cc,v
retrieving revision 1.22
diff -c -2 -p -r1.22 exception.cc
*** libjava/exception.cc	23 Dec 2002 19:59:30 -0000	1.22
--- libjava/exception.cc	21 Jan 2003 17:53:25 -0000
*************** details.  */
*** 16,19 ****
--- 16,22 ----
  #include <java/lang/Class.h>
  #include <java/lang/NullPointerException.h>
+ #include <gnu/gcj/runtime/StackTrace.h> 
+ #include <gnu/gcj/runtime/MethodRef.h> 
+ #include <gnu/gcj/RawData.h> 
  #include <gcj/cni.h>
  #include <jvm.h>
*************** PERSONALITY_FUNCTION (int version,
*** 336,344 ****
  	      jclass catch_type = get_ttype_entry (context, &info, ar_filter);
  
! 	      // The catch_type is either a (java::lang::Class*) or
! 	      // is one more than a (Utf8Const*).
! 	      if ((size_t)catch_type & 1)
! 		catch_type = _Jv_FindClass ((Utf8Const*)((size_t)catch_type ^ 1), NULL);
! 
  	      if (_Jv_IsInstanceOf (xh->value, catch_type))
  		{
--- 339,357 ----
  	      jclass catch_type = get_ttype_entry (context, &info, ar_filter);
  
! 	      typedef struct {
! 		int __attribute__ ((mode (pointer))) dummy; 
! 		Utf8Const *utf8;
! 	      } utf8_hdr;
! 	      utf8_hdr *p = (utf8_hdr *)catch_type;
! 	      if (p->dummy == -1)
! 		{
! 		  using namespace gnu::gcj::runtime;
! 		  java::lang::Class *klass 
! 		    = StackTrace::getClass ((gnu::gcj::RawData *)ip);
! 		  java::lang::ClassLoader *loader 
! 		    = klass ? klass->getClassLoaderInternal () : NULL;
! 		  catch_type = _Jv_FindClass (p->utf8, loader);
! 		}
! 	      
  	      if (_Jv_IsInstanceOf (xh->value, catch_type))
  		{
Index: gcc/java/except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/except.c,v
retrieving revision 1.38
diff -p -2 -c -r1.38 except.c
*** gcc/java/except.c	6 Feb 2003 19:01:24 -0000	1.38
--- gcc/java/except.c	28 Mar 2003 18:51:44 -0000
*************** prepare_eh_table_type (tree type)
*** 325,332 ****
      exp = build_class_ref (type);
    else
!     exp = fold (build 
! 		(PLUS_EXPR, ptr_type_node,
! 		 build_utf8_ref (DECL_NAME (TYPE_NAME (type))),
! 		 size_one_node));
    return exp;
  }
--- 325,358 ----
      exp = build_class_ref (type);
    else
!     {
!       tree ctype = make_node (RECORD_TYPE);
!       tree field = NULL_TREE;
!       tree cinit, decl;
!       tree utf8_ref = build_utf8_ref (DECL_NAME (TYPE_NAME (type)));
!       char buf[64];
!       sprintf (buf, "%s_ref", 
! 	       IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (utf8_ref, 0))));
!       PUSH_FIELD (ctype, field, "dummy", ptr_type_node);
!       PUSH_FIELD (ctype, field, "utf8",  utf8const_ptr_type);
!       FINISH_RECORD (ctype);
!       START_RECORD_CONSTRUCTOR (cinit, ctype);
!       PUSH_FIELD_VALUE (cinit, "dummy", 
! 			convert (ptr_type_node, integer_minus_one_node));
!       PUSH_FIELD_VALUE (cinit, "utf8", utf8_ref);
!       FINISH_RECORD_CONSTRUCTOR (cinit);
!       TREE_CONSTANT (cinit) = 1;
!       decl = build_decl (VAR_DECL, get_identifier (buf), ctype);
!       TREE_STATIC (decl) = 1;
!       DECL_ARTIFICIAL (decl) = 1;
!       DECL_IGNORED_P (decl) = 1;
!       TREE_READONLY (decl) = 1;
!       TREE_THIS_VOLATILE (decl) = 0;
!       DECL_INITIAL (decl) = cinit;
!       layout_decl (decl, 0);
!       pushdecl (decl);
!       rest_of_decl_compilation (decl, (char*) 0, global_bindings_p (), 0);
!       make_decl_rtl (decl, (char*) 0);
!       exp = build1 (ADDR_EXPR, build_pointer_type (ctype), decl);
!     }
    return exp;
  }
Index: libjava/gnu/gcj/runtime/StackTrace.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/StackTrace.java,v
retrieving revision 1.1
diff -c -2 -p -r1.1 StackTrace.java
*** libjava/gnu/gcj/runtime/StackTrace.java	3 Dec 2002 13:53:27 -0000	1.1
--- libjava/gnu/gcj/runtime/StackTrace.java	21 Jan 2003 17:53:26 -0000
*************** public final class StackTrace
*** 140,143 ****
--- 140,145 ----
    }
  
+   public static native Class getClass(RawData ip);
+ 
    private static native void update();
    private static MethodRef methodAtAddress(RawData addr)
Index: libjava/gnu/gcj/runtime/natStackTrace.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/natStackTrace.cc,v
retrieving revision 1.2
diff -c -2 -p -r1.2 natStackTrace.cc
*** libjava/gnu/gcj/runtime/natStackTrace.cc	5 Dec 2002 11:35:11 -0000	1.2
--- libjava/gnu/gcj/runtime/natStackTrace.cc	21 Jan 2003 17:53:26 -0000
*************** gnu::gcj::runtime::StackTrace::getCompil
*** 124,127 ****
--- 124,137 ----
  
  java::lang::Class *
+ gnu::gcj::runtime::StackTrace::getClass (gnu::gcj::RawData *p)
+ {
+   gnu::gcj::runtime::MethodRef *ref = getCompiledMethodRef (p);
+   if (ref)
+     return ref->klass;
+   else
+     return NULL;
+ }
+ 
+ java::lang::Class *
  gnu::gcj::runtime::StackTrace::classAt (jint n)
  {
*************** gnu::gcj::runtime::StackTrace::classAt (
*** 137,146 ****
  #endif // INTERPRETER
    
!   gnu::gcj::runtime::MethodRef *ref 
!     = getCompiledMethodRef ((gnu::gcj::RawData *)frame->addr);
!   if (ref)
!     return ref->klass;
!   else
!     return NULL;
  }
  
--- 147,151 ----
  #endif // INTERPRETER
    
!   return getClass ((gnu::gcj::RawData *)frame->addr);
  }
