jvm.h (_Jv_VTable): Handle function descriptors for ia64...
authorRichard Henderson <rth@gcc.gnu.org>
Fri, 21 Sep 2001 16:59:12 +0000 (09:59 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 21 Sep 2001 16:59:12 +0000 (09:59 -0700)
        * include/jvm.h (_Jv_VTable): Handle function descriptors for ia64;
        add get_method, set_method, vtable_elt_size, new_vtable.
        (_Jv_ArrayVTable): Derive from _Jv_VTable.
        * resolve.cc (_Jv_PrepareClass): Use new _Jv_VTable methods.
        * interpret.cc (_Jv_InterpMethod::continue1): Likewise.
        * java/lang/natClassLoader.cc (_Jv_NewArrayClass): Likewise.

From-SVN: r45734

libjava/ChangeLog
libjava/include/jvm.h
libjava/interpret.cc
libjava/java/lang/natClassLoader.cc
libjava/resolve.cc

index 8981ace8a8cd7884c0d2d19885c456beddefded6..fe52c144b515118f723924ea5978ac0ea800734b 100644 (file)
@@ -1,3 +1,12 @@
+2001-09-21  Richard Henderson  <rth@redhat.com>
+
+       * include/jvm.h (_Jv_VTable): Handle function descriptors for ia64;
+       add get_method, set_method, vtable_elt_size, new_vtable.
+       (_Jv_ArrayVTable): Derive from _Jv_VTable.
+       * resolve.cc (_Jv_PrepareClass): Use new _Jv_VTable methods.
+       * interpret.cc (_Jv_InterpMethod::continue1): Likewise.
+       * java/lang/natClassLoader.cc (_Jv_NewArrayClass): Likewise.
+
 2001-09-21  Richard Henderson  <rth@redhat.com>
 
        * no-threads.cc (_Jv_ThreadStart): Remove names of unused arguments.
 
 2001-09-05  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 
-        * java/text/MessageFormat.java (setLocale): Don't catch ParseException
-        here, DecimalFormat.applyPattern() does not throw it.
+       * java/text/MessageFormat.java (setLocale): Don't catch ParseException
+       here, DecimalFormat.applyPattern() does not throw it.
 
 2001-09-04  Tom Tromey  <tromey@redhat.com>
 
 
 2001-08-21  Anthony Green  <green@redhat.com>
 
-        * java/lang/natClassLoader.cc (findClass): Search for
-        lib-gnu-pkg-quux.so, not gnu-pkg-quux.so.
+       * java/lang/natClassLoader.cc (findClass): Search for
+       lib-gnu-pkg-quux.so, not gnu-pkg-quux.so.
 
 2001-08-21  Jeff Sturm  <jsturm@one-point.com>
 
 
 2001-05-29  Andrew Haley  <aph@redhat.com>
 
-        * include/i386-signal.h (MAKE_THROW_FRAME): Don't fix up frame
-        pointer: the dwarf unwinder in libgcc will do everything that's
-        needed.
-        (HANDLE_DIVIDE_OVERFLOW): Tidy.  Don't mess with stack frames any
-        more than we absolutely need to.
-        * configure.host (EXCEPTIONSPEC): Remove libgcj_sjlj on Alpha.
-        * configure.in (SIGNAL_HANDLER): Use include/dwarf2-signal.h on
-        Alpha.
-        (SIGNAL_HANDLER): Test "$enable_sjlj_exceptions", not
-        "$libgcj_sjlj".
-        * configure: Rebuilt.
-        * include/dwarf2-signal.h (MAKE_THROW_FRAME): Adjust PC
-        for Alpha.
-        (SIGNAL_HANDLER): Use siginfo style handler.
-        (INIT_SEGV): Likewise.
-        (INIT_FPE): Likewise.
-        * include/ppc-signal.h: Delete whole file.
+       * include/i386-signal.h (MAKE_THROW_FRAME): Don't fix up frame
+       pointer: the dwarf unwinder in libgcc will do everything that's
+       needed.
+       (HANDLE_DIVIDE_OVERFLOW): Tidy.  Don't mess with stack frames any
+       more than we absolutely need to.
+       * configure.host (EXCEPTIONSPEC): Remove libgcj_sjlj on Alpha.
+       * configure.in (SIGNAL_HANDLER): Use include/dwarf2-signal.h on
+       Alpha.
+       (SIGNAL_HANDLER): Test "$enable_sjlj_exceptions", not
+       "$libgcj_sjlj".
+       * configure: Rebuilt.
+       * include/dwarf2-signal.h (MAKE_THROW_FRAME): Adjust PC
+       for Alpha.
+       (SIGNAL_HANDLER): Use siginfo style handler.
+       (INIT_SEGV): Likewise.
+       (INIT_FPE): Likewise.
+       * include/ppc-signal.h: Delete whole file.
 
 2001-05-24  Tom Tromey  <tromey@redhat.com>
 
        * include/dwarf2-signal.h: New file.
        * configure.in (SYSDEP_SOURCES): Add dwarf2-signal.h for PPC.
        * configure.host (EXCEPTIONSPEC): Don't use sjlj on PPC.
-        * configure: Rebuilt.
+       * configure: Rebuilt.
 
 2001-05-21  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 
 
 2001-05-11  Richard Henderson  <rth@redhat.com>
 
-        * exception.cc: Include unwind-pe.h.  Remove all pointer
+       * exception.cc: Include unwind-pe.h.  Remove all pointer
        encoding logic.
 
 2001-05-10  Tom Tromey  <tromey@redhat.com>
index 936d4c690c617103978ab255a52030268fbebe6a..957869ee581c9c81a152a5193db3b8264d92f37e 100644 (file)
@@ -27,10 +27,35 @@ details.  */
 /* Structure of the virtual table.  */
 struct _Jv_VTable
 {
+#ifdef __ia64__
   jclass clas;
+  unsigned long : 64;
   void *gc_descr;
-  void *method[1];
-  void *get_finalizer() { return method[0]; }
+  unsigned long : 64;
+
+  typedef struct { void *pc, *gp; } vtable_elt;
+#else
+  jclass clas;
+  void *gc_descr;
+
+  typedef void *vtable_elt;
+#endif
+
+  // This must be last, as derived classes "extend" this by
+  // adding new data members.
+  vtable_elt method[1];
+
+#ifdef __ia64__
+  void *get_method(int i) { return &method[i]; }
+  void set_method(int i, void *fptr) { method[i] = *(vtable_elt *)fptr; }
+#else
+  void *get_method(int i) { return method[i]; }
+  void set_method(int i, void *fptr) { method[i] = fptr; }
+#endif
+
+  void *get_finalizer() { return get_method(0); }
+  static size_t vtable_elt_size() { return sizeof(vtable_elt); }
+  static _Jv_VTable *new_vtable (int count);
 };
 
 // Number of virtual methods on object.  FIXME: it sucks that we have
@@ -38,12 +63,9 @@ struct _Jv_VTable
 #define NUM_OBJECT_METHODS 5
 
 // This structure is the type of an array's vtable.
-struct _Jv_ArrayVTable
+struct _Jv_ArrayVTable : public _Jv_VTable
 {
-  jclass clas;
-  void *gc_descr;
-  void *method[NUM_OBJECT_METHODS];
-  void *get_finalizer() { return method[0]; }
+  vtable_elt extra_method[NUM_OBJECT_METHODS - 1];
 };
 
 union _Jv_word
@@ -172,6 +194,18 @@ extern "C" void JvRunMain (jclass klass, int argc, const char **argv);
 void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv, 
                  bool is_jar);
 
