Merged trunk and subtype.
[cacao.git] / src / vm / linker.h
index cd77fcec4474e0c2ef8eff0dac7228dfb9438eb4..b9dc1876ff4dda700a2553f243bd0cd9dbf113f7 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/linker.h - class linker header
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: linker.h 2148 2005-03-30 16:49:40Z twisti $
 */
 
 
@@ -42,7 +33,13 @@ typedef struct arraydescriptor arraydescriptor;
 typedef struct primitivetypeinfo primitivetypeinfo;
 
 
+#include "config.h"
+#include "vm/types.h"
+
+#include "threads/mutex.hpp"
+
 #include "vm/class.h"
+#include "vm/references.h"
 
 
 /* virtual function table ******************************************************
@@ -84,34 +81,42 @@ typedef struct primitivetypeinfo primitivetypeinfo;
    interfacetablelength = 4
 
                   | ...       |            +----------+
-                     +-----------+            | method 2 |---> method z
-                     | class     |            | method 1 |---> method y
-                     +-----------+            | method 0 |---> method x
-                     | ivftbl  0 |----------> +----------+
-       vftblptr ---> +-----------+
+                  +-----------+            | method 2 |---> method z
+                  | class     |            | method 1 |---> method y
+                  +-----------+            | method 0 |---> method x
+                  | ivftbl  0 |----------> +----------+
+    vftblptr ---> +-----------+
                   | ivftbl -1 |--> NULL    +----------+
                   | ivftbl -2 |--> NULL    | method 1 |---> method x
                   | ivftbl -3 |-----+      | method 0 |---> method a
                   +-----------+     +----> +----------+
      
                               +---------------+
-                                 | length 3 = 2  |
-                                 | length 2 = 0  |
-                                 | length 1 = 0  |
-                                 | length 0 = 3  |
-       interfacevftbllength ---> +---------------+
+                              | length 3 = 2  |
+                              | length 2 = 0  |
+                              | length 1 = 0  |
+                              | length 0 = 3  |
+    interfacevftbllength ---> +---------------+
 
 *******************************************************************************/
 
+#define DISPLAY_SIZE 4
+
 struct _vftbl {
        methodptr   *interfacetable[1];    /* interface table (access via macro)  */
-       classinfo   *class;                /* class, the vtbl belongs to          */
+       classinfo   *clazz;                /* class, the vtbl belongs to          */
        arraydescriptor *arraydesc;        /* for array classes, otherwise NULL   */
        s4           vftbllength;          /* virtual function table length       */
        s4           interfacetablelength; /* interface table length              */
        s4           baseval;              /* base for runtime type check         */
                                           /* (-index for interfaces)             */
        s4           diffval;              /* high - base for runtime type check  */
+
+       s4 subtype_depth;
+       s4 subtype_offset;
+       struct _vftbl *subtype_display[DISPLAY_SIZE+1];  /* the last one is cache */
+       struct _vftbl **subtype_overflow;
+
        s4          *interfacevftbllength; /* length of interface vftbls          */
        methodptr    table[1];             /* class vftbl                         */
 };
@@ -136,33 +141,20 @@ struct arraydescriptor {
 };
 
 
-/* primitivetypeinfo **********************************************************/
-
-struct primitivetypeinfo {
-       classinfo *class_wrap;               /* class for wrapping primitive type */
-       classinfo *class_primitive;          /* primitive class                   */
-       char      *wrapname;                 /* name of class for wrapping        */
-       char       typesig;                  /* one character type signature      */
-       char      *name;                     /* name of primitive class           */
-       char      *arrayname;                /* name of primitive array class     */
-       classinfo *arrayclass;               /* primitive array class             */
-       vftbl_t   *arrayvftbl;               /* vftbl of primitive array class    */
-};
-
-
-/* global variables ***********************************************************/
-
-/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_ constants   */
-/* (except ARRAYTYPE_OBJECT).                                                 */
-
-extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
-
-
 /* function prototypes ********************************************************/
 
-bool linker_init(void);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void       linker_preinit(void);
+void       linker_init(void);
 classinfo *link_class(classinfo *c);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LINKER_H */