-/* vm/tables.c -
+/* src/vm/tables.c -
Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
Changes: Mark Probst
Andreas Krall
+ Christian Thalinger
Contains support functions for:
- Reading of Java class files
- the heap
- additional support functions
- $Id: tables.c 1930 2005-02-10 10:54:28Z twisti $
+ $Id: tables.c 3679 2005-11-16 12:12:02Z twisti $
*/
#include <sys/mman.h>
#include <unistd.h>
-#include "types.h"
+#include "config.h"
+#include "vm/types.h"
+
#include "mm/memory.h"
#include "native/native.h"
#include "toolbox/logging.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
#include "vm/tables.h"
+#include "vm/classcache.h"
hashtable string_hash; /* hashtable for javastrings */
}
-/*********************** function: tables_init *****************************
+/* tables_init *****************************************************************
- creates hashtables for symboltables
- (called once at startup)
+ Creates hashtables for symboltables (called once at startup).
-*****************************************************************************/
+*******************************************************************************/
-void tables_init()
+bool tables_init(void)
{
init_hashtable(&utf_hash, UTF_HASHSTART); /* hashtable for utf8-symbols */
init_hashtable(&string_hash, HASHSTART); /* hashtable for javastrings */
- init_hashtable(&class_hash, HASHSTART); /* hashtable for classes */
/* if (opt_eager) */
/* list_init(&unlinkedclasses, OFFSET(classinfo, listnode)); */
if (opt_stat)
count_utf_len += sizeof(utf*) * utf_hash.size;
#endif
+
+ /* everything's ok */
+
+ return true;
}
utf *u = NULL;
literalstring *s;
u4 i;
+
+ classcache_free();
/* dispose utf symbols */
for (i = 0; i < utf_hash.size; i++) {
/* dispose hashtable structures */
MFREE(utf_hash.ptr, void*, utf_hash.size);
MFREE(string_hash.ptr, void*, string_hash.size);
- MFREE(class_hash.ptr, void*, class_hash.size);
}
u2 desc_to_type(utf *descriptor)
{
char *utf_ptr = descriptor->text; /* current position in utf text */
- char logtext[MAXLOGTEXT];
- if (descriptor->blength < 1) panic("Type-Descriptor is empty string");
+ if (descriptor->blength < 1) {
+ log_text("Type-Descriptor is empty string");
+ assert(0);
+ }
switch (*utf_ptr++) {
case 'B':
case '[': return TYPE_ADDRESS;
}
- sprintf(logtext, "Invalid Type-Descriptor: ");
- utf_sprint(logtext+strlen(logtext), descriptor);
- error("%s",logtext);
+ assert(0);
return 0;
}