This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

gcj: new encoding


As part of the new gcj ABI, we have a new encoding for classes when
catching exceptions.  This also makes sure that we use the correct
class loader to look up a type when matching an exception region.

Andrew.

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.
 
2003-08-20  Andrew Haley  <aph@redhat.com>

	* gnu/gcj/runtime/StackTrace.java (getClass): New method.
	* gnu/gcj/runtime/natStackTrace.cc (getClass): New method.
	(classAt): Break out class lookup function into getClass().
	* exception.cc (PERSONALITY_FUNCTION): Use new encoding for exception
	handlers when using -fno-assume-compiled.

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	20 Aug 2003 16:55:02 -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/exception.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/exception.cc,v
retrieving revision 1.22
diff -p -2 -c -r1.22 exception.cc
*** libjava/exception.cc	23 Dec 2002 19:59:30 -0000	1.22
--- libjava/exception.cc	20 Aug 2003 16:55:02 -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: libjava/gnu/gcj/runtime/StackTrace.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/StackTrace.java,v
retrieving revision 1.1
diff -p -2 -c -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	20 Aug 2003 16:55:02 -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.4
diff -p -2 -c -r1.4 natStackTrace.cc
*** libjava/gnu/gcj/runtime/natStackTrace.cc	19 Feb 2003 16:28:36 -0000	1.4
--- libjava/gnu/gcj/runtime/natStackTrace.cc	20 Aug 2003 16:55:02 -0000
*************** gnu::gcj::runtime::StackTrace::getCompil
*** 125,128 ****
--- 125,138 ----
  
  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 (
*** 138,147 ****
  #endif // INTERPRETER
    
!   gnu::gcj::runtime::MethodRef *ref 
!     = getCompiledMethodRef ((gnu::gcj::RawData *)frame->addr);
!   if (ref)
!     return ref->klass;
!   else
!     return NULL;
  }
  
--- 148,152 ----
  #endif // INTERPRETER
    
!   return getClass ((gnu::gcj::RawData *)frame->addr);
  }
  


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