/* src/vm/classcache.h - loaded class cache and loading constraints
- 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 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
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
+ Contact: cacao@cacaojvm.org
Authors: Edwin Steiner
Changes:
- $Id: classcache.h 2111 2005-03-29 21:28:24Z twisti $
+ $Id: classcache.h 4945 2006-05-23 19:52:47Z motse $
*/
#ifndef _CLASSCACHE_H
#define _CLASSCACHE_H
+#include "config.h"
+#include "vm/types.h"
+
#include <stdio.h> /* for FILE */
-#include "vm/class.h"
-#include "vm/utf8.h"
+#include "vm/hashtable.h"
+#include "vm/references.h"
/* forward declarations *******************************************************/
typedef java_objectheader classloader;
-/* structs ********************************************************************/
+/* global variables ***********************************************************/
+
+extern hashtable hashtable_classcache;
+
+#if defined(ENABLE_JVMTI)
+#if defined(ENABLE_THREADS)
+# define CLASSCACHE_LOCK() builtin_monitorenter(lock_hashtable_classcache)
+# define CLASSCACHE_UNLOCK() builtin_monitorexit(lock_hashtable_classcache)
+#else
+# define CLASSCACHE_LOCK()
+# define CLASSCACHE_UNLOCK()
+#endif
+extern java_objectheader *lock_hashtable_classcache;
+#endif
+
+/* structs ********************************************************************/
/*----------------------------------------------------------------------------*/
/* The Loaded Class Cache */
struct classcache_name_entry
{
utf *name; /* class name */
- classcache_name_entry *hashlink; /* link for external chaining */
+ classcache_name_entry *hashlink; /* link for external chaining */
classcache_class_entry *classes; /* equivalence classes for this name*/
};
classcache_loader_entry *next; /* next loader entry in the list */
};
+
/* function prototypes ********************************************************/
-/* classcache_init *************************************************************
-
- Initialize the loaded class cache
-
-*******************************************************************************/
-
-void classcache_init();
-
-/* classcache_free *************************************************************
-
- Free the memory used by the class cache
-
- NOTE:
- The class cache may not be used any more after this call, except
- when it is reinitialized with classcache_init.
-
-*******************************************************************************/
-
-void classcache_free();
-
-/* classcache_lookup ***********************************************************
-
- Lookup a possibly loaded class
-
- IN:
- initloader.......initiating loader for resolving the class name
- classname........class name to look up
-
- RETURN VALUE:
- The return value is a pointer to the cached class object,
- or NULL, if the class is not in the cache.
-
-*******************************************************************************/
+/* initialize the loaded class cache */
+bool classcache_init(void);
+void classcache_free(void);
classinfo * classcache_lookup(classloader *initloader,utf *classname);
+classinfo * classcache_lookup_defined(classloader *defloader,utf *classname);
+classinfo * classcache_lookup_defined_or_initiated(classloader *loader,utf *classname);
-/* classcache_store ************************************************************
-
- Store a loaded class
-
- IN:
- initloader.......initiating loader used to load the class
- cls..............class object to cache
-
- RETURN VALUE:
- true.............everything ok, the class was stored in
- the cache if necessary,
- false............an exception has been thrown.
-
-*******************************************************************************/
-
-bool classcache_store(classloader *initloader,classinfo *cls);
-
-/* classcache_add_constraint ***************************************************
-
- Add a loading constraint
-
- IN:
- a................first initiating loader
- b................second initiating loader
- classname........class name
-
- RETURN VALUE:
- true.............everything ok, the constraint has been added,
- false............an exception has been thrown.
-
-*******************************************************************************/
+bool classcache_store_unique(classinfo *cls);
+classinfo * classcache_store(classloader *initloader,classinfo *cls,bool mayfree);
+classinfo * classcache_store_defined(classinfo *cls);
+#if defined(ENABLE_VERIFIER)
bool classcache_add_constraint(classloader *a,classloader *b,utf *classname);
+bool classcache_add_constraints_for_params(classloader *a,classloader *b,
+ methodinfo *m);
+#endif
-/* classcache_debug_dump *******************************************************
-
- Print the contents of the loaded class cache to a stream
-
- IN:
- file.............output stream
-
-*******************************************************************************/
-
-void classcache_debug_dump(FILE *file);
+#ifndef NDEBUG
+void classcache_debug_dump(FILE *file,utf *only);
+#endif
#endif /* _CLASSCACHE_H */