1 /* src/vm/classcache.h - loaded class cache and loading constraints
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Edwin Steiner
31 $Id: classcache.h 3837 2005-12-01 23:50:28Z twisti $
39 #include <stdio.h> /* for FILE */
44 #include "vm/hashtable.h"
45 #include "vm/references.h"
48 /* forward declarations *******************************************************/
50 typedef struct classcache_name_entry classcache_name_entry;
51 typedef struct classcache_class_entry classcache_class_entry;
52 typedef struct classcache_loader_entry classcache_loader_entry;
54 typedef java_objectheader classloader;
56 /* global variables ***********************************************************/
58 extern hashtable hashtable_classcache;
61 /* structs ********************************************************************/
63 /*----------------------------------------------------------------------------*/
64 /* The Loaded Class Cache */
66 /* The loaded class cache is implemented as a two-level data structure. */
68 /* The first level is a hash table indexed by class names. For each class */
69 /* name in the cache there is a classcache_name_entry, which collects all */
70 /* information about classes with this class name. */
72 /* Second level: For each classcache_name_entry there is a list of */
73 /* classcache_class_entry:s representing the possible different resolutions */
74 /* of the class name. */
76 /* A classcache_class_entry records the following: */
78 /* - the loaded class object, if this entry has been resolved, otherwise NULL */
79 /* - the list of initiating loaders which have resolved the class name to */
80 /* this class object */
81 /* - the list of initiating loaders which are constrained to resolve this */
82 /* class name to this class object in the future */
84 /* The classcache_class_entry:s approximate the equivalence classes created */
85 /* by the loading constraints and (XXX?) the equivalence of loaded classes. */
87 /* When a loading constraint (loaderA,loaderB,NAME) is added, then the */
88 /* classcache_class_entry:s for NAME containing loaderA and loaderB resp. */
89 /* must be merged into one entry. If this is impossible, because the entries */
90 /* have already been resolved to different class objects, then the constraint */
91 /* is violated and an expception must be thrown. */
92 /*----------------------------------------------------------------------------*/
95 /* classcache_name_entry
97 * For each classname a classcache_name_entry struct is created.
100 struct classcache_name_entry
102 utf *name; /* class name */
103 classcache_name_entry *hashlink; /* link for external chaining */
104 classcache_class_entry *classes; /* equivalence classes for this name*/
107 struct classcache_class_entry
109 classinfo *classobj; /* the loaded class object, or NULL */
110 classcache_loader_entry *loaders;
111 classcache_loader_entry *constraints;
112 classcache_class_entry *next; /* next class entry for same name */
115 struct classcache_loader_entry
117 classloader *loader; /* class loader object */
118 classcache_loader_entry *next; /* next loader entry in the list */
122 /* function prototypes ********************************************************/
124 /* initialize the loaded class cache */
125 bool classcache_init(void);
126 void classcache_free(void);
128 classinfo * classcache_lookup(classloader *initloader,utf *classname);
129 classinfo * classcache_lookup_defined(classloader *defloader,utf *classname);
130 classinfo * classcache_lookup_defined_or_initiated(classloader *loader,utf *classname);
132 bool classcache_store_unique(classinfo *cls);
133 classinfo * classcache_store(classloader *initloader,classinfo *cls,bool mayfree);
134 classinfo * classcache_store_defined(classinfo *cls);
136 bool classcache_add_constraint(classloader *a,classloader *b,utf *classname);
139 void classcache_debug_dump(FILE *file);
142 #endif /* _CLASSCACHE_H */
145 * These are local overrides for various environment variables in Emacs.
146 * Please do not remove this and leave it at the end of the file, where
147 * Emacs will automagically detect them.
148 * ---------------------------------------------------------------------
151 * indent-tabs-mode: t
155 * vim:noexpandtab:sw=4:ts=4: