]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2003-01-31 Andrew Haley <aph@redhat.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2003 17:27:56 +0000 (17:27 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2003 17:27:56 +0000 (17:27 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70605 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/except.c
libjava/ChangeLog
libjava/exception.cc
libjava/gnu/gcj/runtime/StackTrace.java
libjava/gnu/gcj/runtime/natStackTrace.cc

index 9ad41a658ba347e8530699a1fb87d7b775ac94d1..6aeff65ea259461684177c6708c075a503dbef16 100644 (file)
@@ -324,10 +324,36 @@ prepare_eh_table_type (tree type)
   else if (is_compiled_class (type))
     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));
+    {
+      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 99c2229343b4e0fbeaa5b0b0e54a66f56e8df280..892e2c148ca429d979c547dcfd99173a2845b5da 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2003-08-20  Tom Tromey  <tromey@redhat.com>
 
        Fix for PR libgcj/9125:
index d983f98f8faaaaff3cb9d269c3f78de990caf1fd..9647d446d18ecdf24ae0ad3c7c926635c3cfdbf8 100644 (file)
@@ -15,6 +15,9 @@ details.  */
 
 #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>
 
@@ -335,11 +338,21 @@ PERSONALITY_FUNCTION (int version,
 
              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);
-
+             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))
                {
                  handler_switch_value = ar_filter;
index 5faaa1495ae0c9aef8a86dbb0e4de1287b8d590f..684ee4fd9974d1f861c6ec9b3bcfe9e1bfc12a35 100644 (file)
@@ -139,6 +139,8 @@ public final class StackTrace
     return len;
   }
 
+  public static native Class getClass(RawData ip);
+
   private static native void update();
   private static MethodRef methodAtAddress(RawData addr)
   {
index d39cd00dbababac8c6f5cc3bc82d5fb313ad3e7d..af8889beb5262f6556c082d1aeea31591dc14d98 100644 (file)
@@ -123,6 +123,16 @@ gnu::gcj::runtime::StackTrace::getCompiledMethodRef (gnu::gcj::RawData *addr)
     ::methodAtAddress ((gnu::gcj::RawData *)p);
 }
 
+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)
 {
@@ -137,12 +147,7 @@ gnu::gcj::runtime::StackTrace::classAt (jint n)
     }
 #endif // INTERPRETER
   
-  gnu::gcj::runtime::MethodRef *ref 
-    = getCompiledMethodRef ((gnu::gcj::RawData *)frame->addr);
-  if (ref)
-    return ref->klass;
-  else
-    return NULL;
+  return getClass ((gnu::gcj::RawData *)frame->addr);
 }
 
 java::lang::String*