/* src/vm/descriptor.c - checking and parsing of field / method descriptors
- 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: Christian Thalinger
Christian Ullrich
- $Id: descriptor.c 3825 2005-12-01 18:46:29Z edwin $
+ $Id: descriptor.c 5171 2006-07-25 13:52:38Z twisti $
*/
+#include "config.h"
+
#include <assert.h>
-#include "types.h"
+#include "vm/types.h"
+
#include "md-abi.h"
#include "mm/memory.h"
#include "vm/descriptor.h"
#include "vm/exceptions.h"
+#include "vm/options.h"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
u2 descriptor_to_basic_type(utf *descriptor)
{
- char *utf_ptr = descriptor->text;
-
assert(descriptor->blength >= 1);
- switch (*utf_ptr++) {
- case 'B':
- case 'C':
- case 'I':
- case 'S':
- case 'Z': return TYPE_INT;
- case 'D': return TYPE_DOUBLE;
- case 'F': return TYPE_FLOAT;
- case 'J': return TYPE_LONG;
- case 'L':
- case '[': return TYPE_ADDRESS;
+ switch (descriptor->text[0]) {
+ case 'B':
+ case 'C':
+ case 'I':
+ case 'S':
+ case 'Z': return TYPE_INT;
+ case 'D': return TYPE_DBL;
+ case 'F': return TYPE_FLT;
+ case 'J': return TYPE_LNG;
+ case 'L':
+ case '[': return TYPE_ADR;
}
assert(0);
assert(td);
switch (td->type) {
- case TYPE_INT: return 4;
- case TYPE_LONG: return 8;
- case TYPE_FLOAT: return 4;
- case TYPE_DOUBLE: return 8;
- case TYPE_ADDRESS: return sizeof(voidptr);
+ case TYPE_INT: return 4;
+ case TYPE_LNG: return 8;
+ case TYPE_FLT: return 4;
+ case TYPE_DBL: return 8;
+ case TYPE_ADR: return sizeof(voidptr);
}
assert(0);
if (name) {
/* a reference type */
- td->type = TYPE_ADDRESS;
- td->decltype = TYPE_ADDRESS;
+ td->type = TYPE_ADR;
+ td->decltype = TYPE_ADR;
td->arraydim = 0;
for (utf_ptr = name->text; *utf_ptr == '['; ++utf_ptr)
td->arraydim++;
break;
case 'D':
td->decltype = PRIMITIVETYPE_DOUBLE;
- td->type = TYPE_DOUBLE;
+ td->type = TYPE_DBL;
break;
case 'F':
td->decltype = PRIMITIVETYPE_FLOAT;
- td->type = TYPE_FLOAT;
+ td->type = TYPE_FLT;
break;
case 'J':
td->decltype = PRIMITIVETYPE_LONG;
- td->type = TYPE_LONG;
+ td->type = TYPE_LNG;
break;
case 'V':
td->decltype = PRIMITIVETYPE_VOID;
#ifdef DESCRIPTOR_VERBOSE
fprintf(stderr,"descriptor_pool_add_class(%p,",(void*)pool);
- utf_fprint(stderr,name);fprintf(stderr,")\n");
+ utf_fprint_printable_ascii(stderr,name);fprintf(stderr,")\n");
#endif
/* find a place in the hashtable */
#ifdef DESCRIPTOR_VERBOSE
fprintf(stderr,"descriptor_pool_add(%p,",(void*)pool);
- utf_fprint(stderr,desc);fprintf(stderr,")\n");
+ utf_fprint_printable_ascii(stderr,desc);fprintf(stderr,")\n");
#endif
assert(pool);
#ifdef DESCRIPTOR_VERBOSE
fprintf(stderr,"descriptor_pool_parse_method_descriptor(%p,%d,%p,",
(void*)pool,(int)mflags,(void*)thisclass);
- utf_fprint(stderr,desc); fprintf(stderr,")\n");
+ utf_fprint_printable_ascii(stderr,desc); fprintf(stderr,")\n");
#endif
assert(pool);
if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, &utf_ptr, td))
return NULL;
- if (td->type == TYPE_LONG || td->type == TYPE_DOUBLE)
+ if (IS_2_WORD_TYPE(td->type))
paramslots++;
td++;
}
/* fill the paramdesc */
- /* md_param_alloc has to be called if md->paramcount == 0, too, so it */
- /* can make the reservation for the Linkage Area, Return Register... */
- md_param_alloc(md);
- }
- else {
- /* params will be allocated later by descriptor_params_from_paramtypes */
- /* if necessary */
+ /* md_param_alloc has to be called if md->paramcount == 0,
+ too, so it can make the reservation for the Linkage Area,
+ Return Register... */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+# endif
+ md_param_alloc(md);
+#endif
+
+ } else {
+ /* params will be allocated later by
+ descriptor_params_from_paramtypes if necessary */
+
md->params = NULL;
}
/* allocate memory for params */
md->params = MNEW(paramdesc, md->paramcount);
- }
- else {
+
+ } else {
md->params = METHODDESC_NOPARAMS;
}
/* fill the paramdesc */
- /* md_param_alloc has to be called if md->paramcount == 0, too, so */
- /* it can make the reservation for the Linkage Area, Return Register.. */
-
- md_param_alloc(md);
+ /* md_param_alloc has to be called if md->paramcount == 0, too, so
+ it can make the reservation for the Linkage Area, Return
+ Register.. */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+# endif
+ md_param_alloc(md);
+#endif
return true;
}
return;
}
- if (d->type == TYPE_ADDRESS) {
+ if (d->type == TYPE_ADR) {
if (d->classref)
- utf_fprint(file,d->classref->name);
+ utf_fprint_printable_ascii(file,d->classref->name);
else
fprintf(file,"<class=NULL>");
}
u4 size;
fprintf(file,"======[descriptor_pool for ");
- utf_fprint(file,pool->referer->name);
+ utf_fprint_printable_ascii(file,pool->referer->name);
fprintf(file,"]======\n");
fprintf(file,"fieldcount: %d\n",pool->fieldcount);
classref_hash_entry *c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
while (c) {
fprintf(file," %4d: ",c->index);
- utf_fprint(file,c->name);
+ utf_fprint_printable_ascii(file,c->name);
fprintf(file,"\n");
c = c->hashlink;
}
descriptor_hash_entry *c = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
while (c) {
fprintf(file," %p: ",c->parseddesc.any);
- utf_fprint(file,c->desc);
+ utf_fprint_printable_ascii(file,c->desc);
fprintf(file,"\n");
c = c->hashlink;
}