X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Ftables.c;h=40b880e64371dd7fc0289f8c9bc19c7bc1d8e9cd;hb=4f021ace4cbb48cb8d75e5445929a01f61ca756a;hp=71e18b637e4447964830be7237ca300dc9b5deb1;hpb=0616c8a9409d465004849503376b04f06617ac43;p=cacao.git diff --git a/src/vm/tables.c b/src/vm/tables.c index 71e18b637..40b880e64 100644 --- a/src/vm/tables.c +++ b/src/vm/tables.c @@ -1,4 +1,4 @@ -/* 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, @@ -28,6 +28,7 @@ Changes: Mark Probst Andreas Krall + Christian Thalinger Contains support functions for: - Reading of Java class files @@ -35,7 +36,7 @@ - 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 $ */ @@ -47,7 +48,9 @@ #include #include -#include "types.h" +#include "config.h" +#include "vm/types.h" + #include "mm/memory.h" #include "native/native.h" #include "toolbox/logging.h" @@ -59,6 +62,7 @@ #include "vm/statistics.h" #include "vm/stringlocal.h" #include "vm/tables.h" +#include "vm/classcache.h" hashtable string_hash; /* hashtable for javastrings */ @@ -94,18 +98,16 @@ void init_hashtable(hashtable *hash, u4 size) } -/*********************** 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)); */ @@ -114,6 +116,10 @@ void tables_init() if (opt_stat) count_utf_len += sizeof(utf*) * utf_hash.size; #endif + + /* everything's ok */ + + return true; } @@ -128,6 +134,8 @@ void tables_close() utf *u = NULL; literalstring *s; u4 i; + + classcache_free(); /* dispose utf symbols */ for (i = 0; i < utf_hash.size; i++) { @@ -156,7 +164,6 @@ void tables_close() /* 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); } @@ -175,9 +182,11 @@ void tables_close() 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': @@ -192,9 +201,7 @@ u2 desc_to_type(utf *descriptor) case '[': return TYPE_ADDRESS; } - sprintf(logtext, "Invalid Type-Descriptor: "); - utf_sprint(logtext+strlen(logtext), descriptor); - error("%s",logtext); + assert(0); return 0; }