This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


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

newabi minor cleanup/fixes


This patch improves a few comments for the new abi stuff and fixes a
problem due to missing default constructor in Class.h. It also adds a
small optimization to class initialization.

I'm checking it in.

regards

  [ bryce ]

2001-01-17  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/lang/Class.h (isInterface): Move implementation from 
	natClass.cc. Declare inline.
	(Class): Add default constructor.
	* java/lang/Object.h: Update comments.
	* java/lang/natClass.cc (initializeClass): Use _Jv_InitClass to
	initialize superclass, saving a call if super is already initialized.

Index: java/lang/Class.h
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Class.h,v
retrieving revision 1.30
diff -u -r1.30 Class.h
--- Class.h	2001/01/17 08:13:06	1.30
+++ Class.h	2001/01/17 10:17:36
@@ -174,7 +174,8 @@
 
   jboolean isAssignableFrom (jclass cls);
   jboolean isInstance (jobject obj);
-  jboolean isInterface (void)
+
+  inline jboolean isInterface (void)
   {
     return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
   }
@@ -196,16 +197,17 @@
   // finalization
   void finalize ();
 
+  Class () {};
+
   // This constructor is used to create Class object for the primitive
-  // types.
-  Class (jobject cname, jbyte sig, jint len, jobject array_vtable) {
-    
+  // types. See prims.cc.
+  Class (jobject cname, jbyte sig, jint len, jobject array_vtable)
+  {    
     using namespace java::lang::reflect;
     _Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len);
 
-    // C++ ctors are fixing the vtbl in a way that doesn't fit Java.
-    // We can fix the C++ compiler, or we can hack our runtime. What's
-    // below fix the vtable so that it starts at -2.
+    // C++ ctors set the vtbl pointer to point at an offset inside the vtable
+    // object. That doesn't work for Java, so this hack adjusts it back.
     void *p =  ((void **)this)[0];
     ((void **)this)[0] = (void *)((char *)p-2*sizeof (void *));
 
Index: java/lang/Object.h
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Object.h,v
retrieving revision 1.7
diff -u -r1.7 Object.h
--- Object.h	2001/01/15 08:11:40	1.7
+++ Object.h	2001/01/17 10:17:37
@@ -16,15 +16,13 @@
 #include <gcj/javaprims.h>
 
 // This class is mainly here as a kludge to get G++ to allocate two
-// extra entries in the vtable. We will use them to store data.  This
-// allows us to support the new C++ ABI.
-
+// extra entries in each vtable.
 struct _JvObjectPrefix
 {
 protected:
   // New ABI Compatibility Dummy, #1 and 2.
-  virtual void nacd_1 (void) {};
-  virtual void nacd_2 (void) {};
+  virtual void nacd_1 (void) {};  // This slot really contains the Class pointer.
+  virtual void nacd_2 (void) {};  // Actually the GC bitmap marking descriptor.
 };
 
 class java::lang::Object : public _JvObjectPrefix
Index: java/lang/natClass.cc
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/natClass.cc,v
retrieving revision 1.34
diff -u -r1.34 natClass.cc
--- natClass.cc	2001/01/17 08:13:06	1.34
+++ natClass.cc	2001/01/17 10:17:37
@@ -732,7 +732,7 @@
     {
       try
 	{
-	  superclass->initializeClass ();
+	  _Jv_InitClass (superclass);
 	}
       catch (java::lang::Throwable *except)
 	{

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