/* src/vm/classcache.h - loaded class cache and loading constraints
- 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Edwin Steiner
-
- Changes:
-
- $Id: classcache.h 4945 2006-05-23 19:52:47Z motse $
-
*/
#define _CLASSCACHE_H
#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "vm/types.h"
#include <stdio.h> /* for FILE */
-#include "vm/hashtable.h"
+#if defined(ENABLE_JVMTI)
+# include "native/jni.h"
+#endif
+
+#include "toolbox/hashtable.h"
+
+#include "vm/class.h"
+#include "vm/global.h"
+#include "vm/loader.h"
#include "vm/references.h"
typedef struct classcache_class_entry classcache_class_entry;
typedef struct classcache_loader_entry classcache_loader_entry;
-typedef java_objectheader classloader;
-
/* 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 ********************************************************************/
/* class name to this class object in the future */
/* */
/* The classcache_class_entry:s approximate the equivalence classes created */
-/* by the loading constraints and (XXX?) the equivalence of loaded classes. */
+/* by the loading constraints and the equivalence of loaded classes. */
/* */
/* When a loading constraint (loaderA,loaderB,NAME) is added, then the */
/* classcache_class_entry:s for NAME containing loaderA and loaderB resp. */
struct classcache_loader_entry
{
- classloader *loader; /* class loader object */
+ classloader_t *loader; /* class loader object */
classcache_loader_entry *next; /* next loader entry in the list */
};
+/* callback function type for classcache_foreach_loaded_class */
+
+typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *);
+
+
/* function prototypes ********************************************************/
/* 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);
+classinfo * classcache_lookup(classloader_t *initloader,utf *classname);
+classinfo * classcache_lookup_defined(classloader_t *defloader,utf *classname);
+classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader,utf *classname);
bool classcache_store_unique(classinfo *cls);
-classinfo * classcache_store(classloader *initloader,classinfo *cls,bool mayfree);
+classinfo * classcache_store(classloader_t *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,
+bool classcache_add_constraint(classloader_t *a,classloader_t *b,utf *classname);
+bool classcache_add_constraints_for_params(classloader_t *a,classloader_t *b,
methodinfo *m);
#endif
+s4 classcache_get_loaded_class_count(void);
+
+void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
+ void *data);
+
+#if defined(ENABLE_JVMTI)
+void classcache_get_loaded_classes(s4 *class_count_ptr,
+ classinfo ***classes_ptr);
+#endif
+
#ifndef NDEBUG
void classcache_debug_dump(FILE *file,utf *only);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _CLASSCACHE_H */
/*