+// Delayed until after _Jv_AllocBytes is declared.
+//
+// Note that we allocate this as unscanned memory -- the vtables
+// are handled specially by the GC.
+
+inline _Jv_VTable *
+_Jv_VTable::new_vtable (int count)
+{
+  size_t size = sizeof(_Jv_VTable) + (count - 1) * vtable_elt_size ();
+  return (_Jv_VTable *) _Jv_AllocBytes (size);
+}
+
 // This function is used to determine the hash code of an object.
 inline jint
 _Jv_HashCode (jobject obj)
index b121a1b7ebb2c2e6acf62178b8fc37a51b21fc27..42c342a3281806a9d02499936e0c2477fd0bb10e 100644 (file)
@@ -691,7 +691,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
          {
            jobject rcv = sp[0].o;
            _Jv_VTable *table = *(_Jv_VTable**)rcv;
-           fun = (void (*)()) table->method[rmeth->vtable_index];
+           fun = (void (*)()) table->get_method(rmeth->vtable_index);
          }
       }
       goto perform_invoke;
index 70dea6db84a89f4a1140bba27c833867fc6226ce..004b9d14b735d2d0dc347cb9dd24f4fdbe2b524d 100644 (file)
@@ -626,20 +626,17 @@ _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader,
   JvAssert (ObjectClass.vtable_method_count == NUM_OBJECT_METHODS);
   int dm_count = ObjectClass.vtable_method_count;
 
