summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-21 16:59:12 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-21 16:59:12 +0000
commit67577e43ece0812b968fd949d8c890e880fc6668 (patch)
tree8a0b15f8ae55ff04e4e9997580f5dcc5bbc78ec7
parent6bfa2cc1b1757ca919c796642fcb4ee2d7fe7fa7 (diff)
downloadgcc-67577e43ece0812b968fd949d8c890e880fc6668.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45734 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog55
-rw-r--r--libjava/include/jvm.h48
-rw-r--r--libjava/interpret.cc2
-rw-r--r--libjava/java/lang/natClassLoader.cc13
-rw-r--r--libjava/resolve.cc13
5 files changed, 84 insertions, 47 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 8981ace8a8c..fe52c144b51 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,14 @@
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.
* java/lang/mprec.c (lo0bits): Fix paren typo.
@@ -127,8 +136,8 @@
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>
@@ -510,8 +519,8 @@
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>
@@ -1098,23 +1107,23 @@
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>
@@ -1286,7 +1295,7 @@
* 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>
@@ -1354,7 +1363,7 @@
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>
diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h
index 936d4c690c6..957869ee581 100644
--- a/libjava/include/jvm.h
+++ b/libjava/include/jvm.h
@@ -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)
diff --git a/libjava/interpret.cc b/libjava/interpret.cc
index b121a1b7ebb..42c342a3281 100644
--- a/libjava/interpret.cc
+++ b/libjava/interpret.cc
@@ -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;
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
index 70dea6db84a..004b9d14b73 100644
--- a/libjava/java/lang/natClassLoader.cc
+++ b/libjava/java/lang/natClassLoader.cc
@@ -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;
diff --git a/libjava/resolve.cc b/libjava/resolve.cc
index 9fbc9630645..e44ba6d339a 100644
--- a/libjava/resolve.cc
+++ b/libjava/resolve.cc
@@ -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);
}
}