src/vm/classcache.c: export CLASSCACHE_LOCK/UNLOCK and lock_hashtable_classcache
[cacao.git] / src / vm / classcache.h
index c1b35621a8ab30797cd92bbe7496844bb9250862..4be010936938636aaf469df3117627c3e7475dcf 100644 (file)
@@ -1,9 +1,9 @@
 /* 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 3680 2005-11-16 12:12:29Z 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/hashtable.h"
 #include "vm/references.h"
-#include "vm/tables.h"
 
 
 /* forward declarations *******************************************************/
@@ -52,10 +55,21 @@ typedef java_objectheader classloader;
 
 /* global variables ***********************************************************/
 
-extern hashtable classcache_hash;
+extern hashtable hashtable_classcache;
 
-/* structs ********************************************************************/
+#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                                                     */
@@ -115,150 +129,30 @@ struct classcache_loader_entry
        classcache_loader_entry  *next;       /* next loader entry in the list    */
 };
 
+
 /* function prototypes ********************************************************/
 
 /* initialize the loaded class cache */
 bool classcache_init(void);
-
-/* 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.
-   
-*******************************************************************************/
+void classcache_free(void);
 
 classinfo * classcache_lookup(classloader *initloader,utf *classname);
-
-/* classcache_lookup_defined ***************************************************
-   Lookup a class with the given name and defining loader
-  
-   IN:
-       defloader........defining loader
-       classname........class name
-  
-   RETURN VALUE:
-       The return value is a pointer to the cached class object,
-       or NULL, if the class is not in the cache.
-   
-*******************************************************************************/
-
 classinfo * classcache_lookup_defined(classloader *defloader,utf *classname);
-
-/* classcache_store_unique *****************************************************
-   
-   Store a loaded class as loaded by the bootstrap loader. This is a wrapper 
-   aroung classcache_store that throws an exception if a class with the same 
-   name has already been loaded by the bootstrap loader.
-
-   This function is used to register a few special classes during startup.
-   It should not be used otherwise.
-  
-   IN:
-       cls..............class object to cache
-  
-   RETURN VALUE:
-       true.............everything ok, the class was stored.
-       false............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
+classinfo * classcache_lookup_defined_or_initiated(classloader *loader,utf *classname);
 
 bool classcache_store_unique(classinfo *cls);
-
-/* classcache_store ************************************************************
-   
-   Store a loaded class. If a class of the same name has already been stored
-   with the same initiating loader, then the given class CLS is freed (if
-   possible) and the previously stored class is returned.
-  
-   IN:
-       initloader.......initiating loader used to load the class
-                           (may be NULL indicating the bootstrap loader)
-       cls..............class object to cache
-          mayfree..........true if CLS may be freed in case another class is
-                           returned
-  
-   RETURN VALUE:
-       cls..............everything ok, the class was stored in the cache,
-          other classinfo..another class with the same (initloader,name) has been
-                           stored earlier. CLS has been freed and the earlier
-                                               stored class is returned.
-       NULL.............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
 classinfo * classcache_store(classloader *initloader,classinfo *cls,bool mayfree);
-
-/* classcache_store_defined ****************************************************
-   
-   Store a loaded class after it has been defined. If the class has already
-   been defined by the same defining loader in another thread, free the given
-   class and returned the one which has been defined earlier.
-  
-   IN:
-       cls..............class object to store. classloader must be set
-                           (classloader may be NULL, for bootloader)
-  
-   RETURN VALUE:
-       cls..............everything ok, the class was stored the cache,
-          other classinfo..the class had already been defined, CLS was freed, the
-                           class which was defined earlier is returned,
-       NULL.............an exception has been thrown.
-   
-*******************************************************************************/
-
 classinfo * classcache_store_defined(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.
-   
-*******************************************************************************/
-
+#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 */