-  // Create a new vtable by copying Object's vtable (except the
-  // class pointer, of course).  Note that we allocate this as
-  // unscanned memory -- the vtables are handled specially by the
-  // GC.
-  int size = (sizeof (_Jv_VTable) + ((dm_count - 1) * sizeof (void *)));
+  // Create a new vtable by copying Object's vtable.
   _Jv_VTable *vtable;
   if (array_vtable)
     vtable = array_vtable;
   else
-    vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
+    vtable = _Jv_VTable::new_vtable (dm_count);
   vtable->clas = array_class;
-  memcpy (vtable->method, ObjectClass.vtable->method,
-         dm_count * sizeof (void *));
   vtable->gc_descr = ObjectClass.vtable->gc_descr;
+  for (int i = 0; i < dm_count; ++i)
+    vtable->set_method (i, ObjectClass.vtable->get_method (i));
+
   array_class->vtable = vtable;
   array_class->vtable_method_count = ObjectClass.vtable_method_count;
 
index 9fbc963064563edab1399ec2a9b40778056c9c7d..e44ba6d339a69150bdfe0c81b6ebe40409507223 100644 (file)
@@ -696,9 +696,7 @@ _Jv_PrepareClass(jclass klass)
   clz->vtable_method_count = vtable_count;
 
   /* allocate vtable structure */
-  _Jv_VTable *vtable = (_Jv_VTable*) 
-    _Jv_AllocBytes (sizeof (_Jv_VTable) 
-                          + (sizeof (void*) * (vtable_count)));
+  _Jv_VTable *vtable = _Jv_VTable::new_vtable (vtable_count);
   vtable->clas = clz;
   vtable->gc_descr = _Jv_BuildGCDescr(clz);
 
@@ -712,9 +710,8 @@ _Jv_PrepareClass(jclass klass)
 
     /* copy super class' vtable entries. */
     if (effective_superclass && effective_superclass->vtable)
-      memcpy ((void*)&vtable->method[0],
-             (void*)&effective_superclass->vtable->method[0],
-             sizeof (void*) * effective_superclass->vtable_method_count);
+      for (int i = 0; i < effective_superclass->vtable_method_count; ++i)
+       vtable->set_method (i, effective_superclass->vtable->get_method (i));
   }
 
   /* now, install our own vtable entries, reprise... */
@@ -735,9 +732,9 @@ _Jv_PrepareClass(jclass klass)
            throw_internal_error ("vtable problem...");
 
          if (clz->interpreted_methods[i] == 0)
-           vtable->method[index] = (void*)&_Jv_abstractMethodError;
+           vtable->set_method(i, (void*)&_Jv_abstractMethodError);
          else
-           vtable->method[index] = this_meth->ncode;
+           vtable->set_method(i, this_meth->ncode);
        }
     }